From 270504923dbb52b725ca6e6fdd3d96bdeb6aa14c Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Wed, 18 Jan 2017 14:48:02 +0000 Subject: [PATCH] Fixed Scale Mode references. --- v3/src/checksum.js | 2 +- v3/src/gameobjects/GameObject.js | 3 ++- v3/src/renderer/canvas/CanvasRenderer.js | 18 ++++-------------- v3/src/renderer/canvas/utils/DrawImage.js | 2 +- .../renderer/webgl/utils/CreateEmptyTexture.js | 4 ++-- v3/src/state/Settings.js | 3 ++- v3/src/textures/TextureSource.js | 5 ++--- 7 files changed, 14 insertions(+), 23 deletions(-) diff --git a/v3/src/checksum.js b/v3/src/checksum.js index 9857c84cc..5b9cda6ae 100644 --- a/v3/src/checksum.js +++ b/v3/src/checksum.js @@ -1,4 +1,4 @@ var CHECKSUM = { -build: '746a1440-dd75-11e6-9565-df50d68fb751' +build: 'b42592a0-dd8c-11e6-9836-0f8afa574dfa' }; module.exports = CHECKSUM; \ No newline at end of file diff --git a/v3/src/gameobjects/GameObject.js b/v3/src/gameobjects/GameObject.js index 99a234131..db6d51aae 100644 --- a/v3/src/gameobjects/GameObject.js +++ b/v3/src/gameobjects/GameObject.js @@ -6,6 +6,7 @@ var CONST = require('../const'); var MATH_CONST = require('../math/const'); +var ScaleModes = require('../renderer/ScaleModes'); var Component = require('../components'); var WrapAngle = require('../math/angle/Wrap'); @@ -51,7 +52,7 @@ var GameObject = function (state, x, y, texture, frame, parent) // ---------------------------------------------------------------- // ---------------------------------------------------------------- - this.scaleMode = CONST.scaleModes.DEFAULT; + this.scaleMode = ScaleModes.DEFAULT; // Allows you to turn off a GameObject from rendering, but still render its children (if it has any) // Maybe this should move? diff --git a/v3/src/renderer/canvas/CanvasRenderer.js b/v3/src/renderer/canvas/CanvasRenderer.js index bdaa56c49..449f8c7eb 100644 --- a/v3/src/renderer/canvas/CanvasRenderer.js +++ b/v3/src/renderer/canvas/CanvasRenderer.js @@ -13,7 +13,7 @@ var CanvasRenderer = function (game) // Needed? this.type = CONST.CANVAS; - // Read all the following from game config + // Read all the following from game config (or State config?) this.clearBeforeRender = true; this.transparent = false; @@ -50,10 +50,6 @@ var CanvasRenderer = function (game) this.currentBlendMode = 0; this.currentScaleMode = 0; - this.startTime = 0; - this.endTime = 0; - this.drawCount = 0; - // this.tintMethod = this.tintWithPerPixel; this.init(); @@ -86,7 +82,7 @@ CanvasRenderer.prototype = { // if (this.smoothProperty) // { - // this.context[this.smoothProperty] = (this.scaleMode === Phaser.scaleModes.LINEAR); + // this.context[this.smoothProperty] = (this.scaleMode === ScaleModes.LINEAR); // } }, @@ -109,8 +105,6 @@ CanvasRenderer.prototype = { // TODO: A State should have the option of having its own canvas to draw to - this.startTime = Date.now(); - ctx.setTransform(1, 0, 0, 1, 0, 0); // If the alpha or blend mode didn't change since the last render, then don't set them again (saves 2 ops) @@ -118,29 +112,25 @@ CanvasRenderer.prototype = { if (this.currentAlpha !== 1) { ctx.globalAlpha = 1; + this.currentAlpha = 1; } if (this.currentBlendMode !== 0) { ctx.globalCompositeOperation = 'source-over'; + this.currentBlendMode = 0; } - this.currentBlendMode = 0; this.currentScaleMode = 0; - this.currentAlpha = 1; if (this.clearBeforeRender) { ctx.clearRect(0, 0, this.width, this.height); } - this.drawCount = 0; - // Could move to the State Systems or MainLoop this.game.state.renderChildren(this, state, interpolationPercentage); - this.endTime = Date.now(); - // console.log('%c render end ', 'color: #ffffff; background: #ff0000;'); // Add Post-render hook diff --git a/v3/src/renderer/canvas/utils/DrawImage.js b/v3/src/renderer/canvas/utils/DrawImage.js index b9bec3e31..3ed25c465 100644 --- a/v3/src/renderer/canvas/utils/DrawImage.js +++ b/v3/src/renderer/canvas/utils/DrawImage.js @@ -25,7 +25,7 @@ var DrawImage = function (frame, blendMode, transform, alpha, tint, bg) if (this.currentScaleMode !== frame.source.scaleMode) { // this.currentScaleMode = source.scaleMode; - // ctx[this.smoothProperty] = (source.scaleMode === Phaser.scaleModes.LINEAR); + // ctx[this.smoothProperty] = (source.scaleMode === ScaleModes.LINEAR); } ctx.setTransform(transform.a, transform.b, transform.c, transform.d, transform.tx, transform.ty); diff --git a/v3/src/renderer/webgl/utils/CreateEmptyTexture.js b/v3/src/renderer/webgl/utils/CreateEmptyTexture.js index b2ebd8f0f..55b82fc83 100644 --- a/v3/src/renderer/webgl/utils/CreateEmptyTexture.js +++ b/v3/src/renderer/webgl/utils/CreateEmptyTexture.js @@ -1,9 +1,9 @@ -var CONST = require('../../../const'); +var ScaleModes = require('../../ScaleModes'); var CreateEmptyTexture = function (gl, width, height, scaleMode, textureIndex) { var texture = gl.createTexture(); - var glScaleMode = (scaleMode === CONST.scaleModes.LINEAR) ? gl.LINEAR : gl.NEAREST; + var glScaleMode = (scaleMode === ScaleModes.LINEAR) ? gl.LINEAR : gl.NEAREST; gl.activeTexture(gl.TEXTURE0 + textureIndex); gl.bindTexture(gl.TEXTURE_2D, texture); diff --git a/v3/src/state/Settings.js b/v3/src/state/Settings.js index 799ebdc3f..23d8f7f0f 100644 --- a/v3/src/state/Settings.js +++ b/v3/src/state/Settings.js @@ -1,4 +1,5 @@ var CONST = require('../const'); +var ScaleModes = require('../renderer/ScaleModes'); var GetObjectValue = require('../utils/GetObjectValue'); var Settings = function (state, config) @@ -24,7 +25,7 @@ var Settings = function (state, config) this.key = GetObjectValue(config, 'key', ''); this.active = GetObjectValue(config, 'active', false); this.visible = GetObjectValue(config, 'visible', true); - this.scaleMode = GetObjectValue(config, 'scaleMode', CONST.scaleModes.DEFAULT); + this.scaleMode = GetObjectValue(config, 'scaleMode', ScaleModes.DEFAULT); this.fps = GetObjectValue(config, 'fps', 60); this.x = GetObjectValue(config, 'x', 0); this.y = GetObjectValue(config, 'y', 0); diff --git a/v3/src/textures/TextureSource.js b/v3/src/textures/TextureSource.js index 21ef2a26b..dac83eb03 100644 --- a/v3/src/textures/TextureSource.js +++ b/v3/src/textures/TextureSource.js @@ -4,7 +4,7 @@ * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var CONST = require('../const'); +var ScaleModes = require('../renderer/ScaleModes'); var IsSizePowerOfTwo = require('../math/pow2/IsSizePowerOfTwo'); /** @@ -56,8 +56,7 @@ var TextureSource = function (texture, source) * @type {Number} * @default Phaser.scaleModes.DEFAULT; */ - this.scaleMode = CONST.scaleModes.DEFAULT; - // this.scaleMode = CONST.scaleModes.NEAREST; + this.scaleMode = ScaleModes.DEFAULT; /** * Controls if RGB channels should be pre-multiplied by Alpha (WebGL only)