From cbf9b3f71f14c870c0c7c4590137eed4e6a40d06 Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Sat, 26 Sep 2015 00:58:02 +0100 Subject: [PATCH] WebGLRenderer.mapBlendModes optimised to cut down on file size. --- README.md | 1 + src/pixi/renderers/webgl/WebGLRenderer.js | 39 ++++++++++++----------- 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index b7f36621a..abcae937d 100644 --- a/README.md +++ b/README.md @@ -316,6 +316,7 @@ Please note that Phaser uses a custom build of Pixi and always has done. The fol * CanvasRenderer.mapBlendModes optimised to cut down on file size. * PIXI.WebGLRenderer.updateTexture now returns a boolean depending on if the texture was successfully bound to the gl context or not. * PIXI.WebGLSpriteBatch.renderBatch would still try and render a texture even if `updateTexture` failed to bind it. It now checks the return value from `updateTexture` and ignores failed binds. +* WebGLRenderer.mapBlendModes optimised to cut down on file size. For changes in previous releases please see the extensive [Version History](https://github.com/photonstorm/phaser/blob/master/CHANGELOG.md). diff --git a/src/pixi/renderers/webgl/WebGLRenderer.js b/src/pixi/renderers/webgl/WebGLRenderer.js index 2b2f75275..88844cd41 100644 --- a/src/pixi/renderers/webgl/WebGLRenderer.js +++ b/src/pixi/renderers/webgl/WebGLRenderer.js @@ -443,25 +443,28 @@ PIXI.WebGLRenderer.prototype.mapBlendModes = function() if (!PIXI.blendModesWebGL) { - PIXI.blendModesWebGL = []; + var b = []; + var modes = PIXI.blendModes; - PIXI.blendModesWebGL[PIXI.blendModes.NORMAL] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - PIXI.blendModesWebGL[PIXI.blendModes.ADD] = [gl.SRC_ALPHA, gl.DST_ALPHA]; - PIXI.blendModesWebGL[PIXI.blendModes.MULTIPLY] = [gl.DST_COLOR, gl.ONE_MINUS_SRC_ALPHA]; - PIXI.blendModesWebGL[PIXI.blendModes.SCREEN] = [gl.SRC_ALPHA, gl.ONE]; - PIXI.blendModesWebGL[PIXI.blendModes.OVERLAY] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - PIXI.blendModesWebGL[PIXI.blendModes.DARKEN] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - PIXI.blendModesWebGL[PIXI.blendModes.LIGHTEN] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - PIXI.blendModesWebGL[PIXI.blendModes.COLOR_DODGE] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - PIXI.blendModesWebGL[PIXI.blendModes.COLOR_BURN] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - PIXI.blendModesWebGL[PIXI.blendModes.HARD_LIGHT] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - PIXI.blendModesWebGL[PIXI.blendModes.SOFT_LIGHT] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - PIXI.blendModesWebGL[PIXI.blendModes.DIFFERENCE] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - PIXI.blendModesWebGL[PIXI.blendModes.EXCLUSION] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - PIXI.blendModesWebGL[PIXI.blendModes.HUE] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - PIXI.blendModesWebGL[PIXI.blendModes.SATURATION] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - PIXI.blendModesWebGL[PIXI.blendModes.COLOR] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - PIXI.blendModesWebGL[PIXI.blendModes.LUMINOSITY] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + b[modes.NORMAL] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + b[modes.ADD] = [gl.SRC_ALPHA, gl.DST_ALPHA]; + b[modes.MULTIPLY] = [gl.DST_COLOR, gl.ONE_MINUS_SRC_ALPHA]; + b[modes.SCREEN] = [gl.SRC_ALPHA, gl.ONE]; + b[modes.OVERLAY] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + b[modes.DARKEN] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + b[modes.LIGHTEN] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + b[modes.COLOR_DODGE] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + b[modes.COLOR_BURN] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + b[modes.HARD_LIGHT] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + b[modes.SOFT_LIGHT] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + b[modes.DIFFERENCE] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + b[modes.EXCLUSION] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + b[modes.HUE] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + b[modes.SATURATION] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + b[modes.COLOR] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + b[modes.LUMINOSITY] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + + PIXI.blendModesWebGL = b; } };