diff --git a/src/core/renderers/canvas/CanvasRenderer.js b/src/core/renderers/canvas/CanvasRenderer.js index 24eafc9..389ae5e 100644 --- a/src/core/renderers/canvas/CanvasRenderer.js +++ b/src/core/renderers/canvas/CanvasRenderer.js @@ -10,6 +10,7 @@ * * @class * @memberof PIXI + * @extends SystemRenderer * @param [width=800] {number} the width of the canvas view * @param [height=600] {number} the height of the canvas view * @param [options] {object} The optional renderer parameters diff --git a/src/core/renderers/canvas/CanvasRenderer.js b/src/core/renderers/canvas/CanvasRenderer.js index 24eafc9..389ae5e 100644 --- a/src/core/renderers/canvas/CanvasRenderer.js +++ b/src/core/renderers/canvas/CanvasRenderer.js @@ -10,6 +10,7 @@ * * @class * @memberof PIXI + * @extends SystemRenderer * @param [width=800] {number} the width of the canvas view * @param [height=600] {number} the height of the canvas view * @param [options] {object} The optional renderer parameters diff --git a/src/core/renderers/webgl/WebGLRenderer.js b/src/core/renderers/webgl/WebGLRenderer.js index 15ce4fe..6bfb6de 100644 --- a/src/core/renderers/webgl/WebGLRenderer.js +++ b/src/core/renderers/webgl/WebGLRenderer.js @@ -265,7 +265,7 @@ * Renders a Display Object. * * @param displayObject {DisplayObject} The DisplayObject to render - * @param renderTarget {Point} TODO @alvin + * @param renderTarget {RenderTarget} The render target to use to render this display object * */ WebGLRenderer.prototype.renderDisplayObject = function (displayObject, renderTarget)//projection, buffer) @@ -305,7 +305,7 @@ /** * Changes the current render target to the one given in parameter * - * @param renderTarget {Object} the new render target + * @param renderTarget {RenderTarget} the new render target * */ WebGLRenderer.prototype.setRenderTarget = function (renderTarget) diff --git a/src/core/renderers/canvas/CanvasRenderer.js b/src/core/renderers/canvas/CanvasRenderer.js index 24eafc9..389ae5e 100644 --- a/src/core/renderers/canvas/CanvasRenderer.js +++ b/src/core/renderers/canvas/CanvasRenderer.js @@ -10,6 +10,7 @@ * * @class * @memberof PIXI + * @extends SystemRenderer * @param [width=800] {number} the width of the canvas view * @param [height=600] {number} the height of the canvas view * @param [options] {object} The optional renderer parameters diff --git a/src/core/renderers/webgl/WebGLRenderer.js b/src/core/renderers/webgl/WebGLRenderer.js index 15ce4fe..6bfb6de 100644 --- a/src/core/renderers/webgl/WebGLRenderer.js +++ b/src/core/renderers/webgl/WebGLRenderer.js @@ -265,7 +265,7 @@ * Renders a Display Object. * * @param displayObject {DisplayObject} The DisplayObject to render - * @param renderTarget {Point} TODO @alvin + * @param renderTarget {RenderTarget} The render target to use to render this display object * */ WebGLRenderer.prototype.renderDisplayObject = function (displayObject, renderTarget)//projection, buffer) @@ -305,7 +305,7 @@ /** * Changes the current render target to the one given in parameter * - * @param renderTarget {Object} the new render target + * @param renderTarget {RenderTarget} the new render target * */ WebGLRenderer.prototype.setRenderTarget = function (renderTarget) diff --git a/src/core/renderers/webgl/filters/AbstractFilter.js b/src/core/renderers/webgl/filters/AbstractFilter.js index 91e874c..7a3cb01 100644 --- a/src/core/renderers/webgl/filters/AbstractFilter.js +++ b/src/core/renderers/webgl/filters/AbstractFilter.js @@ -84,6 +84,13 @@ return shader; }; +/* + * Applies the filter + * @param renderer {Shader} + * @param input {Any} + * @param output {Any} + * @param clear {boolean} Whether or not we want to clear the outputTarget + */ AbstractFilter.prototype.applyFilter = function (renderer, input, output, clear) { var shader = this.getShader(renderer); diff --git a/src/core/renderers/canvas/CanvasRenderer.js b/src/core/renderers/canvas/CanvasRenderer.js index 24eafc9..389ae5e 100644 --- a/src/core/renderers/canvas/CanvasRenderer.js +++ b/src/core/renderers/canvas/CanvasRenderer.js @@ -10,6 +10,7 @@ * * @class * @memberof PIXI + * @extends SystemRenderer * @param [width=800] {number} the width of the canvas view * @param [height=600] {number} the height of the canvas view * @param [options] {object} The optional renderer parameters diff --git a/src/core/renderers/webgl/WebGLRenderer.js b/src/core/renderers/webgl/WebGLRenderer.js index 15ce4fe..6bfb6de 100644 --- a/src/core/renderers/webgl/WebGLRenderer.js +++ b/src/core/renderers/webgl/WebGLRenderer.js @@ -265,7 +265,7 @@ * Renders a Display Object. * * @param displayObject {DisplayObject} The DisplayObject to render - * @param renderTarget {Point} TODO @alvin + * @param renderTarget {RenderTarget} The render target to use to render this display object * */ WebGLRenderer.prototype.renderDisplayObject = function (displayObject, renderTarget)//projection, buffer) @@ -305,7 +305,7 @@ /** * Changes the current render target to the one given in parameter * - * @param renderTarget {Object} the new render target + * @param renderTarget {RenderTarget} the new render target * */ WebGLRenderer.prototype.setRenderTarget = function (renderTarget) diff --git a/src/core/renderers/webgl/filters/AbstractFilter.js b/src/core/renderers/webgl/filters/AbstractFilter.js index 91e874c..7a3cb01 100644 --- a/src/core/renderers/webgl/filters/AbstractFilter.js +++ b/src/core/renderers/webgl/filters/AbstractFilter.js @@ -84,6 +84,13 @@ return shader; }; +/* + * Applies the filter + * @param renderer {Shader} + * @param input {Any} + * @param output {Any} + * @param clear {boolean} Whether or not we want to clear the outputTarget + */ AbstractFilter.prototype.applyFilter = function (renderer, input, output, clear) { var shader = this.getShader(renderer); diff --git a/src/core/renderers/webgl/filters/FXAAFilter.js b/src/core/renderers/webgl/filters/FXAAFilter.js index f9398d1..bda7830 100644 --- a/src/core/renderers/webgl/filters/FXAAFilter.js +++ b/src/core/renderers/webgl/filters/FXAAFilter.js @@ -1,14 +1,19 @@ var AbstractFilter = require('./AbstractFilter'); /** - * The FXAAFilter class uses the pixel values from the specified texture (called the displacement map) to perform a displacement of an object. - * You can use this filter to apply all manor of crazy warping effects - * Currently the r property of the texture is used to offset the x and the g property of the texture is used to offset the y. + * + * Basic FXAA implementation based on the code on geeks3d.com with the + * modification that the texture2DLod stuff was removed since it's + * unsupported by WebGL. + * + * -- + * From: + * https://github.com/mitsuhiko/webgl-meincraft * * @class * @extends AbstractFilter * @memberof PIXI - * @param texture {Texture} The texture used for the displacement map * must be power of 2 texture at the moment + * */ function FXAAFilter() { @@ -25,52 +30,6 @@ } ); - /** -Basic FXAA implementation based on the code on geeks3d.com with the -modification that the texture2DLod stuff was removed since it's -unsupported by WebGL. - --- - -From: -https://github.com/mitsuhiko/webgl-meincraft - -Copyright (c) 2011 by Armin Ronacher. - -Some rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. - - * The names of the contributors may not be used to endorse or - promote products derived from this software without specific - prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - - - - } FXAAFilter.prototype = Object.create(AbstractFilter.prototype); diff --git a/src/core/renderers/canvas/CanvasRenderer.js b/src/core/renderers/canvas/CanvasRenderer.js index 24eafc9..389ae5e 100644 --- a/src/core/renderers/canvas/CanvasRenderer.js +++ b/src/core/renderers/canvas/CanvasRenderer.js @@ -10,6 +10,7 @@ * * @class * @memberof PIXI + * @extends SystemRenderer * @param [width=800] {number} the width of the canvas view * @param [height=600] {number} the height of the canvas view * @param [options] {object} The optional renderer parameters diff --git a/src/core/renderers/webgl/WebGLRenderer.js b/src/core/renderers/webgl/WebGLRenderer.js index 15ce4fe..6bfb6de 100644 --- a/src/core/renderers/webgl/WebGLRenderer.js +++ b/src/core/renderers/webgl/WebGLRenderer.js @@ -265,7 +265,7 @@ * Renders a Display Object. * * @param displayObject {DisplayObject} The DisplayObject to render - * @param renderTarget {Point} TODO @alvin + * @param renderTarget {RenderTarget} The render target to use to render this display object * */ WebGLRenderer.prototype.renderDisplayObject = function (displayObject, renderTarget)//projection, buffer) @@ -305,7 +305,7 @@ /** * Changes the current render target to the one given in parameter * - * @param renderTarget {Object} the new render target + * @param renderTarget {RenderTarget} the new render target * */ WebGLRenderer.prototype.setRenderTarget = function (renderTarget) diff --git a/src/core/renderers/webgl/filters/AbstractFilter.js b/src/core/renderers/webgl/filters/AbstractFilter.js index 91e874c..7a3cb01 100644 --- a/src/core/renderers/webgl/filters/AbstractFilter.js +++ b/src/core/renderers/webgl/filters/AbstractFilter.js @@ -84,6 +84,13 @@ return shader; }; +/* + * Applies the filter + * @param renderer {Shader} + * @param input {Any} + * @param output {Any} + * @param clear {boolean} Whether or not we want to clear the outputTarget + */ AbstractFilter.prototype.applyFilter = function (renderer, input, output, clear) { var shader = this.getShader(renderer); diff --git a/src/core/renderers/webgl/filters/FXAAFilter.js b/src/core/renderers/webgl/filters/FXAAFilter.js index f9398d1..bda7830 100644 --- a/src/core/renderers/webgl/filters/FXAAFilter.js +++ b/src/core/renderers/webgl/filters/FXAAFilter.js @@ -1,14 +1,19 @@ var AbstractFilter = require('./AbstractFilter'); /** - * The FXAAFilter class uses the pixel values from the specified texture (called the displacement map) to perform a displacement of an object. - * You can use this filter to apply all manor of crazy warping effects - * Currently the r property of the texture is used to offset the x and the g property of the texture is used to offset the y. + * + * Basic FXAA implementation based on the code on geeks3d.com with the + * modification that the texture2DLod stuff was removed since it's + * unsupported by WebGL. + * + * -- + * From: + * https://github.com/mitsuhiko/webgl-meincraft * * @class * @extends AbstractFilter * @memberof PIXI - * @param texture {Texture} The texture used for the displacement map * must be power of 2 texture at the moment + * */ function FXAAFilter() { @@ -25,52 +30,6 @@ } ); - /** -Basic FXAA implementation based on the code on geeks3d.com with the -modification that the texture2DLod stuff was removed since it's -unsupported by WebGL. - --- - -From: -https://github.com/mitsuhiko/webgl-meincraft - -Copyright (c) 2011 by Armin Ronacher. - -Some rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. - - * The names of the contributors may not be used to endorse or - promote products derived from this software without specific - prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - - - - } FXAAFilter.prototype = Object.create(AbstractFilter.prototype); diff --git a/src/core/renderers/webgl/filters/SpriteMaskFilter.js b/src/core/renderers/webgl/filters/SpriteMaskFilter.js index 4b09a8c..e1e5167 100644 --- a/src/core/renderers/webgl/filters/SpriteMaskFilter.js +++ b/src/core/renderers/webgl/filters/SpriteMaskFilter.js @@ -2,14 +2,12 @@ math = require('../../../math'); /** - * The SpriteMaskFilter class uses the pixel values from the specified texture (called the displacement map) to perform a displacement of an object. - * You can use this filter to apply all manor of crazy warping effects - * Currently the r property of the texture is used to offset the x and the g property of the texture is used to offset the y. + * The SpriteMaskFilter class * * @class * @extends AbstractFilter * @memberof PIXI - * @param texture {Texture} The texture used for the displacement map * must be power of 2 texture at the moment + * @param sprite {Sprite} the target sprite */ function SpriteMaskFilter(sprite) { @@ -72,6 +70,13 @@ SpriteMaskFilter.prototype.constructor = SpriteMaskFilter; module.exports = SpriteMaskFilter; +/** + * Applies the filter ? @alvin + * + * @param renderer {WebGLRenderer} A reference to the WebGL renderer + * @param input {} + * @param output {} + */ SpriteMaskFilter.prototype.applyFilter = function (renderer, input, output) { var filterManager = renderer.filterManager; diff --git a/src/core/renderers/canvas/CanvasRenderer.js b/src/core/renderers/canvas/CanvasRenderer.js index 24eafc9..389ae5e 100644 --- a/src/core/renderers/canvas/CanvasRenderer.js +++ b/src/core/renderers/canvas/CanvasRenderer.js @@ -10,6 +10,7 @@ * * @class * @memberof PIXI + * @extends SystemRenderer * @param [width=800] {number} the width of the canvas view * @param [height=600] {number} the height of the canvas view * @param [options] {object} The optional renderer parameters diff --git a/src/core/renderers/webgl/WebGLRenderer.js b/src/core/renderers/webgl/WebGLRenderer.js index 15ce4fe..6bfb6de 100644 --- a/src/core/renderers/webgl/WebGLRenderer.js +++ b/src/core/renderers/webgl/WebGLRenderer.js @@ -265,7 +265,7 @@ * Renders a Display Object. * * @param displayObject {DisplayObject} The DisplayObject to render - * @param renderTarget {Point} TODO @alvin + * @param renderTarget {RenderTarget} The render target to use to render this display object * */ WebGLRenderer.prototype.renderDisplayObject = function (displayObject, renderTarget)//projection, buffer) @@ -305,7 +305,7 @@ /** * Changes the current render target to the one given in parameter * - * @param renderTarget {Object} the new render target + * @param renderTarget {RenderTarget} the new render target * */ WebGLRenderer.prototype.setRenderTarget = function (renderTarget) diff --git a/src/core/renderers/webgl/filters/AbstractFilter.js b/src/core/renderers/webgl/filters/AbstractFilter.js index 91e874c..7a3cb01 100644 --- a/src/core/renderers/webgl/filters/AbstractFilter.js +++ b/src/core/renderers/webgl/filters/AbstractFilter.js @@ -84,6 +84,13 @@ return shader; }; +/* + * Applies the filter + * @param renderer {Shader} + * @param input {Any} + * @param output {Any} + * @param clear {boolean} Whether or not we want to clear the outputTarget + */ AbstractFilter.prototype.applyFilter = function (renderer, input, output, clear) { var shader = this.getShader(renderer); diff --git a/src/core/renderers/webgl/filters/FXAAFilter.js b/src/core/renderers/webgl/filters/FXAAFilter.js index f9398d1..bda7830 100644 --- a/src/core/renderers/webgl/filters/FXAAFilter.js +++ b/src/core/renderers/webgl/filters/FXAAFilter.js @@ -1,14 +1,19 @@ var AbstractFilter = require('./AbstractFilter'); /** - * The FXAAFilter class uses the pixel values from the specified texture (called the displacement map) to perform a displacement of an object. - * You can use this filter to apply all manor of crazy warping effects - * Currently the r property of the texture is used to offset the x and the g property of the texture is used to offset the y. + * + * Basic FXAA implementation based on the code on geeks3d.com with the + * modification that the texture2DLod stuff was removed since it's + * unsupported by WebGL. + * + * -- + * From: + * https://github.com/mitsuhiko/webgl-meincraft * * @class * @extends AbstractFilter * @memberof PIXI - * @param texture {Texture} The texture used for the displacement map * must be power of 2 texture at the moment + * */ function FXAAFilter() { @@ -25,52 +30,6 @@ } ); - /** -Basic FXAA implementation based on the code on geeks3d.com with the -modification that the texture2DLod stuff was removed since it's -unsupported by WebGL. - --- - -From: -https://github.com/mitsuhiko/webgl-meincraft - -Copyright (c) 2011 by Armin Ronacher. - -Some rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. - - * The names of the contributors may not be used to endorse or - promote products derived from this software without specific - prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - - - - } FXAAFilter.prototype = Object.create(AbstractFilter.prototype); diff --git a/src/core/renderers/webgl/filters/SpriteMaskFilter.js b/src/core/renderers/webgl/filters/SpriteMaskFilter.js index 4b09a8c..e1e5167 100644 --- a/src/core/renderers/webgl/filters/SpriteMaskFilter.js +++ b/src/core/renderers/webgl/filters/SpriteMaskFilter.js @@ -2,14 +2,12 @@ math = require('../../../math'); /** - * The SpriteMaskFilter class uses the pixel values from the specified texture (called the displacement map) to perform a displacement of an object. - * You can use this filter to apply all manor of crazy warping effects - * Currently the r property of the texture is used to offset the x and the g property of the texture is used to offset the y. + * The SpriteMaskFilter class * * @class * @extends AbstractFilter * @memberof PIXI - * @param texture {Texture} The texture used for the displacement map * must be power of 2 texture at the moment + * @param sprite {Sprite} the target sprite */ function SpriteMaskFilter(sprite) { @@ -72,6 +70,13 @@ SpriteMaskFilter.prototype.constructor = SpriteMaskFilter; module.exports = SpriteMaskFilter; +/** + * Applies the filter ? @alvin + * + * @param renderer {WebGLRenderer} A reference to the WebGL renderer + * @param input {} + * @param output {} + */ SpriteMaskFilter.prototype.applyFilter = function (renderer, input, output) { var filterManager = renderer.filterManager; diff --git a/src/core/renderers/webgl/managers/BlendModeManager.js b/src/core/renderers/webgl/managers/BlendModeManager.js index be51394..356f641 100644 --- a/src/core/renderers/webgl/managers/BlendModeManager.js +++ b/src/core/renderers/webgl/managers/BlendModeManager.js @@ -3,6 +3,7 @@ /** * @class * @memberof PIXI + * @extends WebGlManager * @param renderer {WebGLRenderer} The renderer this manager works for. */ function BlendModeManager(renderer) diff --git a/src/core/renderers/canvas/CanvasRenderer.js b/src/core/renderers/canvas/CanvasRenderer.js index 24eafc9..389ae5e 100644 --- a/src/core/renderers/canvas/CanvasRenderer.js +++ b/src/core/renderers/canvas/CanvasRenderer.js @@ -10,6 +10,7 @@ * * @class * @memberof PIXI + * @extends SystemRenderer * @param [width=800] {number} the width of the canvas view * @param [height=600] {number} the height of the canvas view * @param [options] {object} The optional renderer parameters diff --git a/src/core/renderers/webgl/WebGLRenderer.js b/src/core/renderers/webgl/WebGLRenderer.js index 15ce4fe..6bfb6de 100644 --- a/src/core/renderers/webgl/WebGLRenderer.js +++ b/src/core/renderers/webgl/WebGLRenderer.js @@ -265,7 +265,7 @@ * Renders a Display Object. * * @param displayObject {DisplayObject} The DisplayObject to render - * @param renderTarget {Point} TODO @alvin + * @param renderTarget {RenderTarget} The render target to use to render this display object * */ WebGLRenderer.prototype.renderDisplayObject = function (displayObject, renderTarget)//projection, buffer) @@ -305,7 +305,7 @@ /** * Changes the current render target to the one given in parameter * - * @param renderTarget {Object} the new render target + * @param renderTarget {RenderTarget} the new render target * */ WebGLRenderer.prototype.setRenderTarget = function (renderTarget) diff --git a/src/core/renderers/webgl/filters/AbstractFilter.js b/src/core/renderers/webgl/filters/AbstractFilter.js index 91e874c..7a3cb01 100644 --- a/src/core/renderers/webgl/filters/AbstractFilter.js +++ b/src/core/renderers/webgl/filters/AbstractFilter.js @@ -84,6 +84,13 @@ return shader; }; +/* + * Applies the filter + * @param renderer {Shader} + * @param input {Any} + * @param output {Any} + * @param clear {boolean} Whether or not we want to clear the outputTarget + */ AbstractFilter.prototype.applyFilter = function (renderer, input, output, clear) { var shader = this.getShader(renderer); diff --git a/src/core/renderers/webgl/filters/FXAAFilter.js b/src/core/renderers/webgl/filters/FXAAFilter.js index f9398d1..bda7830 100644 --- a/src/core/renderers/webgl/filters/FXAAFilter.js +++ b/src/core/renderers/webgl/filters/FXAAFilter.js @@ -1,14 +1,19 @@ var AbstractFilter = require('./AbstractFilter'); /** - * The FXAAFilter class uses the pixel values from the specified texture (called the displacement map) to perform a displacement of an object. - * You can use this filter to apply all manor of crazy warping effects - * Currently the r property of the texture is used to offset the x and the g property of the texture is used to offset the y. + * + * Basic FXAA implementation based on the code on geeks3d.com with the + * modification that the texture2DLod stuff was removed since it's + * unsupported by WebGL. + * + * -- + * From: + * https://github.com/mitsuhiko/webgl-meincraft * * @class * @extends AbstractFilter * @memberof PIXI - * @param texture {Texture} The texture used for the displacement map * must be power of 2 texture at the moment + * */ function FXAAFilter() { @@ -25,52 +30,6 @@ } ); - /** -Basic FXAA implementation based on the code on geeks3d.com with the -modification that the texture2DLod stuff was removed since it's -unsupported by WebGL. - --- - -From: -https://github.com/mitsuhiko/webgl-meincraft - -Copyright (c) 2011 by Armin Ronacher. - -Some rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. - - * The names of the contributors may not be used to endorse or - promote products derived from this software without specific - prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - - - - } FXAAFilter.prototype = Object.create(AbstractFilter.prototype); diff --git a/src/core/renderers/webgl/filters/SpriteMaskFilter.js b/src/core/renderers/webgl/filters/SpriteMaskFilter.js index 4b09a8c..e1e5167 100644 --- a/src/core/renderers/webgl/filters/SpriteMaskFilter.js +++ b/src/core/renderers/webgl/filters/SpriteMaskFilter.js @@ -2,14 +2,12 @@ math = require('../../../math'); /** - * The SpriteMaskFilter class uses the pixel values from the specified texture (called the displacement map) to perform a displacement of an object. - * You can use this filter to apply all manor of crazy warping effects - * Currently the r property of the texture is used to offset the x and the g property of the texture is used to offset the y. + * The SpriteMaskFilter class * * @class * @extends AbstractFilter * @memberof PIXI - * @param texture {Texture} The texture used for the displacement map * must be power of 2 texture at the moment + * @param sprite {Sprite} the target sprite */ function SpriteMaskFilter(sprite) { @@ -72,6 +70,13 @@ SpriteMaskFilter.prototype.constructor = SpriteMaskFilter; module.exports = SpriteMaskFilter; +/** + * Applies the filter ? @alvin + * + * @param renderer {WebGLRenderer} A reference to the WebGL renderer + * @param input {} + * @param output {} + */ SpriteMaskFilter.prototype.applyFilter = function (renderer, input, output) { var filterManager = renderer.filterManager; diff --git a/src/core/renderers/webgl/managers/BlendModeManager.js b/src/core/renderers/webgl/managers/BlendModeManager.js index be51394..356f641 100644 --- a/src/core/renderers/webgl/managers/BlendModeManager.js +++ b/src/core/renderers/webgl/managers/BlendModeManager.js @@ -3,6 +3,7 @@ /** * @class * @memberof PIXI + * @extends WebGlManager * @param renderer {WebGLRenderer} The renderer this manager works for. */ function BlendModeManager(renderer) diff --git a/src/core/renderers/webgl/managers/FilterManager.js b/src/core/renderers/webgl/managers/FilterManager.js index b22513d..7576ef3 100644 --- a/src/core/renderers/webgl/managers/FilterManager.js +++ b/src/core/renderers/webgl/managers/FilterManager.js @@ -6,6 +6,7 @@ /** * @class * @memberof PIXI + * @extends WebGLManager * @param renderer {WebGLRenderer} The renderer this manager works for. */ function FilterManager(renderer) @@ -41,6 +42,10 @@ module.exports = FilterManager; +/** + * Called when there is a WebGL context change. + * + */ FilterManager.prototype.onContextChange = function () { this.texturePool.length = 0; @@ -117,7 +122,7 @@ /** - * Removes the last filter from the filter stack and doesn't return it. + * Removes the last filter from the filter stack and returns it. * */ FilterManager.prototype.popFilter = function () @@ -192,6 +197,12 @@ return filterData.filter; }; +/** + * Grabs an render target from the internal pool + * + * @param clear {boolean} Whether or not we need to clear the RenderTarget + * @return {RenderTarget} + */ FilterManager.prototype.getRenderTarget = function ( clear ) { var renderTarget = this.texturePool.pop() || new RenderTarget(this.renderer.gl, this.textureSize.width, this.textureSize.height, null, this.renderer.resolution); @@ -205,11 +216,22 @@ return renderTarget; }; +/* + * Returns a RenderTarget to the internal pool + * @param renderTarget {RenderTarget} The RenderTarget we want to return to the pool + */ FilterManager.prototype.returnRenderTarget = function (renderTarget) { this.texturePool.push( renderTarget ); }; +/* + * Applies the filter + * @param shader {Shader} + * @param inputTarget {Any} + * @param outputTarget {Any} + * @param clear {boolean} Whether or not we want to clear the outputTarget + */ FilterManager.prototype.applyFilter = function (shader, inputTarget, outputTarget, clear) { var gl = this.renderer.gl; @@ -240,7 +262,12 @@ gl.drawElements(gl.TRIANGLES, 6, gl.UNSIGNED_SHORT, 0 ); }; - +/* + * Constrains the filter area to the texture size + * @param filterArea {Rectangle} The filter area + * @param sprite {Sprite} the target sprite + * @param outputMatrix {Matrix} @alvin + */ // TODO playing around here.. this is temporary - (will end up in the shader) FilterManager.prototype.calculateMappedMatrix = function (filterArea, sprite, outputMatrix) { @@ -308,6 +335,10 @@ // return transform; }; +/* + * Constrains the filter area to the texture size + * @param filterArea {Rectangle} The filter area we want to cap + */ FilterManager.prototype.capFilterArea = function (filterArea) { if (filterArea.x < 0) @@ -333,6 +364,11 @@ } }; +/* + * Resizes all the render targets in the pool + * @param width {number} the new width + * @param height {number} the new height + */ FilterManager.prototype.resize = function ( width, height ) { this.textureSize.width = width; diff --git a/src/core/renderers/canvas/CanvasRenderer.js b/src/core/renderers/canvas/CanvasRenderer.js index 24eafc9..389ae5e 100644 --- a/src/core/renderers/canvas/CanvasRenderer.js +++ b/src/core/renderers/canvas/CanvasRenderer.js @@ -10,6 +10,7 @@ * * @class * @memberof PIXI + * @extends SystemRenderer * @param [width=800] {number} the width of the canvas view * @param [height=600] {number} the height of the canvas view * @param [options] {object} The optional renderer parameters diff --git a/src/core/renderers/webgl/WebGLRenderer.js b/src/core/renderers/webgl/WebGLRenderer.js index 15ce4fe..6bfb6de 100644 --- a/src/core/renderers/webgl/WebGLRenderer.js +++ b/src/core/renderers/webgl/WebGLRenderer.js @@ -265,7 +265,7 @@ * Renders a Display Object. * * @param displayObject {DisplayObject} The DisplayObject to render - * @param renderTarget {Point} TODO @alvin + * @param renderTarget {RenderTarget} The render target to use to render this display object * */ WebGLRenderer.prototype.renderDisplayObject = function (displayObject, renderTarget)//projection, buffer) @@ -305,7 +305,7 @@ /** * Changes the current render target to the one given in parameter * - * @param renderTarget {Object} the new render target + * @param renderTarget {RenderTarget} the new render target * */ WebGLRenderer.prototype.setRenderTarget = function (renderTarget) diff --git a/src/core/renderers/webgl/filters/AbstractFilter.js b/src/core/renderers/webgl/filters/AbstractFilter.js index 91e874c..7a3cb01 100644 --- a/src/core/renderers/webgl/filters/AbstractFilter.js +++ b/src/core/renderers/webgl/filters/AbstractFilter.js @@ -84,6 +84,13 @@ return shader; }; +/* + * Applies the filter + * @param renderer {Shader} + * @param input {Any} + * @param output {Any} + * @param clear {boolean} Whether or not we want to clear the outputTarget + */ AbstractFilter.prototype.applyFilter = function (renderer, input, output, clear) { var shader = this.getShader(renderer); diff --git a/src/core/renderers/webgl/filters/FXAAFilter.js b/src/core/renderers/webgl/filters/FXAAFilter.js index f9398d1..bda7830 100644 --- a/src/core/renderers/webgl/filters/FXAAFilter.js +++ b/src/core/renderers/webgl/filters/FXAAFilter.js @@ -1,14 +1,19 @@ var AbstractFilter = require('./AbstractFilter'); /** - * The FXAAFilter class uses the pixel values from the specified texture (called the displacement map) to perform a displacement of an object. - * You can use this filter to apply all manor of crazy warping effects - * Currently the r property of the texture is used to offset the x and the g property of the texture is used to offset the y. + * + * Basic FXAA implementation based on the code on geeks3d.com with the + * modification that the texture2DLod stuff was removed since it's + * unsupported by WebGL. + * + * -- + * From: + * https://github.com/mitsuhiko/webgl-meincraft * * @class * @extends AbstractFilter * @memberof PIXI - * @param texture {Texture} The texture used for the displacement map * must be power of 2 texture at the moment + * */ function FXAAFilter() { @@ -25,52 +30,6 @@ } ); - /** -Basic FXAA implementation based on the code on geeks3d.com with the -modification that the texture2DLod stuff was removed since it's -unsupported by WebGL. - --- - -From: -https://github.com/mitsuhiko/webgl-meincraft - -Copyright (c) 2011 by Armin Ronacher. - -Some rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. - - * The names of the contributors may not be used to endorse or - promote products derived from this software without specific - prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - - - - } FXAAFilter.prototype = Object.create(AbstractFilter.prototype); diff --git a/src/core/renderers/webgl/filters/SpriteMaskFilter.js b/src/core/renderers/webgl/filters/SpriteMaskFilter.js index 4b09a8c..e1e5167 100644 --- a/src/core/renderers/webgl/filters/SpriteMaskFilter.js +++ b/src/core/renderers/webgl/filters/SpriteMaskFilter.js @@ -2,14 +2,12 @@ math = require('../../../math'); /** - * The SpriteMaskFilter class uses the pixel values from the specified texture (called the displacement map) to perform a displacement of an object. - * You can use this filter to apply all manor of crazy warping effects - * Currently the r property of the texture is used to offset the x and the g property of the texture is used to offset the y. + * The SpriteMaskFilter class * * @class * @extends AbstractFilter * @memberof PIXI - * @param texture {Texture} The texture used for the displacement map * must be power of 2 texture at the moment + * @param sprite {Sprite} the target sprite */ function SpriteMaskFilter(sprite) { @@ -72,6 +70,13 @@ SpriteMaskFilter.prototype.constructor = SpriteMaskFilter; module.exports = SpriteMaskFilter; +/** + * Applies the filter ? @alvin + * + * @param renderer {WebGLRenderer} A reference to the WebGL renderer + * @param input {} + * @param output {} + */ SpriteMaskFilter.prototype.applyFilter = function (renderer, input, output) { var filterManager = renderer.filterManager; diff --git a/src/core/renderers/webgl/managers/BlendModeManager.js b/src/core/renderers/webgl/managers/BlendModeManager.js index be51394..356f641 100644 --- a/src/core/renderers/webgl/managers/BlendModeManager.js +++ b/src/core/renderers/webgl/managers/BlendModeManager.js @@ -3,6 +3,7 @@ /** * @class * @memberof PIXI + * @extends WebGlManager * @param renderer {WebGLRenderer} The renderer this manager works for. */ function BlendModeManager(renderer) diff --git a/src/core/renderers/webgl/managers/FilterManager.js b/src/core/renderers/webgl/managers/FilterManager.js index b22513d..7576ef3 100644 --- a/src/core/renderers/webgl/managers/FilterManager.js +++ b/src/core/renderers/webgl/managers/FilterManager.js @@ -6,6 +6,7 @@ /** * @class * @memberof PIXI + * @extends WebGLManager * @param renderer {WebGLRenderer} The renderer this manager works for. */ function FilterManager(renderer) @@ -41,6 +42,10 @@ module.exports = FilterManager; +/** + * Called when there is a WebGL context change. + * + */ FilterManager.prototype.onContextChange = function () { this.texturePool.length = 0; @@ -117,7 +122,7 @@ /** - * Removes the last filter from the filter stack and doesn't return it. + * Removes the last filter from the filter stack and returns it. * */ FilterManager.prototype.popFilter = function () @@ -192,6 +197,12 @@ return filterData.filter; }; +/** + * Grabs an render target from the internal pool + * + * @param clear {boolean} Whether or not we need to clear the RenderTarget + * @return {RenderTarget} + */ FilterManager.prototype.getRenderTarget = function ( clear ) { var renderTarget = this.texturePool.pop() || new RenderTarget(this.renderer.gl, this.textureSize.width, this.textureSize.height, null, this.renderer.resolution); @@ -205,11 +216,22 @@ return renderTarget; }; +/* + * Returns a RenderTarget to the internal pool + * @param renderTarget {RenderTarget} The RenderTarget we want to return to the pool + */ FilterManager.prototype.returnRenderTarget = function (renderTarget) { this.texturePool.push( renderTarget ); }; +/* + * Applies the filter + * @param shader {Shader} + * @param inputTarget {Any} + * @param outputTarget {Any} + * @param clear {boolean} Whether or not we want to clear the outputTarget + */ FilterManager.prototype.applyFilter = function (shader, inputTarget, outputTarget, clear) { var gl = this.renderer.gl; @@ -240,7 +262,12 @@ gl.drawElements(gl.TRIANGLES, 6, gl.UNSIGNED_SHORT, 0 ); }; - +/* + * Constrains the filter area to the texture size + * @param filterArea {Rectangle} The filter area + * @param sprite {Sprite} the target sprite + * @param outputMatrix {Matrix} @alvin + */ // TODO playing around here.. this is temporary - (will end up in the shader) FilterManager.prototype.calculateMappedMatrix = function (filterArea, sprite, outputMatrix) { @@ -308,6 +335,10 @@ // return transform; }; +/* + * Constrains the filter area to the texture size + * @param filterArea {Rectangle} The filter area we want to cap + */ FilterManager.prototype.capFilterArea = function (filterArea) { if (filterArea.x < 0) @@ -333,6 +364,11 @@ } }; +/* + * Resizes all the render targets in the pool + * @param width {number} the new width + * @param height {number} the new height + */ FilterManager.prototype.resize = function ( width, height ) { this.textureSize.width = width; diff --git a/src/core/renderers/webgl/managers/MaskManager.js b/src/core/renderers/webgl/managers/MaskManager.js index 472eea1..fbc8e9c 100644 --- a/src/core/renderers/webgl/managers/MaskManager.js +++ b/src/core/renderers/webgl/managers/MaskManager.js @@ -40,6 +40,12 @@ }; +/** + * Removes the last mask from the mask stack and doesn't return it. + * + * @param target {RenderTarget} + * @param maskData {any[]} + */ MaskManager.prototype.popMask = function (target, maskData) { if (maskData.texture) @@ -52,6 +58,12 @@ } }; +/** + * Applies the Mask and adds it to the current filter stack. + * + * @param target {RenderTarget} + * @param maskData {any[]} + */ MaskManager.prototype.pushSpriteMask = function (target, maskData) { var alphaMaskFilter = this.alphaMaskPool.pop(); @@ -79,9 +91,9 @@ /** * Applies the Mask and adds it to the current filter stack. * + * @param target {RenderTarget} * @param maskData {any[]} */ - MaskManager.prototype.pushStencilMask = function (target, maskData) { this.renderer.stencilManager.pushMask(maskData); @@ -89,7 +101,7 @@ /** * Removes the last filter from the filter stack and doesn't return it. - * + * @param target {RenderTarget} * @param maskData {any[]} */ MaskManager.prototype.popStencilMask = function (target, maskData) diff --git a/src/core/renderers/canvas/CanvasRenderer.js b/src/core/renderers/canvas/CanvasRenderer.js index 24eafc9..389ae5e 100644 --- a/src/core/renderers/canvas/CanvasRenderer.js +++ b/src/core/renderers/canvas/CanvasRenderer.js @@ -10,6 +10,7 @@ * * @class * @memberof PIXI + * @extends SystemRenderer * @param [width=800] {number} the width of the canvas view * @param [height=600] {number} the height of the canvas view * @param [options] {object} The optional renderer parameters diff --git a/src/core/renderers/webgl/WebGLRenderer.js b/src/core/renderers/webgl/WebGLRenderer.js index 15ce4fe..6bfb6de 100644 --- a/src/core/renderers/webgl/WebGLRenderer.js +++ b/src/core/renderers/webgl/WebGLRenderer.js @@ -265,7 +265,7 @@ * Renders a Display Object. * * @param displayObject {DisplayObject} The DisplayObject to render - * @param renderTarget {Point} TODO @alvin + * @param renderTarget {RenderTarget} The render target to use to render this display object * */ WebGLRenderer.prototype.renderDisplayObject = function (displayObject, renderTarget)//projection, buffer) @@ -305,7 +305,7 @@ /** * Changes the current render target to the one given in parameter * - * @param renderTarget {Object} the new render target + * @param renderTarget {RenderTarget} the new render target * */ WebGLRenderer.prototype.setRenderTarget = function (renderTarget) diff --git a/src/core/renderers/webgl/filters/AbstractFilter.js b/src/core/renderers/webgl/filters/AbstractFilter.js index 91e874c..7a3cb01 100644 --- a/src/core/renderers/webgl/filters/AbstractFilter.js +++ b/src/core/renderers/webgl/filters/AbstractFilter.js @@ -84,6 +84,13 @@ return shader; }; +/* + * Applies the filter + * @param renderer {Shader} + * @param input {Any} + * @param output {Any} + * @param clear {boolean} Whether or not we want to clear the outputTarget + */ AbstractFilter.prototype.applyFilter = function (renderer, input, output, clear) { var shader = this.getShader(renderer); diff --git a/src/core/renderers/webgl/filters/FXAAFilter.js b/src/core/renderers/webgl/filters/FXAAFilter.js index f9398d1..bda7830 100644 --- a/src/core/renderers/webgl/filters/FXAAFilter.js +++ b/src/core/renderers/webgl/filters/FXAAFilter.js @@ -1,14 +1,19 @@ var AbstractFilter = require('./AbstractFilter'); /** - * The FXAAFilter class uses the pixel values from the specified texture (called the displacement map) to perform a displacement of an object. - * You can use this filter to apply all manor of crazy warping effects - * Currently the r property of the texture is used to offset the x and the g property of the texture is used to offset the y. + * + * Basic FXAA implementation based on the code on geeks3d.com with the + * modification that the texture2DLod stuff was removed since it's + * unsupported by WebGL. + * + * -- + * From: + * https://github.com/mitsuhiko/webgl-meincraft * * @class * @extends AbstractFilter * @memberof PIXI - * @param texture {Texture} The texture used for the displacement map * must be power of 2 texture at the moment + * */ function FXAAFilter() { @@ -25,52 +30,6 @@ } ); - /** -Basic FXAA implementation based on the code on geeks3d.com with the -modification that the texture2DLod stuff was removed since it's -unsupported by WebGL. - --- - -From: -https://github.com/mitsuhiko/webgl-meincraft - -Copyright (c) 2011 by Armin Ronacher. - -Some rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. - - * The names of the contributors may not be used to endorse or - promote products derived from this software without specific - prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - - - - } FXAAFilter.prototype = Object.create(AbstractFilter.prototype); diff --git a/src/core/renderers/webgl/filters/SpriteMaskFilter.js b/src/core/renderers/webgl/filters/SpriteMaskFilter.js index 4b09a8c..e1e5167 100644 --- a/src/core/renderers/webgl/filters/SpriteMaskFilter.js +++ b/src/core/renderers/webgl/filters/SpriteMaskFilter.js @@ -2,14 +2,12 @@ math = require('../../../math'); /** - * The SpriteMaskFilter class uses the pixel values from the specified texture (called the displacement map) to perform a displacement of an object. - * You can use this filter to apply all manor of crazy warping effects - * Currently the r property of the texture is used to offset the x and the g property of the texture is used to offset the y. + * The SpriteMaskFilter class * * @class * @extends AbstractFilter * @memberof PIXI - * @param texture {Texture} The texture used for the displacement map * must be power of 2 texture at the moment + * @param sprite {Sprite} the target sprite */ function SpriteMaskFilter(sprite) { @@ -72,6 +70,13 @@ SpriteMaskFilter.prototype.constructor = SpriteMaskFilter; module.exports = SpriteMaskFilter; +/** + * Applies the filter ? @alvin + * + * @param renderer {WebGLRenderer} A reference to the WebGL renderer + * @param input {} + * @param output {} + */ SpriteMaskFilter.prototype.applyFilter = function (renderer, input, output) { var filterManager = renderer.filterManager; diff --git a/src/core/renderers/webgl/managers/BlendModeManager.js b/src/core/renderers/webgl/managers/BlendModeManager.js index be51394..356f641 100644 --- a/src/core/renderers/webgl/managers/BlendModeManager.js +++ b/src/core/renderers/webgl/managers/BlendModeManager.js @@ -3,6 +3,7 @@ /** * @class * @memberof PIXI + * @extends WebGlManager * @param renderer {WebGLRenderer} The renderer this manager works for. */ function BlendModeManager(renderer) diff --git a/src/core/renderers/webgl/managers/FilterManager.js b/src/core/renderers/webgl/managers/FilterManager.js index b22513d..7576ef3 100644 --- a/src/core/renderers/webgl/managers/FilterManager.js +++ b/src/core/renderers/webgl/managers/FilterManager.js @@ -6,6 +6,7 @@ /** * @class * @memberof PIXI + * @extends WebGLManager * @param renderer {WebGLRenderer} The renderer this manager works for. */ function FilterManager(renderer) @@ -41,6 +42,10 @@ module.exports = FilterManager; +/** + * Called when there is a WebGL context change. + * + */ FilterManager.prototype.onContextChange = function () { this.texturePool.length = 0; @@ -117,7 +122,7 @@ /** - * Removes the last filter from the filter stack and doesn't return it. + * Removes the last filter from the filter stack and returns it. * */ FilterManager.prototype.popFilter = function () @@ -192,6 +197,12 @@ return filterData.filter; }; +/** + * Grabs an render target from the internal pool + * + * @param clear {boolean} Whether or not we need to clear the RenderTarget + * @return {RenderTarget} + */ FilterManager.prototype.getRenderTarget = function ( clear ) { var renderTarget = this.texturePool.pop() || new RenderTarget(this.renderer.gl, this.textureSize.width, this.textureSize.height, null, this.renderer.resolution); @@ -205,11 +216,22 @@ return renderTarget; }; +/* + * Returns a RenderTarget to the internal pool + * @param renderTarget {RenderTarget} The RenderTarget we want to return to the pool + */ FilterManager.prototype.returnRenderTarget = function (renderTarget) { this.texturePool.push( renderTarget ); }; +/* + * Applies the filter + * @param shader {Shader} + * @param inputTarget {Any} + * @param outputTarget {Any} + * @param clear {boolean} Whether or not we want to clear the outputTarget + */ FilterManager.prototype.applyFilter = function (shader, inputTarget, outputTarget, clear) { var gl = this.renderer.gl; @@ -240,7 +262,12 @@ gl.drawElements(gl.TRIANGLES, 6, gl.UNSIGNED_SHORT, 0 ); }; - +/* + * Constrains the filter area to the texture size + * @param filterArea {Rectangle} The filter area + * @param sprite {Sprite} the target sprite + * @param outputMatrix {Matrix} @alvin + */ // TODO playing around here.. this is temporary - (will end up in the shader) FilterManager.prototype.calculateMappedMatrix = function (filterArea, sprite, outputMatrix) { @@ -308,6 +335,10 @@ // return transform; }; +/* + * Constrains the filter area to the texture size + * @param filterArea {Rectangle} The filter area we want to cap + */ FilterManager.prototype.capFilterArea = function (filterArea) { if (filterArea.x < 0) @@ -333,6 +364,11 @@ } }; +/* + * Resizes all the render targets in the pool + * @param width {number} the new width + * @param height {number} the new height + */ FilterManager.prototype.resize = function ( width, height ) { this.textureSize.width = width; diff --git a/src/core/renderers/webgl/managers/MaskManager.js b/src/core/renderers/webgl/managers/MaskManager.js index 472eea1..fbc8e9c 100644 --- a/src/core/renderers/webgl/managers/MaskManager.js +++ b/src/core/renderers/webgl/managers/MaskManager.js @@ -40,6 +40,12 @@ }; +/** + * Removes the last mask from the mask stack and doesn't return it. + * + * @param target {RenderTarget} + * @param maskData {any[]} + */ MaskManager.prototype.popMask = function (target, maskData) { if (maskData.texture) @@ -52,6 +58,12 @@ } }; +/** + * Applies the Mask and adds it to the current filter stack. + * + * @param target {RenderTarget} + * @param maskData {any[]} + */ MaskManager.prototype.pushSpriteMask = function (target, maskData) { var alphaMaskFilter = this.alphaMaskPool.pop(); @@ -79,9 +91,9 @@ /** * Applies the Mask and adds it to the current filter stack. * + * @param target {RenderTarget} * @param maskData {any[]} */ - MaskManager.prototype.pushStencilMask = function (target, maskData) { this.renderer.stencilManager.pushMask(maskData); @@ -89,7 +101,7 @@ /** * Removes the last filter from the filter stack and doesn't return it. - * + * @param target {RenderTarget} * @param maskData {any[]} */ MaskManager.prototype.popStencilMask = function (target, maskData) diff --git a/src/core/renderers/webgl/managers/ShaderManager.js b/src/core/renderers/webgl/managers/ShaderManager.js index 32dabf0..d3ee07a 100644 --- a/src/core/renderers/webgl/managers/ShaderManager.js +++ b/src/core/renderers/webgl/managers/ShaderManager.js @@ -7,6 +7,7 @@ /** * @class * @memberof PIXI + * @extends WebGLManager * @param renderer {WebGLRenderer} The renderer this manager works for. */ function ShaderManager(renderer) @@ -59,6 +60,10 @@ module.exports = ShaderManager; +/** + * Called when there is a WebGL context change. + * + */ ShaderManager.prototype.onContextChange = function () { this.initPlugins(); diff --git a/src/core/renderers/canvas/CanvasRenderer.js b/src/core/renderers/canvas/CanvasRenderer.js index 24eafc9..389ae5e 100644 --- a/src/core/renderers/canvas/CanvasRenderer.js +++ b/src/core/renderers/canvas/CanvasRenderer.js @@ -10,6 +10,7 @@ * * @class * @memberof PIXI + * @extends SystemRenderer * @param [width=800] {number} the width of the canvas view * @param [height=600] {number} the height of the canvas view * @param [options] {object} The optional renderer parameters diff --git a/src/core/renderers/webgl/WebGLRenderer.js b/src/core/renderers/webgl/WebGLRenderer.js index 15ce4fe..6bfb6de 100644 --- a/src/core/renderers/webgl/WebGLRenderer.js +++ b/src/core/renderers/webgl/WebGLRenderer.js @@ -265,7 +265,7 @@ * Renders a Display Object. * * @param displayObject {DisplayObject} The DisplayObject to render - * @param renderTarget {Point} TODO @alvin + * @param renderTarget {RenderTarget} The render target to use to render this display object * */ WebGLRenderer.prototype.renderDisplayObject = function (displayObject, renderTarget)//projection, buffer) @@ -305,7 +305,7 @@ /** * Changes the current render target to the one given in parameter * - * @param renderTarget {Object} the new render target + * @param renderTarget {RenderTarget} the new render target * */ WebGLRenderer.prototype.setRenderTarget = function (renderTarget) diff --git a/src/core/renderers/webgl/filters/AbstractFilter.js b/src/core/renderers/webgl/filters/AbstractFilter.js index 91e874c..7a3cb01 100644 --- a/src/core/renderers/webgl/filters/AbstractFilter.js +++ b/src/core/renderers/webgl/filters/AbstractFilter.js @@ -84,6 +84,13 @@ return shader; }; +/* + * Applies the filter + * @param renderer {Shader} + * @param input {Any} + * @param output {Any} + * @param clear {boolean} Whether or not we want to clear the outputTarget + */ AbstractFilter.prototype.applyFilter = function (renderer, input, output, clear) { var shader = this.getShader(renderer); diff --git a/src/core/renderers/webgl/filters/FXAAFilter.js b/src/core/renderers/webgl/filters/FXAAFilter.js index f9398d1..bda7830 100644 --- a/src/core/renderers/webgl/filters/FXAAFilter.js +++ b/src/core/renderers/webgl/filters/FXAAFilter.js @@ -1,14 +1,19 @@ var AbstractFilter = require('./AbstractFilter'); /** - * The FXAAFilter class uses the pixel values from the specified texture (called the displacement map) to perform a displacement of an object. - * You can use this filter to apply all manor of crazy warping effects - * Currently the r property of the texture is used to offset the x and the g property of the texture is used to offset the y. + * + * Basic FXAA implementation based on the code on geeks3d.com with the + * modification that the texture2DLod stuff was removed since it's + * unsupported by WebGL. + * + * -- + * From: + * https://github.com/mitsuhiko/webgl-meincraft * * @class * @extends AbstractFilter * @memberof PIXI - * @param texture {Texture} The texture used for the displacement map * must be power of 2 texture at the moment + * */ function FXAAFilter() { @@ -25,52 +30,6 @@ } ); - /** -Basic FXAA implementation based on the code on geeks3d.com with the -modification that the texture2DLod stuff was removed since it's -unsupported by WebGL. - --- - -From: -https://github.com/mitsuhiko/webgl-meincraft - -Copyright (c) 2011 by Armin Ronacher. - -Some rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. - - * The names of the contributors may not be used to endorse or - promote products derived from this software without specific - prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - - - - } FXAAFilter.prototype = Object.create(AbstractFilter.prototype); diff --git a/src/core/renderers/webgl/filters/SpriteMaskFilter.js b/src/core/renderers/webgl/filters/SpriteMaskFilter.js index 4b09a8c..e1e5167 100644 --- a/src/core/renderers/webgl/filters/SpriteMaskFilter.js +++ b/src/core/renderers/webgl/filters/SpriteMaskFilter.js @@ -2,14 +2,12 @@ math = require('../../../math'); /** - * The SpriteMaskFilter class uses the pixel values from the specified texture (called the displacement map) to perform a displacement of an object. - * You can use this filter to apply all manor of crazy warping effects - * Currently the r property of the texture is used to offset the x and the g property of the texture is used to offset the y. + * The SpriteMaskFilter class * * @class * @extends AbstractFilter * @memberof PIXI - * @param texture {Texture} The texture used for the displacement map * must be power of 2 texture at the moment + * @param sprite {Sprite} the target sprite */ function SpriteMaskFilter(sprite) { @@ -72,6 +70,13 @@ SpriteMaskFilter.prototype.constructor = SpriteMaskFilter; module.exports = SpriteMaskFilter; +/** + * Applies the filter ? @alvin + * + * @param renderer {WebGLRenderer} A reference to the WebGL renderer + * @param input {} + * @param output {} + */ SpriteMaskFilter.prototype.applyFilter = function (renderer, input, output) { var filterManager = renderer.filterManager; diff --git a/src/core/renderers/webgl/managers/BlendModeManager.js b/src/core/renderers/webgl/managers/BlendModeManager.js index be51394..356f641 100644 --- a/src/core/renderers/webgl/managers/BlendModeManager.js +++ b/src/core/renderers/webgl/managers/BlendModeManager.js @@ -3,6 +3,7 @@ /** * @class * @memberof PIXI + * @extends WebGlManager * @param renderer {WebGLRenderer} The renderer this manager works for. */ function BlendModeManager(renderer) diff --git a/src/core/renderers/webgl/managers/FilterManager.js b/src/core/renderers/webgl/managers/FilterManager.js index b22513d..7576ef3 100644 --- a/src/core/renderers/webgl/managers/FilterManager.js +++ b/src/core/renderers/webgl/managers/FilterManager.js @@ -6,6 +6,7 @@ /** * @class * @memberof PIXI + * @extends WebGLManager * @param renderer {WebGLRenderer} The renderer this manager works for. */ function FilterManager(renderer) @@ -41,6 +42,10 @@ module.exports = FilterManager; +/** + * Called when there is a WebGL context change. + * + */ FilterManager.prototype.onContextChange = function () { this.texturePool.length = 0; @@ -117,7 +122,7 @@ /** - * Removes the last filter from the filter stack and doesn't return it. + * Removes the last filter from the filter stack and returns it. * */ FilterManager.prototype.popFilter = function () @@ -192,6 +197,12 @@ return filterData.filter; }; +/** + * Grabs an render target from the internal pool + * + * @param clear {boolean} Whether or not we need to clear the RenderTarget + * @return {RenderTarget} + */ FilterManager.prototype.getRenderTarget = function ( clear ) { var renderTarget = this.texturePool.pop() || new RenderTarget(this.renderer.gl, this.textureSize.width, this.textureSize.height, null, this.renderer.resolution); @@ -205,11 +216,22 @@ return renderTarget; }; +/* + * Returns a RenderTarget to the internal pool + * @param renderTarget {RenderTarget} The RenderTarget we want to return to the pool + */ FilterManager.prototype.returnRenderTarget = function (renderTarget) { this.texturePool.push( renderTarget ); }; +/* + * Applies the filter + * @param shader {Shader} + * @param inputTarget {Any} + * @param outputTarget {Any} + * @param clear {boolean} Whether or not we want to clear the outputTarget + */ FilterManager.prototype.applyFilter = function (shader, inputTarget, outputTarget, clear) { var gl = this.renderer.gl; @@ -240,7 +262,12 @@ gl.drawElements(gl.TRIANGLES, 6, gl.UNSIGNED_SHORT, 0 ); }; - +/* + * Constrains the filter area to the texture size + * @param filterArea {Rectangle} The filter area + * @param sprite {Sprite} the target sprite + * @param outputMatrix {Matrix} @alvin + */ // TODO playing around here.. this is temporary - (will end up in the shader) FilterManager.prototype.calculateMappedMatrix = function (filterArea, sprite, outputMatrix) { @@ -308,6 +335,10 @@ // return transform; }; +/* + * Constrains the filter area to the texture size + * @param filterArea {Rectangle} The filter area we want to cap + */ FilterManager.prototype.capFilterArea = function (filterArea) { if (filterArea.x < 0) @@ -333,6 +364,11 @@ } }; +/* + * Resizes all the render targets in the pool + * @param width {number} the new width + * @param height {number} the new height + */ FilterManager.prototype.resize = function ( width, height ) { this.textureSize.width = width; diff --git a/src/core/renderers/webgl/managers/MaskManager.js b/src/core/renderers/webgl/managers/MaskManager.js index 472eea1..fbc8e9c 100644 --- a/src/core/renderers/webgl/managers/MaskManager.js +++ b/src/core/renderers/webgl/managers/MaskManager.js @@ -40,6 +40,12 @@ }; +/** + * Removes the last mask from the mask stack and doesn't return it. + * + * @param target {RenderTarget} + * @param maskData {any[]} + */ MaskManager.prototype.popMask = function (target, maskData) { if (maskData.texture) @@ -52,6 +58,12 @@ } }; +/** + * Applies the Mask and adds it to the current filter stack. + * + * @param target {RenderTarget} + * @param maskData {any[]} + */ MaskManager.prototype.pushSpriteMask = function (target, maskData) { var alphaMaskFilter = this.alphaMaskPool.pop(); @@ -79,9 +91,9 @@ /** * Applies the Mask and adds it to the current filter stack. * + * @param target {RenderTarget} * @param maskData {any[]} */ - MaskManager.prototype.pushStencilMask = function (target, maskData) { this.renderer.stencilManager.pushMask(maskData); @@ -89,7 +101,7 @@ /** * Removes the last filter from the filter stack and doesn't return it. - * + * @param target {RenderTarget} * @param maskData {any[]} */ MaskManager.prototype.popStencilMask = function (target, maskData) diff --git a/src/core/renderers/webgl/managers/ShaderManager.js b/src/core/renderers/webgl/managers/ShaderManager.js index 32dabf0..d3ee07a 100644 --- a/src/core/renderers/webgl/managers/ShaderManager.js +++ b/src/core/renderers/webgl/managers/ShaderManager.js @@ -7,6 +7,7 @@ /** * @class * @memberof PIXI + * @extends WebGLManager * @param renderer {WebGLRenderer} The renderer this manager works for. */ function ShaderManager(renderer) @@ -59,6 +60,10 @@ module.exports = ShaderManager; +/** + * Called when there is a WebGL context change. + * + */ ShaderManager.prototype.onContextChange = function () { this.initPlugins(); diff --git a/src/core/renderers/webgl/managers/WebGLManager.js b/src/core/renderers/webgl/managers/WebGLManager.js index 41ddec2..dfb5573 100644 --- a/src/core/renderers/webgl/managers/WebGLManager.js +++ b/src/core/renderers/webgl/managers/WebGLManager.js @@ -23,11 +23,19 @@ WebGLManager.prototype.constructor = WebGLManager; module.exports = WebGLManager; +/** + * Generic method called when there is a WebGL context change. + * + */ WebGLManager.prototype.onContextChange = function () { // do some codes init! }; +/** + * Generic destroy methods to be overridden by the subclass + * + */ WebGLManager.prototype.destroy = function () { this.renderer.off('context', this._onContextChangeFn); diff --git a/src/core/renderers/canvas/CanvasRenderer.js b/src/core/renderers/canvas/CanvasRenderer.js index 24eafc9..389ae5e 100644 --- a/src/core/renderers/canvas/CanvasRenderer.js +++ b/src/core/renderers/canvas/CanvasRenderer.js @@ -10,6 +10,7 @@ * * @class * @memberof PIXI + * @extends SystemRenderer * @param [width=800] {number} the width of the canvas view * @param [height=600] {number} the height of the canvas view * @param [options] {object} The optional renderer parameters diff --git a/src/core/renderers/webgl/WebGLRenderer.js b/src/core/renderers/webgl/WebGLRenderer.js index 15ce4fe..6bfb6de 100644 --- a/src/core/renderers/webgl/WebGLRenderer.js +++ b/src/core/renderers/webgl/WebGLRenderer.js @@ -265,7 +265,7 @@ * Renders a Display Object. * * @param displayObject {DisplayObject} The DisplayObject to render - * @param renderTarget {Point} TODO @alvin + * @param renderTarget {RenderTarget} The render target to use to render this display object * */ WebGLRenderer.prototype.renderDisplayObject = function (displayObject, renderTarget)//projection, buffer) @@ -305,7 +305,7 @@ /** * Changes the current render target to the one given in parameter * - * @param renderTarget {Object} the new render target + * @param renderTarget {RenderTarget} the new render target * */ WebGLRenderer.prototype.setRenderTarget = function (renderTarget) diff --git a/src/core/renderers/webgl/filters/AbstractFilter.js b/src/core/renderers/webgl/filters/AbstractFilter.js index 91e874c..7a3cb01 100644 --- a/src/core/renderers/webgl/filters/AbstractFilter.js +++ b/src/core/renderers/webgl/filters/AbstractFilter.js @@ -84,6 +84,13 @@ return shader; }; +/* + * Applies the filter + * @param renderer {Shader} + * @param input {Any} + * @param output {Any} + * @param clear {boolean} Whether or not we want to clear the outputTarget + */ AbstractFilter.prototype.applyFilter = function (renderer, input, output, clear) { var shader = this.getShader(renderer); diff --git a/src/core/renderers/webgl/filters/FXAAFilter.js b/src/core/renderers/webgl/filters/FXAAFilter.js index f9398d1..bda7830 100644 --- a/src/core/renderers/webgl/filters/FXAAFilter.js +++ b/src/core/renderers/webgl/filters/FXAAFilter.js @@ -1,14 +1,19 @@ var AbstractFilter = require('./AbstractFilter'); /** - * The FXAAFilter class uses the pixel values from the specified texture (called the displacement map) to perform a displacement of an object. - * You can use this filter to apply all manor of crazy warping effects - * Currently the r property of the texture is used to offset the x and the g property of the texture is used to offset the y. + * + * Basic FXAA implementation based on the code on geeks3d.com with the + * modification that the texture2DLod stuff was removed since it's + * unsupported by WebGL. + * + * -- + * From: + * https://github.com/mitsuhiko/webgl-meincraft * * @class * @extends AbstractFilter * @memberof PIXI - * @param texture {Texture} The texture used for the displacement map * must be power of 2 texture at the moment + * */ function FXAAFilter() { @@ -25,52 +30,6 @@ } ); - /** -Basic FXAA implementation based on the code on geeks3d.com with the -modification that the texture2DLod stuff was removed since it's -unsupported by WebGL. - --- - -From: -https://github.com/mitsuhiko/webgl-meincraft - -Copyright (c) 2011 by Armin Ronacher. - -Some rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. - - * The names of the contributors may not be used to endorse or - promote products derived from this software without specific - prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - - - - } FXAAFilter.prototype = Object.create(AbstractFilter.prototype); diff --git a/src/core/renderers/webgl/filters/SpriteMaskFilter.js b/src/core/renderers/webgl/filters/SpriteMaskFilter.js index 4b09a8c..e1e5167 100644 --- a/src/core/renderers/webgl/filters/SpriteMaskFilter.js +++ b/src/core/renderers/webgl/filters/SpriteMaskFilter.js @@ -2,14 +2,12 @@ math = require('../../../math'); /** - * The SpriteMaskFilter class uses the pixel values from the specified texture (called the displacement map) to perform a displacement of an object. - * You can use this filter to apply all manor of crazy warping effects - * Currently the r property of the texture is used to offset the x and the g property of the texture is used to offset the y. + * The SpriteMaskFilter class * * @class * @extends AbstractFilter * @memberof PIXI - * @param texture {Texture} The texture used for the displacement map * must be power of 2 texture at the moment + * @param sprite {Sprite} the target sprite */ function SpriteMaskFilter(sprite) { @@ -72,6 +70,13 @@ SpriteMaskFilter.prototype.constructor = SpriteMaskFilter; module.exports = SpriteMaskFilter; +/** + * Applies the filter ? @alvin + * + * @param renderer {WebGLRenderer} A reference to the WebGL renderer + * @param input {} + * @param output {} + */ SpriteMaskFilter.prototype.applyFilter = function (renderer, input, output) { var filterManager = renderer.filterManager; diff --git a/src/core/renderers/webgl/managers/BlendModeManager.js b/src/core/renderers/webgl/managers/BlendModeManager.js index be51394..356f641 100644 --- a/src/core/renderers/webgl/managers/BlendModeManager.js +++ b/src/core/renderers/webgl/managers/BlendModeManager.js @@ -3,6 +3,7 @@ /** * @class * @memberof PIXI + * @extends WebGlManager * @param renderer {WebGLRenderer} The renderer this manager works for. */ function BlendModeManager(renderer) diff --git a/src/core/renderers/webgl/managers/FilterManager.js b/src/core/renderers/webgl/managers/FilterManager.js index b22513d..7576ef3 100644 --- a/src/core/renderers/webgl/managers/FilterManager.js +++ b/src/core/renderers/webgl/managers/FilterManager.js @@ -6,6 +6,7 @@ /** * @class * @memberof PIXI + * @extends WebGLManager * @param renderer {WebGLRenderer} The renderer this manager works for. */ function FilterManager(renderer) @@ -41,6 +42,10 @@ module.exports = FilterManager; +/** + * Called when there is a WebGL context change. + * + */ FilterManager.prototype.onContextChange = function () { this.texturePool.length = 0; @@ -117,7 +122,7 @@ /** - * Removes the last filter from the filter stack and doesn't return it. + * Removes the last filter from the filter stack and returns it. * */ FilterManager.prototype.popFilter = function () @@ -192,6 +197,12 @@ return filterData.filter; }; +/** + * Grabs an render target from the internal pool + * + * @param clear {boolean} Whether or not we need to clear the RenderTarget + * @return {RenderTarget} + */ FilterManager.prototype.getRenderTarget = function ( clear ) { var renderTarget = this.texturePool.pop() || new RenderTarget(this.renderer.gl, this.textureSize.width, this.textureSize.height, null, this.renderer.resolution); @@ -205,11 +216,22 @@ return renderTarget; }; +/* + * Returns a RenderTarget to the internal pool + * @param renderTarget {RenderTarget} The RenderTarget we want to return to the pool + */ FilterManager.prototype.returnRenderTarget = function (renderTarget) { this.texturePool.push( renderTarget ); }; +/* + * Applies the filter + * @param shader {Shader} + * @param inputTarget {Any} + * @param outputTarget {Any} + * @param clear {boolean} Whether or not we want to clear the outputTarget + */ FilterManager.prototype.applyFilter = function (shader, inputTarget, outputTarget, clear) { var gl = this.renderer.gl; @@ -240,7 +262,12 @@ gl.drawElements(gl.TRIANGLES, 6, gl.UNSIGNED_SHORT, 0 ); }; - +/* + * Constrains the filter area to the texture size + * @param filterArea {Rectangle} The filter area + * @param sprite {Sprite} the target sprite + * @param outputMatrix {Matrix} @alvin + */ // TODO playing around here.. this is temporary - (will end up in the shader) FilterManager.prototype.calculateMappedMatrix = function (filterArea, sprite, outputMatrix) { @@ -308,6 +335,10 @@ // return transform; }; +/* + * Constrains the filter area to the texture size + * @param filterArea {Rectangle} The filter area we want to cap + */ FilterManager.prototype.capFilterArea = function (filterArea) { if (filterArea.x < 0) @@ -333,6 +364,11 @@ } }; +/* + * Resizes all the render targets in the pool + * @param width {number} the new width + * @param height {number} the new height + */ FilterManager.prototype.resize = function ( width, height ) { this.textureSize.width = width; diff --git a/src/core/renderers/webgl/managers/MaskManager.js b/src/core/renderers/webgl/managers/MaskManager.js index 472eea1..fbc8e9c 100644 --- a/src/core/renderers/webgl/managers/MaskManager.js +++ b/src/core/renderers/webgl/managers/MaskManager.js @@ -40,6 +40,12 @@ }; +/** + * Removes the last mask from the mask stack and doesn't return it. + * + * @param target {RenderTarget} + * @param maskData {any[]} + */ MaskManager.prototype.popMask = function (target, maskData) { if (maskData.texture) @@ -52,6 +58,12 @@ } }; +/** + * Applies the Mask and adds it to the current filter stack. + * + * @param target {RenderTarget} + * @param maskData {any[]} + */ MaskManager.prototype.pushSpriteMask = function (target, maskData) { var alphaMaskFilter = this.alphaMaskPool.pop(); @@ -79,9 +91,9 @@ /** * Applies the Mask and adds it to the current filter stack. * + * @param target {RenderTarget} * @param maskData {any[]} */ - MaskManager.prototype.pushStencilMask = function (target, maskData) { this.renderer.stencilManager.pushMask(maskData); @@ -89,7 +101,7 @@ /** * Removes the last filter from the filter stack and doesn't return it. - * + * @param target {RenderTarget} * @param maskData {any[]} */ MaskManager.prototype.popStencilMask = function (target, maskData) diff --git a/src/core/renderers/webgl/managers/ShaderManager.js b/src/core/renderers/webgl/managers/ShaderManager.js index 32dabf0..d3ee07a 100644 --- a/src/core/renderers/webgl/managers/ShaderManager.js +++ b/src/core/renderers/webgl/managers/ShaderManager.js @@ -7,6 +7,7 @@ /** * @class * @memberof PIXI + * @extends WebGLManager * @param renderer {WebGLRenderer} The renderer this manager works for. */ function ShaderManager(renderer) @@ -59,6 +60,10 @@ module.exports = ShaderManager; +/** + * Called when there is a WebGL context change. + * + */ ShaderManager.prototype.onContextChange = function () { this.initPlugins(); diff --git a/src/core/renderers/webgl/managers/WebGLManager.js b/src/core/renderers/webgl/managers/WebGLManager.js index 41ddec2..dfb5573 100644 --- a/src/core/renderers/webgl/managers/WebGLManager.js +++ b/src/core/renderers/webgl/managers/WebGLManager.js @@ -23,11 +23,19 @@ WebGLManager.prototype.constructor = WebGLManager; module.exports = WebGLManager; +/** + * Generic method called when there is a WebGL context change. + * + */ WebGLManager.prototype.onContextChange = function () { // do some codes init! }; +/** + * Generic destroy methods to be overridden by the subclass + * + */ WebGLManager.prototype.destroy = function () { this.renderer.off('context', this._onContextChangeFn); diff --git a/src/core/renderers/webgl/shaders/ComplexPrimitiveShader.js b/src/core/renderers/webgl/shaders/ComplexPrimitiveShader.js index e3b06ac..15fae67 100644 --- a/src/core/renderers/webgl/shaders/ComplexPrimitiveShader.js +++ b/src/core/renderers/webgl/shaders/ComplexPrimitiveShader.js @@ -3,6 +3,7 @@ /** * @class * @memberof PIXI + * @extends Shader * @param shaderManager {ShaderManager} The webgl shader manager this shader works for. */ function ComplexPrimitiveShader(shaderManager) diff --git a/src/core/renderers/canvas/CanvasRenderer.js b/src/core/renderers/canvas/CanvasRenderer.js index 24eafc9..389ae5e 100644 --- a/src/core/renderers/canvas/CanvasRenderer.js +++ b/src/core/renderers/canvas/CanvasRenderer.js @@ -10,6 +10,7 @@ * * @class * @memberof PIXI + * @extends SystemRenderer * @param [width=800] {number} the width of the canvas view * @param [height=600] {number} the height of the canvas view * @param [options] {object} The optional renderer parameters diff --git a/src/core/renderers/webgl/WebGLRenderer.js b/src/core/renderers/webgl/WebGLRenderer.js index 15ce4fe..6bfb6de 100644 --- a/src/core/renderers/webgl/WebGLRenderer.js +++ b/src/core/renderers/webgl/WebGLRenderer.js @@ -265,7 +265,7 @@ * Renders a Display Object. * * @param displayObject {DisplayObject} The DisplayObject to render - * @param renderTarget {Point} TODO @alvin + * @param renderTarget {RenderTarget} The render target to use to render this display object * */ WebGLRenderer.prototype.renderDisplayObject = function (displayObject, renderTarget)//projection, buffer) @@ -305,7 +305,7 @@ /** * Changes the current render target to the one given in parameter * - * @param renderTarget {Object} the new render target + * @param renderTarget {RenderTarget} the new render target * */ WebGLRenderer.prototype.setRenderTarget = function (renderTarget) diff --git a/src/core/renderers/webgl/filters/AbstractFilter.js b/src/core/renderers/webgl/filters/AbstractFilter.js index 91e874c..7a3cb01 100644 --- a/src/core/renderers/webgl/filters/AbstractFilter.js +++ b/src/core/renderers/webgl/filters/AbstractFilter.js @@ -84,6 +84,13 @@ return shader; }; +/* + * Applies the filter + * @param renderer {Shader} + * @param input {Any} + * @param output {Any} + * @param clear {boolean} Whether or not we want to clear the outputTarget + */ AbstractFilter.prototype.applyFilter = function (renderer, input, output, clear) { var shader = this.getShader(renderer); diff --git a/src/core/renderers/webgl/filters/FXAAFilter.js b/src/core/renderers/webgl/filters/FXAAFilter.js index f9398d1..bda7830 100644 --- a/src/core/renderers/webgl/filters/FXAAFilter.js +++ b/src/core/renderers/webgl/filters/FXAAFilter.js @@ -1,14 +1,19 @@ var AbstractFilter = require('./AbstractFilter'); /** - * The FXAAFilter class uses the pixel values from the specified texture (called the displacement map) to perform a displacement of an object. - * You can use this filter to apply all manor of crazy warping effects - * Currently the r property of the texture is used to offset the x and the g property of the texture is used to offset the y. + * + * Basic FXAA implementation based on the code on geeks3d.com with the + * modification that the texture2DLod stuff was removed since it's + * unsupported by WebGL. + * + * -- + * From: + * https://github.com/mitsuhiko/webgl-meincraft * * @class * @extends AbstractFilter * @memberof PIXI - * @param texture {Texture} The texture used for the displacement map * must be power of 2 texture at the moment + * */ function FXAAFilter() { @@ -25,52 +30,6 @@ } ); - /** -Basic FXAA implementation based on the code on geeks3d.com with the -modification that the texture2DLod stuff was removed since it's -unsupported by WebGL. - --- - -From: -https://github.com/mitsuhiko/webgl-meincraft - -Copyright (c) 2011 by Armin Ronacher. - -Some rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. - - * The names of the contributors may not be used to endorse or - promote products derived from this software without specific - prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - - - - } FXAAFilter.prototype = Object.create(AbstractFilter.prototype); diff --git a/src/core/renderers/webgl/filters/SpriteMaskFilter.js b/src/core/renderers/webgl/filters/SpriteMaskFilter.js index 4b09a8c..e1e5167 100644 --- a/src/core/renderers/webgl/filters/SpriteMaskFilter.js +++ b/src/core/renderers/webgl/filters/SpriteMaskFilter.js @@ -2,14 +2,12 @@ math = require('../../../math'); /** - * The SpriteMaskFilter class uses the pixel values from the specified texture (called the displacement map) to perform a displacement of an object. - * You can use this filter to apply all manor of crazy warping effects - * Currently the r property of the texture is used to offset the x and the g property of the texture is used to offset the y. + * The SpriteMaskFilter class * * @class * @extends AbstractFilter * @memberof PIXI - * @param texture {Texture} The texture used for the displacement map * must be power of 2 texture at the moment + * @param sprite {Sprite} the target sprite */ function SpriteMaskFilter(sprite) { @@ -72,6 +70,13 @@ SpriteMaskFilter.prototype.constructor = SpriteMaskFilter; module.exports = SpriteMaskFilter; +/** + * Applies the filter ? @alvin + * + * @param renderer {WebGLRenderer} A reference to the WebGL renderer + * @param input {} + * @param output {} + */ SpriteMaskFilter.prototype.applyFilter = function (renderer, input, output) { var filterManager = renderer.filterManager; diff --git a/src/core/renderers/webgl/managers/BlendModeManager.js b/src/core/renderers/webgl/managers/BlendModeManager.js index be51394..356f641 100644 --- a/src/core/renderers/webgl/managers/BlendModeManager.js +++ b/src/core/renderers/webgl/managers/BlendModeManager.js @@ -3,6 +3,7 @@ /** * @class * @memberof PIXI + * @extends WebGlManager * @param renderer {WebGLRenderer} The renderer this manager works for. */ function BlendModeManager(renderer) diff --git a/src/core/renderers/webgl/managers/FilterManager.js b/src/core/renderers/webgl/managers/FilterManager.js index b22513d..7576ef3 100644 --- a/src/core/renderers/webgl/managers/FilterManager.js +++ b/src/core/renderers/webgl/managers/FilterManager.js @@ -6,6 +6,7 @@ /** * @class * @memberof PIXI + * @extends WebGLManager * @param renderer {WebGLRenderer} The renderer this manager works for. */ function FilterManager(renderer) @@ -41,6 +42,10 @@ module.exports = FilterManager; +/** + * Called when there is a WebGL context change. + * + */ FilterManager.prototype.onContextChange = function () { this.texturePool.length = 0; @@ -117,7 +122,7 @@ /** - * Removes the last filter from the filter stack and doesn't return it. + * Removes the last filter from the filter stack and returns it. * */ FilterManager.prototype.popFilter = function () @@ -192,6 +197,12 @@ return filterData.filter; }; +/** + * Grabs an render target from the internal pool + * + * @param clear {boolean} Whether or not we need to clear the RenderTarget + * @return {RenderTarget} + */ FilterManager.prototype.getRenderTarget = function ( clear ) { var renderTarget = this.texturePool.pop() || new RenderTarget(this.renderer.gl, this.textureSize.width, this.textureSize.height, null, this.renderer.resolution); @@ -205,11 +216,22 @@ return renderTarget; }; +/* + * Returns a RenderTarget to the internal pool + * @param renderTarget {RenderTarget} The RenderTarget we want to return to the pool + */ FilterManager.prototype.returnRenderTarget = function (renderTarget) { this.texturePool.push( renderTarget ); }; +/* + * Applies the filter + * @param shader {Shader} + * @param inputTarget {Any} + * @param outputTarget {Any} + * @param clear {boolean} Whether or not we want to clear the outputTarget + */ FilterManager.prototype.applyFilter = function (shader, inputTarget, outputTarget, clear) { var gl = this.renderer.gl; @@ -240,7 +262,12 @@ gl.drawElements(gl.TRIANGLES, 6, gl.UNSIGNED_SHORT, 0 ); }; - +/* + * Constrains the filter area to the texture size + * @param filterArea {Rectangle} The filter area + * @param sprite {Sprite} the target sprite + * @param outputMatrix {Matrix} @alvin + */ // TODO playing around here.. this is temporary - (will end up in the shader) FilterManager.prototype.calculateMappedMatrix = function (filterArea, sprite, outputMatrix) { @@ -308,6 +335,10 @@ // return transform; }; +/* + * Constrains the filter area to the texture size + * @param filterArea {Rectangle} The filter area we want to cap + */ FilterManager.prototype.capFilterArea = function (filterArea) { if (filterArea.x < 0) @@ -333,6 +364,11 @@ } }; +/* + * Resizes all the render targets in the pool + * @param width {number} the new width + * @param height {number} the new height + */ FilterManager.prototype.resize = function ( width, height ) { this.textureSize.width = width; diff --git a/src/core/renderers/webgl/managers/MaskManager.js b/src/core/renderers/webgl/managers/MaskManager.js index 472eea1..fbc8e9c 100644 --- a/src/core/renderers/webgl/managers/MaskManager.js +++ b/src/core/renderers/webgl/managers/MaskManager.js @@ -40,6 +40,12 @@ }; +/** + * Removes the last mask from the mask stack and doesn't return it. + * + * @param target {RenderTarget} + * @param maskData {any[]} + */ MaskManager.prototype.popMask = function (target, maskData) { if (maskData.texture) @@ -52,6 +58,12 @@ } }; +/** + * Applies the Mask and adds it to the current filter stack. + * + * @param target {RenderTarget} + * @param maskData {any[]} + */ MaskManager.prototype.pushSpriteMask = function (target, maskData) { var alphaMaskFilter = this.alphaMaskPool.pop(); @@ -79,9 +91,9 @@ /** * Applies the Mask and adds it to the current filter stack. * + * @param target {RenderTarget} * @param maskData {any[]} */ - MaskManager.prototype.pushStencilMask = function (target, maskData) { this.renderer.stencilManager.pushMask(maskData); @@ -89,7 +101,7 @@ /** * Removes the last filter from the filter stack and doesn't return it. - * + * @param target {RenderTarget} * @param maskData {any[]} */ MaskManager.prototype.popStencilMask = function (target, maskData) diff --git a/src/core/renderers/webgl/managers/ShaderManager.js b/src/core/renderers/webgl/managers/ShaderManager.js index 32dabf0..d3ee07a 100644 --- a/src/core/renderers/webgl/managers/ShaderManager.js +++ b/src/core/renderers/webgl/managers/ShaderManager.js @@ -7,6 +7,7 @@ /** * @class * @memberof PIXI + * @extends WebGLManager * @param renderer {WebGLRenderer} The renderer this manager works for. */ function ShaderManager(renderer) @@ -59,6 +60,10 @@ module.exports = ShaderManager; +/** + * Called when there is a WebGL context change. + * + */ ShaderManager.prototype.onContextChange = function () { this.initPlugins(); diff --git a/src/core/renderers/webgl/managers/WebGLManager.js b/src/core/renderers/webgl/managers/WebGLManager.js index 41ddec2..dfb5573 100644 --- a/src/core/renderers/webgl/managers/WebGLManager.js +++ b/src/core/renderers/webgl/managers/WebGLManager.js @@ -23,11 +23,19 @@ WebGLManager.prototype.constructor = WebGLManager; module.exports = WebGLManager; +/** + * Generic method called when there is a WebGL context change. + * + */ WebGLManager.prototype.onContextChange = function () { // do some codes init! }; +/** + * Generic destroy methods to be overridden by the subclass + * + */ WebGLManager.prototype.destroy = function () { this.renderer.off('context', this._onContextChangeFn); diff --git a/src/core/renderers/webgl/shaders/ComplexPrimitiveShader.js b/src/core/renderers/webgl/shaders/ComplexPrimitiveShader.js index e3b06ac..15fae67 100644 --- a/src/core/renderers/webgl/shaders/ComplexPrimitiveShader.js +++ b/src/core/renderers/webgl/shaders/ComplexPrimitiveShader.js @@ -3,6 +3,7 @@ /** * @class * @memberof PIXI + * @extends Shader * @param shaderManager {ShaderManager} The webgl shader manager this shader works for. */ function ComplexPrimitiveShader(shaderManager) diff --git a/src/core/renderers/webgl/shaders/PrimitiveShader.js b/src/core/renderers/webgl/shaders/PrimitiveShader.js index b7eed82..d89a547 100644 --- a/src/core/renderers/webgl/shaders/PrimitiveShader.js +++ b/src/core/renderers/webgl/shaders/PrimitiveShader.js @@ -3,6 +3,7 @@ /** * @class * @memberof PIXI + * @extends Shader * @param shaderManager {ShaderManager} The webgl shader manager this shader works for. */ function PrimitiveShader(shaderManager) diff --git a/src/core/renderers/canvas/CanvasRenderer.js b/src/core/renderers/canvas/CanvasRenderer.js index 24eafc9..389ae5e 100644 --- a/src/core/renderers/canvas/CanvasRenderer.js +++ b/src/core/renderers/canvas/CanvasRenderer.js @@ -10,6 +10,7 @@ * * @class * @memberof PIXI + * @extends SystemRenderer * @param [width=800] {number} the width of the canvas view * @param [height=600] {number} the height of the canvas view * @param [options] {object} The optional renderer parameters diff --git a/src/core/renderers/webgl/WebGLRenderer.js b/src/core/renderers/webgl/WebGLRenderer.js index 15ce4fe..6bfb6de 100644 --- a/src/core/renderers/webgl/WebGLRenderer.js +++ b/src/core/renderers/webgl/WebGLRenderer.js @@ -265,7 +265,7 @@ * Renders a Display Object. * * @param displayObject {DisplayObject} The DisplayObject to render - * @param renderTarget {Point} TODO @alvin + * @param renderTarget {RenderTarget} The render target to use to render this display object * */ WebGLRenderer.prototype.renderDisplayObject = function (displayObject, renderTarget)//projection, buffer) @@ -305,7 +305,7 @@ /** * Changes the current render target to the one given in parameter * - * @param renderTarget {Object} the new render target + * @param renderTarget {RenderTarget} the new render target * */ WebGLRenderer.prototype.setRenderTarget = function (renderTarget) diff --git a/src/core/renderers/webgl/filters/AbstractFilter.js b/src/core/renderers/webgl/filters/AbstractFilter.js index 91e874c..7a3cb01 100644 --- a/src/core/renderers/webgl/filters/AbstractFilter.js +++ b/src/core/renderers/webgl/filters/AbstractFilter.js @@ -84,6 +84,13 @@ return shader; }; +/* + * Applies the filter + * @param renderer {Shader} + * @param input {Any} + * @param output {Any} + * @param clear {boolean} Whether or not we want to clear the outputTarget + */ AbstractFilter.prototype.applyFilter = function (renderer, input, output, clear) { var shader = this.getShader(renderer); diff --git a/src/core/renderers/webgl/filters/FXAAFilter.js b/src/core/renderers/webgl/filters/FXAAFilter.js index f9398d1..bda7830 100644 --- a/src/core/renderers/webgl/filters/FXAAFilter.js +++ b/src/core/renderers/webgl/filters/FXAAFilter.js @@ -1,14 +1,19 @@ var AbstractFilter = require('./AbstractFilter'); /** - * The FXAAFilter class uses the pixel values from the specified texture (called the displacement map) to perform a displacement of an object. - * You can use this filter to apply all manor of crazy warping effects - * Currently the r property of the texture is used to offset the x and the g property of the texture is used to offset the y. + * + * Basic FXAA implementation based on the code on geeks3d.com with the + * modification that the texture2DLod stuff was removed since it's + * unsupported by WebGL. + * + * -- + * From: + * https://github.com/mitsuhiko/webgl-meincraft * * @class * @extends AbstractFilter * @memberof PIXI - * @param texture {Texture} The texture used for the displacement map * must be power of 2 texture at the moment + * */ function FXAAFilter() { @@ -25,52 +30,6 @@ } ); - /** -Basic FXAA implementation based on the code on geeks3d.com with the -modification that the texture2DLod stuff was removed since it's -unsupported by WebGL. - --- - -From: -https://github.com/mitsuhiko/webgl-meincraft - -Copyright (c) 2011 by Armin Ronacher. - -Some rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. - - * The names of the contributors may not be used to endorse or - promote products derived from this software without specific - prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - - - - } FXAAFilter.prototype = Object.create(AbstractFilter.prototype); diff --git a/src/core/renderers/webgl/filters/SpriteMaskFilter.js b/src/core/renderers/webgl/filters/SpriteMaskFilter.js index 4b09a8c..e1e5167 100644 --- a/src/core/renderers/webgl/filters/SpriteMaskFilter.js +++ b/src/core/renderers/webgl/filters/SpriteMaskFilter.js @@ -2,14 +2,12 @@ math = require('../../../math'); /** - * The SpriteMaskFilter class uses the pixel values from the specified texture (called the displacement map) to perform a displacement of an object. - * You can use this filter to apply all manor of crazy warping effects - * Currently the r property of the texture is used to offset the x and the g property of the texture is used to offset the y. + * The SpriteMaskFilter class * * @class * @extends AbstractFilter * @memberof PIXI - * @param texture {Texture} The texture used for the displacement map * must be power of 2 texture at the moment + * @param sprite {Sprite} the target sprite */ function SpriteMaskFilter(sprite) { @@ -72,6 +70,13 @@ SpriteMaskFilter.prototype.constructor = SpriteMaskFilter; module.exports = SpriteMaskFilter; +/** + * Applies the filter ? @alvin + * + * @param renderer {WebGLRenderer} A reference to the WebGL renderer + * @param input {} + * @param output {} + */ SpriteMaskFilter.prototype.applyFilter = function (renderer, input, output) { var filterManager = renderer.filterManager; diff --git a/src/core/renderers/webgl/managers/BlendModeManager.js b/src/core/renderers/webgl/managers/BlendModeManager.js index be51394..356f641 100644 --- a/src/core/renderers/webgl/managers/BlendModeManager.js +++ b/src/core/renderers/webgl/managers/BlendModeManager.js @@ -3,6 +3,7 @@ /** * @class * @memberof PIXI + * @extends WebGlManager * @param renderer {WebGLRenderer} The renderer this manager works for. */ function BlendModeManager(renderer) diff --git a/src/core/renderers/webgl/managers/FilterManager.js b/src/core/renderers/webgl/managers/FilterManager.js index b22513d..7576ef3 100644 --- a/src/core/renderers/webgl/managers/FilterManager.js +++ b/src/core/renderers/webgl/managers/FilterManager.js @@ -6,6 +6,7 @@ /** * @class * @memberof PIXI + * @extends WebGLManager * @param renderer {WebGLRenderer} The renderer this manager works for. */ function FilterManager(renderer) @@ -41,6 +42,10 @@ module.exports = FilterManager; +/** + * Called when there is a WebGL context change. + * + */ FilterManager.prototype.onContextChange = function () { this.texturePool.length = 0; @@ -117,7 +122,7 @@ /** - * Removes the last filter from the filter stack and doesn't return it. + * Removes the last filter from the filter stack and returns it. * */ FilterManager.prototype.popFilter = function () @@ -192,6 +197,12 @@ return filterData.filter; }; +/** + * Grabs an render target from the internal pool + * + * @param clear {boolean} Whether or not we need to clear the RenderTarget + * @return {RenderTarget} + */ FilterManager.prototype.getRenderTarget = function ( clear ) { var renderTarget = this.texturePool.pop() || new RenderTarget(this.renderer.gl, this.textureSize.width, this.textureSize.height, null, this.renderer.resolution); @@ -205,11 +216,22 @@ return renderTarget; }; +/* + * Returns a RenderTarget to the internal pool + * @param renderTarget {RenderTarget} The RenderTarget we want to return to the pool + */ FilterManager.prototype.returnRenderTarget = function (renderTarget) { this.texturePool.push( renderTarget ); }; +/* + * Applies the filter + * @param shader {Shader} + * @param inputTarget {Any} + * @param outputTarget {Any} + * @param clear {boolean} Whether or not we want to clear the outputTarget + */ FilterManager.prototype.applyFilter = function (shader, inputTarget, outputTarget, clear) { var gl = this.renderer.gl; @@ -240,7 +262,12 @@ gl.drawElements(gl.TRIANGLES, 6, gl.UNSIGNED_SHORT, 0 ); }; - +/* + * Constrains the filter area to the texture size + * @param filterArea {Rectangle} The filter area + * @param sprite {Sprite} the target sprite + * @param outputMatrix {Matrix} @alvin + */ // TODO playing around here.. this is temporary - (will end up in the shader) FilterManager.prototype.calculateMappedMatrix = function (filterArea, sprite, outputMatrix) { @@ -308,6 +335,10 @@ // return transform; }; +/* + * Constrains the filter area to the texture size + * @param filterArea {Rectangle} The filter area we want to cap + */ FilterManager.prototype.capFilterArea = function (filterArea) { if (filterArea.x < 0) @@ -333,6 +364,11 @@ } }; +/* + * Resizes all the render targets in the pool + * @param width {number} the new width + * @param height {number} the new height + */ FilterManager.prototype.resize = function ( width, height ) { this.textureSize.width = width; diff --git a/src/core/renderers/webgl/managers/MaskManager.js b/src/core/renderers/webgl/managers/MaskManager.js index 472eea1..fbc8e9c 100644 --- a/src/core/renderers/webgl/managers/MaskManager.js +++ b/src/core/renderers/webgl/managers/MaskManager.js @@ -40,6 +40,12 @@ }; +/** + * Removes the last mask from the mask stack and doesn't return it. + * + * @param target {RenderTarget} + * @param maskData {any[]} + */ MaskManager.prototype.popMask = function (target, maskData) { if (maskData.texture) @@ -52,6 +58,12 @@ } }; +/** + * Applies the Mask and adds it to the current filter stack. + * + * @param target {RenderTarget} + * @param maskData {any[]} + */ MaskManager.prototype.pushSpriteMask = function (target, maskData) { var alphaMaskFilter = this.alphaMaskPool.pop(); @@ -79,9 +91,9 @@ /** * Applies the Mask and adds it to the current filter stack. * + * @param target {RenderTarget} * @param maskData {any[]} */ - MaskManager.prototype.pushStencilMask = function (target, maskData) { this.renderer.stencilManager.pushMask(maskData); @@ -89,7 +101,7 @@ /** * Removes the last filter from the filter stack and doesn't return it. - * + * @param target {RenderTarget} * @param maskData {any[]} */ MaskManager.prototype.popStencilMask = function (target, maskData) diff --git a/src/core/renderers/webgl/managers/ShaderManager.js b/src/core/renderers/webgl/managers/ShaderManager.js index 32dabf0..d3ee07a 100644 --- a/src/core/renderers/webgl/managers/ShaderManager.js +++ b/src/core/renderers/webgl/managers/ShaderManager.js @@ -7,6 +7,7 @@ /** * @class * @memberof PIXI + * @extends WebGLManager * @param renderer {WebGLRenderer} The renderer this manager works for. */ function ShaderManager(renderer) @@ -59,6 +60,10 @@ module.exports = ShaderManager; +/** + * Called when there is a WebGL context change. + * + */ ShaderManager.prototype.onContextChange = function () { this.initPlugins(); diff --git a/src/core/renderers/webgl/managers/WebGLManager.js b/src/core/renderers/webgl/managers/WebGLManager.js index 41ddec2..dfb5573 100644 --- a/src/core/renderers/webgl/managers/WebGLManager.js +++ b/src/core/renderers/webgl/managers/WebGLManager.js @@ -23,11 +23,19 @@ WebGLManager.prototype.constructor = WebGLManager; module.exports = WebGLManager; +/** + * Generic method called when there is a WebGL context change. + * + */ WebGLManager.prototype.onContextChange = function () { // do some codes init! }; +/** + * Generic destroy methods to be overridden by the subclass + * + */ WebGLManager.prototype.destroy = function () { this.renderer.off('context', this._onContextChangeFn); diff --git a/src/core/renderers/webgl/shaders/ComplexPrimitiveShader.js b/src/core/renderers/webgl/shaders/ComplexPrimitiveShader.js index e3b06ac..15fae67 100644 --- a/src/core/renderers/webgl/shaders/ComplexPrimitiveShader.js +++ b/src/core/renderers/webgl/shaders/ComplexPrimitiveShader.js @@ -3,6 +3,7 @@ /** * @class * @memberof PIXI + * @extends Shader * @param shaderManager {ShaderManager} The webgl shader manager this shader works for. */ function ComplexPrimitiveShader(shaderManager) diff --git a/src/core/renderers/webgl/shaders/PrimitiveShader.js b/src/core/renderers/webgl/shaders/PrimitiveShader.js index b7eed82..d89a547 100644 --- a/src/core/renderers/webgl/shaders/PrimitiveShader.js +++ b/src/core/renderers/webgl/shaders/PrimitiveShader.js @@ -3,6 +3,7 @@ /** * @class * @memberof PIXI + * @extends Shader * @param shaderManager {ShaderManager} The webgl shader manager this shader works for. */ function PrimitiveShader(shaderManager) diff --git a/src/core/renderers/webgl/shaders/Shader.js b/src/core/renderers/webgl/shaders/Shader.js index 9f25245..20079d7 100644 --- a/src/core/renderers/webgl/shaders/Shader.js +++ b/src/core/renderers/webgl/shaders/Shader.js @@ -37,10 +37,25 @@ */ this.program = null; + /** + * The uniforms as an object + * @member {object} + * @private + */ this.uniforms = uniforms || {}; + /** + * The attributes as an object + * @member {object} + * @private + */ this.attributes = attributes || {}; + /** + * Internal texture counter + * @member {number} + * @private + */ this.textureCount = 1; /** @@ -63,6 +78,10 @@ Shader.prototype.constructor = Shader; module.exports = Shader; +/* + * Creates the shader and uses it + * + */ Shader.prototype.init = function () { this.compile(); @@ -73,6 +92,10 @@ this.cacheAttributeLocations(Object.keys(this.attributes)); }; +/* + * Caches the locations of the uniform for reuse + * @param key {string} the uniform to cache + */ Shader.prototype.cacheUniformLocations = function (keys) { for (var i = 0; i < keys.length; ++i) @@ -81,6 +104,10 @@ } }; +/* + * Caches the locations of the attribute for reuse + * @param key {string} the attribute to cache + */ Shader.prototype.cacheAttributeLocations = function (keys) { for (var i = 0; i < keys.length; ++i) @@ -103,6 +130,9 @@ // End worst hack eva // }; +/* + * Attaches the shaders and creates the program + */ Shader.prototype.compile = function () { var gl = this.gl; @@ -119,14 +149,14 @@ // if linking fails, then log and cleanup if (!gl.getProgramParameter(program, gl.LINK_STATUS)) { - window.console.error('Pixi.js Error: Could not initialize shader.'); - window.console.error('gl.VALIDATE_STATUS', gl.getProgramParameter(program, gl.VALIDATE_STATUS)); - window.console.error('gl.getError()', gl.getError()); + console.error('Pixi.js Error: Could not initialize shader.'); + console.error('gl.VALIDATE_STATUS', gl.getProgramParameter(program, gl.VALIDATE_STATUS)); + console.error('gl.getError()', gl.getError()); // if there is a program info log, log it if (gl.getProgramInfoLog(program) !== '') { - window.console.warn('Pixi.js Warning: gl.getProgramInfoLog()', gl.getProgramInfoLog(program)); + console.warn('Pixi.js Warning: gl.getProgramInfoLog()', gl.getProgramInfoLog(program)); } gl.deleteProgram(program); @@ -176,6 +206,11 @@ }*/ +/** +* Adds a new uniform +* +* @param uniform {Object} the new uniform to attach +*/ Shader.prototype.syncUniform = function (uniform) { var location = uniform._location, @@ -407,6 +442,9 @@ } }; +/* + * Updates the shader uniform values. + */ Shader.prototype.syncUniforms = function () { this.textureCount = 1; diff --git a/src/core/renderers/canvas/CanvasRenderer.js b/src/core/renderers/canvas/CanvasRenderer.js index 24eafc9..389ae5e 100644 --- a/src/core/renderers/canvas/CanvasRenderer.js +++ b/src/core/renderers/canvas/CanvasRenderer.js @@ -10,6 +10,7 @@ * * @class * @memberof PIXI + * @extends SystemRenderer * @param [width=800] {number} the width of the canvas view * @param [height=600] {number} the height of the canvas view * @param [options] {object} The optional renderer parameters diff --git a/src/core/renderers/webgl/WebGLRenderer.js b/src/core/renderers/webgl/WebGLRenderer.js index 15ce4fe..6bfb6de 100644 --- a/src/core/renderers/webgl/WebGLRenderer.js +++ b/src/core/renderers/webgl/WebGLRenderer.js @@ -265,7 +265,7 @@ * Renders a Display Object. * * @param displayObject {DisplayObject} The DisplayObject to render - * @param renderTarget {Point} TODO @alvin + * @param renderTarget {RenderTarget} The render target to use to render this display object * */ WebGLRenderer.prototype.renderDisplayObject = function (displayObject, renderTarget)//projection, buffer) @@ -305,7 +305,7 @@ /** * Changes the current render target to the one given in parameter * - * @param renderTarget {Object} the new render target + * @param renderTarget {RenderTarget} the new render target * */ WebGLRenderer.prototype.setRenderTarget = function (renderTarget) diff --git a/src/core/renderers/webgl/filters/AbstractFilter.js b/src/core/renderers/webgl/filters/AbstractFilter.js index 91e874c..7a3cb01 100644 --- a/src/core/renderers/webgl/filters/AbstractFilter.js +++ b/src/core/renderers/webgl/filters/AbstractFilter.js @@ -84,6 +84,13 @@ return shader; }; +/* + * Applies the filter + * @param renderer {Shader} + * @param input {Any} + * @param output {Any} + * @param clear {boolean} Whether or not we want to clear the outputTarget + */ AbstractFilter.prototype.applyFilter = function (renderer, input, output, clear) { var shader = this.getShader(renderer); diff --git a/src/core/renderers/webgl/filters/FXAAFilter.js b/src/core/renderers/webgl/filters/FXAAFilter.js index f9398d1..bda7830 100644 --- a/src/core/renderers/webgl/filters/FXAAFilter.js +++ b/src/core/renderers/webgl/filters/FXAAFilter.js @@ -1,14 +1,19 @@ var AbstractFilter = require('./AbstractFilter'); /** - * The FXAAFilter class uses the pixel values from the specified texture (called the displacement map) to perform a displacement of an object. - * You can use this filter to apply all manor of crazy warping effects - * Currently the r property of the texture is used to offset the x and the g property of the texture is used to offset the y. + * + * Basic FXAA implementation based on the code on geeks3d.com with the + * modification that the texture2DLod stuff was removed since it's + * unsupported by WebGL. + * + * -- + * From: + * https://github.com/mitsuhiko/webgl-meincraft * * @class * @extends AbstractFilter * @memberof PIXI - * @param texture {Texture} The texture used for the displacement map * must be power of 2 texture at the moment + * */ function FXAAFilter() { @@ -25,52 +30,6 @@ } ); - /** -Basic FXAA implementation based on the code on geeks3d.com with the -modification that the texture2DLod stuff was removed since it's -unsupported by WebGL. - --- - -From: -https://github.com/mitsuhiko/webgl-meincraft - -Copyright (c) 2011 by Armin Ronacher. - -Some rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. - - * The names of the contributors may not be used to endorse or - promote products derived from this software without specific - prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - - - - } FXAAFilter.prototype = Object.create(AbstractFilter.prototype); diff --git a/src/core/renderers/webgl/filters/SpriteMaskFilter.js b/src/core/renderers/webgl/filters/SpriteMaskFilter.js index 4b09a8c..e1e5167 100644 --- a/src/core/renderers/webgl/filters/SpriteMaskFilter.js +++ b/src/core/renderers/webgl/filters/SpriteMaskFilter.js @@ -2,14 +2,12 @@ math = require('../../../math'); /** - * The SpriteMaskFilter class uses the pixel values from the specified texture (called the displacement map) to perform a displacement of an object. - * You can use this filter to apply all manor of crazy warping effects - * Currently the r property of the texture is used to offset the x and the g property of the texture is used to offset the y. + * The SpriteMaskFilter class * * @class * @extends AbstractFilter * @memberof PIXI - * @param texture {Texture} The texture used for the displacement map * must be power of 2 texture at the moment + * @param sprite {Sprite} the target sprite */ function SpriteMaskFilter(sprite) { @@ -72,6 +70,13 @@ SpriteMaskFilter.prototype.constructor = SpriteMaskFilter; module.exports = SpriteMaskFilter; +/** + * Applies the filter ? @alvin + * + * @param renderer {WebGLRenderer} A reference to the WebGL renderer + * @param input {} + * @param output {} + */ SpriteMaskFilter.prototype.applyFilter = function (renderer, input, output) { var filterManager = renderer.filterManager; diff --git a/src/core/renderers/webgl/managers/BlendModeManager.js b/src/core/renderers/webgl/managers/BlendModeManager.js index be51394..356f641 100644 --- a/src/core/renderers/webgl/managers/BlendModeManager.js +++ b/src/core/renderers/webgl/managers/BlendModeManager.js @@ -3,6 +3,7 @@ /** * @class * @memberof PIXI + * @extends WebGlManager * @param renderer {WebGLRenderer} The renderer this manager works for. */ function BlendModeManager(renderer) diff --git a/src/core/renderers/webgl/managers/FilterManager.js b/src/core/renderers/webgl/managers/FilterManager.js index b22513d..7576ef3 100644 --- a/src/core/renderers/webgl/managers/FilterManager.js +++ b/src/core/renderers/webgl/managers/FilterManager.js @@ -6,6 +6,7 @@ /** * @class * @memberof PIXI + * @extends WebGLManager * @param renderer {WebGLRenderer} The renderer this manager works for. */ function FilterManager(renderer) @@ -41,6 +42,10 @@ module.exports = FilterManager; +/** + * Called when there is a WebGL context change. + * + */ FilterManager.prototype.onContextChange = function () { this.texturePool.length = 0; @@ -117,7 +122,7 @@ /** - * Removes the last filter from the filter stack and doesn't return it. + * Removes the last filter from the filter stack and returns it. * */ FilterManager.prototype.popFilter = function () @@ -192,6 +197,12 @@ return filterData.filter; }; +/** + * Grabs an render target from the internal pool + * + * @param clear {boolean} Whether or not we need to clear the RenderTarget + * @return {RenderTarget} + */ FilterManager.prototype.getRenderTarget = function ( clear ) { var renderTarget = this.texturePool.pop() || new RenderTarget(this.renderer.gl, this.textureSize.width, this.textureSize.height, null, this.renderer.resolution); @@ -205,11 +216,22 @@ return renderTarget; }; +/* + * Returns a RenderTarget to the internal pool + * @param renderTarget {RenderTarget} The RenderTarget we want to return to the pool + */ FilterManager.prototype.returnRenderTarget = function (renderTarget) { this.texturePool.push( renderTarget ); }; +/* + * Applies the filter + * @param shader {Shader} + * @param inputTarget {Any} + * @param outputTarget {Any} + * @param clear {boolean} Whether or not we want to clear the outputTarget + */ FilterManager.prototype.applyFilter = function (shader, inputTarget, outputTarget, clear) { var gl = this.renderer.gl; @@ -240,7 +262,12 @@ gl.drawElements(gl.TRIANGLES, 6, gl.UNSIGNED_SHORT, 0 ); }; - +/* + * Constrains the filter area to the texture size + * @param filterArea {Rectangle} The filter area + * @param sprite {Sprite} the target sprite + * @param outputMatrix {Matrix} @alvin + */ // TODO playing around here.. this is temporary - (will end up in the shader) FilterManager.prototype.calculateMappedMatrix = function (filterArea, sprite, outputMatrix) { @@ -308,6 +335,10 @@ // return transform; }; +/* + * Constrains the filter area to the texture size + * @param filterArea {Rectangle} The filter area we want to cap + */ FilterManager.prototype.capFilterArea = function (filterArea) { if (filterArea.x < 0) @@ -333,6 +364,11 @@ } }; +/* + * Resizes all the render targets in the pool + * @param width {number} the new width + * @param height {number} the new height + */ FilterManager.prototype.resize = function ( width, height ) { this.textureSize.width = width; diff --git a/src/core/renderers/webgl/managers/MaskManager.js b/src/core/renderers/webgl/managers/MaskManager.js index 472eea1..fbc8e9c 100644 --- a/src/core/renderers/webgl/managers/MaskManager.js +++ b/src/core/renderers/webgl/managers/MaskManager.js @@ -40,6 +40,12 @@ }; +/** + * Removes the last mask from the mask stack and doesn't return it. + * + * @param target {RenderTarget} + * @param maskData {any[]} + */ MaskManager.prototype.popMask = function (target, maskData) { if (maskData.texture) @@ -52,6 +58,12 @@ } }; +/** + * Applies the Mask and adds it to the current filter stack. + * + * @param target {RenderTarget} + * @param maskData {any[]} + */ MaskManager.prototype.pushSpriteMask = function (target, maskData) { var alphaMaskFilter = this.alphaMaskPool.pop(); @@ -79,9 +91,9 @@ /** * Applies the Mask and adds it to the current filter stack. * + * @param target {RenderTarget} * @param maskData {any[]} */ - MaskManager.prototype.pushStencilMask = function (target, maskData) { this.renderer.stencilManager.pushMask(maskData); @@ -89,7 +101,7 @@ /** * Removes the last filter from the filter stack and doesn't return it. - * + * @param target {RenderTarget} * @param maskData {any[]} */ MaskManager.prototype.popStencilMask = function (target, maskData) diff --git a/src/core/renderers/webgl/managers/ShaderManager.js b/src/core/renderers/webgl/managers/ShaderManager.js index 32dabf0..d3ee07a 100644 --- a/src/core/renderers/webgl/managers/ShaderManager.js +++ b/src/core/renderers/webgl/managers/ShaderManager.js @@ -7,6 +7,7 @@ /** * @class * @memberof PIXI + * @extends WebGLManager * @param renderer {WebGLRenderer} The renderer this manager works for. */ function ShaderManager(renderer) @@ -59,6 +60,10 @@ module.exports = ShaderManager; +/** + * Called when there is a WebGL context change. + * + */ ShaderManager.prototype.onContextChange = function () { this.initPlugins(); diff --git a/src/core/renderers/webgl/managers/WebGLManager.js b/src/core/renderers/webgl/managers/WebGLManager.js index 41ddec2..dfb5573 100644 --- a/src/core/renderers/webgl/managers/WebGLManager.js +++ b/src/core/renderers/webgl/managers/WebGLManager.js @@ -23,11 +23,19 @@ WebGLManager.prototype.constructor = WebGLManager; module.exports = WebGLManager; +/** + * Generic method called when there is a WebGL context change. + * + */ WebGLManager.prototype.onContextChange = function () { // do some codes init! }; +/** + * Generic destroy methods to be overridden by the subclass + * + */ WebGLManager.prototype.destroy = function () { this.renderer.off('context', this._onContextChangeFn); diff --git a/src/core/renderers/webgl/shaders/ComplexPrimitiveShader.js b/src/core/renderers/webgl/shaders/ComplexPrimitiveShader.js index e3b06ac..15fae67 100644 --- a/src/core/renderers/webgl/shaders/ComplexPrimitiveShader.js +++ b/src/core/renderers/webgl/shaders/ComplexPrimitiveShader.js @@ -3,6 +3,7 @@ /** * @class * @memberof PIXI + * @extends Shader * @param shaderManager {ShaderManager} The webgl shader manager this shader works for. */ function ComplexPrimitiveShader(shaderManager) diff --git a/src/core/renderers/webgl/shaders/PrimitiveShader.js b/src/core/renderers/webgl/shaders/PrimitiveShader.js index b7eed82..d89a547 100644 --- a/src/core/renderers/webgl/shaders/PrimitiveShader.js +++ b/src/core/renderers/webgl/shaders/PrimitiveShader.js @@ -3,6 +3,7 @@ /** * @class * @memberof PIXI + * @extends Shader * @param shaderManager {ShaderManager} The webgl shader manager this shader works for. */ function PrimitiveShader(shaderManager) diff --git a/src/core/renderers/webgl/shaders/Shader.js b/src/core/renderers/webgl/shaders/Shader.js index 9f25245..20079d7 100644 --- a/src/core/renderers/webgl/shaders/Shader.js +++ b/src/core/renderers/webgl/shaders/Shader.js @@ -37,10 +37,25 @@ */ this.program = null; + /** + * The uniforms as an object + * @member {object} + * @private + */ this.uniforms = uniforms || {}; + /** + * The attributes as an object + * @member {object} + * @private + */ this.attributes = attributes || {}; + /** + * Internal texture counter + * @member {number} + * @private + */ this.textureCount = 1; /** @@ -63,6 +78,10 @@ Shader.prototype.constructor = Shader; module.exports = Shader; +/* + * Creates the shader and uses it + * + */ Shader.prototype.init = function () { this.compile(); @@ -73,6 +92,10 @@ this.cacheAttributeLocations(Object.keys(this.attributes)); }; +/* + * Caches the locations of the uniform for reuse + * @param key {string} the uniform to cache + */ Shader.prototype.cacheUniformLocations = function (keys) { for (var i = 0; i < keys.length; ++i) @@ -81,6 +104,10 @@ } }; +/* + * Caches the locations of the attribute for reuse + * @param key {string} the attribute to cache + */ Shader.prototype.cacheAttributeLocations = function (keys) { for (var i = 0; i < keys.length; ++i) @@ -103,6 +130,9 @@ // End worst hack eva // }; +/* + * Attaches the shaders and creates the program + */ Shader.prototype.compile = function () { var gl = this.gl; @@ -119,14 +149,14 @@ // if linking fails, then log and cleanup if (!gl.getProgramParameter(program, gl.LINK_STATUS)) { - window.console.error('Pixi.js Error: Could not initialize shader.'); - window.console.error('gl.VALIDATE_STATUS', gl.getProgramParameter(program, gl.VALIDATE_STATUS)); - window.console.error('gl.getError()', gl.getError()); + console.error('Pixi.js Error: Could not initialize shader.'); + console.error('gl.VALIDATE_STATUS', gl.getProgramParameter(program, gl.VALIDATE_STATUS)); + console.error('gl.getError()', gl.getError()); // if there is a program info log, log it if (gl.getProgramInfoLog(program) !== '') { - window.console.warn('Pixi.js Warning: gl.getProgramInfoLog()', gl.getProgramInfoLog(program)); + console.warn('Pixi.js Warning: gl.getProgramInfoLog()', gl.getProgramInfoLog(program)); } gl.deleteProgram(program); @@ -176,6 +206,11 @@ }*/ +/** +* Adds a new uniform +* +* @param uniform {Object} the new uniform to attach +*/ Shader.prototype.syncUniform = function (uniform) { var location = uniform._location, @@ -407,6 +442,9 @@ } }; +/* + * Updates the shader uniform values. + */ Shader.prototype.syncUniforms = function () { this.textureCount = 1; diff --git a/src/core/renderers/webgl/shaders/TextureShader.js b/src/core/renderers/webgl/shaders/TextureShader.js index 7e30f83..000463f 100644 --- a/src/core/renderers/webgl/shaders/TextureShader.js +++ b/src/core/renderers/webgl/shaders/TextureShader.js @@ -3,6 +3,7 @@ /** * @class * @memberof PIXI + * @extends Shader * @param shaderManager {ShaderManager} The webgl shader manager this shader works for. * @param [vertexSrc] {string} The source of the vertex shader. * @param [fragmentSrc] {string} The source of the fragment shader. diff --git a/src/core/renderers/canvas/CanvasRenderer.js b/src/core/renderers/canvas/CanvasRenderer.js index 24eafc9..389ae5e 100644 --- a/src/core/renderers/canvas/CanvasRenderer.js +++ b/src/core/renderers/canvas/CanvasRenderer.js @@ -10,6 +10,7 @@ * * @class * @memberof PIXI + * @extends SystemRenderer * @param [width=800] {number} the width of the canvas view * @param [height=600] {number} the height of the canvas view * @param [options] {object} The optional renderer parameters diff --git a/src/core/renderers/webgl/WebGLRenderer.js b/src/core/renderers/webgl/WebGLRenderer.js index 15ce4fe..6bfb6de 100644 --- a/src/core/renderers/webgl/WebGLRenderer.js +++ b/src/core/renderers/webgl/WebGLRenderer.js @@ -265,7 +265,7 @@ * Renders a Display Object. * * @param displayObject {DisplayObject} The DisplayObject to render - * @param renderTarget {Point} TODO @alvin + * @param renderTarget {RenderTarget} The render target to use to render this display object * */ WebGLRenderer.prototype.renderDisplayObject = function (displayObject, renderTarget)//projection, buffer) @@ -305,7 +305,7 @@ /** * Changes the current render target to the one given in parameter * - * @param renderTarget {Object} the new render target + * @param renderTarget {RenderTarget} the new render target * */ WebGLRenderer.prototype.setRenderTarget = function (renderTarget) diff --git a/src/core/renderers/webgl/filters/AbstractFilter.js b/src/core/renderers/webgl/filters/AbstractFilter.js index 91e874c..7a3cb01 100644 --- a/src/core/renderers/webgl/filters/AbstractFilter.js +++ b/src/core/renderers/webgl/filters/AbstractFilter.js @@ -84,6 +84,13 @@ return shader; }; +/* + * Applies the filter + * @param renderer {Shader} + * @param input {Any} + * @param output {Any} + * @param clear {boolean} Whether or not we want to clear the outputTarget + */ AbstractFilter.prototype.applyFilter = function (renderer, input, output, clear) { var shader = this.getShader(renderer); diff --git a/src/core/renderers/webgl/filters/FXAAFilter.js b/src/core/renderers/webgl/filters/FXAAFilter.js index f9398d1..bda7830 100644 --- a/src/core/renderers/webgl/filters/FXAAFilter.js +++ b/src/core/renderers/webgl/filters/FXAAFilter.js @@ -1,14 +1,19 @@ var AbstractFilter = require('./AbstractFilter'); /** - * The FXAAFilter class uses the pixel values from the specified texture (called the displacement map) to perform a displacement of an object. - * You can use this filter to apply all manor of crazy warping effects - * Currently the r property of the texture is used to offset the x and the g property of the texture is used to offset the y. + * + * Basic FXAA implementation based on the code on geeks3d.com with the + * modification that the texture2DLod stuff was removed since it's + * unsupported by WebGL. + * + * -- + * From: + * https://github.com/mitsuhiko/webgl-meincraft * * @class * @extends AbstractFilter * @memberof PIXI - * @param texture {Texture} The texture used for the displacement map * must be power of 2 texture at the moment + * */ function FXAAFilter() { @@ -25,52 +30,6 @@ } ); - /** -Basic FXAA implementation based on the code on geeks3d.com with the -modification that the texture2DLod stuff was removed since it's -unsupported by WebGL. - --- - -From: -https://github.com/mitsuhiko/webgl-meincraft - -Copyright (c) 2011 by Armin Ronacher. - -Some rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. - - * The names of the contributors may not be used to endorse or - promote products derived from this software without specific - prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - - - - } FXAAFilter.prototype = Object.create(AbstractFilter.prototype); diff --git a/src/core/renderers/webgl/filters/SpriteMaskFilter.js b/src/core/renderers/webgl/filters/SpriteMaskFilter.js index 4b09a8c..e1e5167 100644 --- a/src/core/renderers/webgl/filters/SpriteMaskFilter.js +++ b/src/core/renderers/webgl/filters/SpriteMaskFilter.js @@ -2,14 +2,12 @@ math = require('../../../math'); /** - * The SpriteMaskFilter class uses the pixel values from the specified texture (called the displacement map) to perform a displacement of an object. - * You can use this filter to apply all manor of crazy warping effects - * Currently the r property of the texture is used to offset the x and the g property of the texture is used to offset the y. + * The SpriteMaskFilter class * * @class * @extends AbstractFilter * @memberof PIXI - * @param texture {Texture} The texture used for the displacement map * must be power of 2 texture at the moment + * @param sprite {Sprite} the target sprite */ function SpriteMaskFilter(sprite) { @@ -72,6 +70,13 @@ SpriteMaskFilter.prototype.constructor = SpriteMaskFilter; module.exports = SpriteMaskFilter; +/** + * Applies the filter ? @alvin + * + * @param renderer {WebGLRenderer} A reference to the WebGL renderer + * @param input {} + * @param output {} + */ SpriteMaskFilter.prototype.applyFilter = function (renderer, input, output) { var filterManager = renderer.filterManager; diff --git a/src/core/renderers/webgl/managers/BlendModeManager.js b/src/core/renderers/webgl/managers/BlendModeManager.js index be51394..356f641 100644 --- a/src/core/renderers/webgl/managers/BlendModeManager.js +++ b/src/core/renderers/webgl/managers/BlendModeManager.js @@ -3,6 +3,7 @@ /** * @class * @memberof PIXI + * @extends WebGlManager * @param renderer {WebGLRenderer} The renderer this manager works for. */ function BlendModeManager(renderer) diff --git a/src/core/renderers/webgl/managers/FilterManager.js b/src/core/renderers/webgl/managers/FilterManager.js index b22513d..7576ef3 100644 --- a/src/core/renderers/webgl/managers/FilterManager.js +++ b/src/core/renderers/webgl/managers/FilterManager.js @@ -6,6 +6,7 @@ /** * @class * @memberof PIXI + * @extends WebGLManager * @param renderer {WebGLRenderer} The renderer this manager works for. */ function FilterManager(renderer) @@ -41,6 +42,10 @@ module.exports = FilterManager; +/** + * Called when there is a WebGL context change. + * + */ FilterManager.prototype.onContextChange = function () { this.texturePool.length = 0; @@ -117,7 +122,7 @@ /** - * Removes the last filter from the filter stack and doesn't return it. + * Removes the last filter from the filter stack and returns it. * */ FilterManager.prototype.popFilter = function () @@ -192,6 +197,12 @@ return filterData.filter; }; +/** + * Grabs an render target from the internal pool + * + * @param clear {boolean} Whether or not we need to clear the RenderTarget + * @return {RenderTarget} + */ FilterManager.prototype.getRenderTarget = function ( clear ) { var renderTarget = this.texturePool.pop() || new RenderTarget(this.renderer.gl, this.textureSize.width, this.textureSize.height, null, this.renderer.resolution); @@ -205,11 +216,22 @@ return renderTarget; }; +/* + * Returns a RenderTarget to the internal pool + * @param renderTarget {RenderTarget} The RenderTarget we want to return to the pool + */ FilterManager.prototype.returnRenderTarget = function (renderTarget) { this.texturePool.push( renderTarget ); }; +/* + * Applies the filter + * @param shader {Shader} + * @param inputTarget {Any} + * @param outputTarget {Any} + * @param clear {boolean} Whether or not we want to clear the outputTarget + */ FilterManager.prototype.applyFilter = function (shader, inputTarget, outputTarget, clear) { var gl = this.renderer.gl; @@ -240,7 +262,12 @@ gl.drawElements(gl.TRIANGLES, 6, gl.UNSIGNED_SHORT, 0 ); }; - +/* + * Constrains the filter area to the texture size + * @param filterArea {Rectangle} The filter area + * @param sprite {Sprite} the target sprite + * @param outputMatrix {Matrix} @alvin + */ // TODO playing around here.. this is temporary - (will end up in the shader) FilterManager.prototype.calculateMappedMatrix = function (filterArea, sprite, outputMatrix) { @@ -308,6 +335,10 @@ // return transform; }; +/* + * Constrains the filter area to the texture size + * @param filterArea {Rectangle} The filter area we want to cap + */ FilterManager.prototype.capFilterArea = function (filterArea) { if (filterArea.x < 0) @@ -333,6 +364,11 @@ } }; +/* + * Resizes all the render targets in the pool + * @param width {number} the new width + * @param height {number} the new height + */ FilterManager.prototype.resize = function ( width, height ) { this.textureSize.width = width; diff --git a/src/core/renderers/webgl/managers/MaskManager.js b/src/core/renderers/webgl/managers/MaskManager.js index 472eea1..fbc8e9c 100644 --- a/src/core/renderers/webgl/managers/MaskManager.js +++ b/src/core/renderers/webgl/managers/MaskManager.js @@ -40,6 +40,12 @@ }; +/** + * Removes the last mask from the mask stack and doesn't return it. + * + * @param target {RenderTarget} + * @param maskData {any[]} + */ MaskManager.prototype.popMask = function (target, maskData) { if (maskData.texture) @@ -52,6 +58,12 @@ } }; +/** + * Applies the Mask and adds it to the current filter stack. + * + * @param target {RenderTarget} + * @param maskData {any[]} + */ MaskManager.prototype.pushSpriteMask = function (target, maskData) { var alphaMaskFilter = this.alphaMaskPool.pop(); @@ -79,9 +91,9 @@ /** * Applies the Mask and adds it to the current filter stack. * + * @param target {RenderTarget} * @param maskData {any[]} */ - MaskManager.prototype.pushStencilMask = function (target, maskData) { this.renderer.stencilManager.pushMask(maskData); @@ -89,7 +101,7 @@ /** * Removes the last filter from the filter stack and doesn't return it. - * + * @param target {RenderTarget} * @param maskData {any[]} */ MaskManager.prototype.popStencilMask = function (target, maskData) diff --git a/src/core/renderers/webgl/managers/ShaderManager.js b/src/core/renderers/webgl/managers/ShaderManager.js index 32dabf0..d3ee07a 100644 --- a/src/core/renderers/webgl/managers/ShaderManager.js +++ b/src/core/renderers/webgl/managers/ShaderManager.js @@ -7,6 +7,7 @@ /** * @class * @memberof PIXI + * @extends WebGLManager * @param renderer {WebGLRenderer} The renderer this manager works for. */ function ShaderManager(renderer) @@ -59,6 +60,10 @@ module.exports = ShaderManager; +/** + * Called when there is a WebGL context change. + * + */ ShaderManager.prototype.onContextChange = function () { this.initPlugins(); diff --git a/src/core/renderers/webgl/managers/WebGLManager.js b/src/core/renderers/webgl/managers/WebGLManager.js index 41ddec2..dfb5573 100644 --- a/src/core/renderers/webgl/managers/WebGLManager.js +++ b/src/core/renderers/webgl/managers/WebGLManager.js @@ -23,11 +23,19 @@ WebGLManager.prototype.constructor = WebGLManager; module.exports = WebGLManager; +/** + * Generic method called when there is a WebGL context change. + * + */ WebGLManager.prototype.onContextChange = function () { // do some codes init! }; +/** + * Generic destroy methods to be overridden by the subclass + * + */ WebGLManager.prototype.destroy = function () { this.renderer.off('context', this._onContextChangeFn); diff --git a/src/core/renderers/webgl/shaders/ComplexPrimitiveShader.js b/src/core/renderers/webgl/shaders/ComplexPrimitiveShader.js index e3b06ac..15fae67 100644 --- a/src/core/renderers/webgl/shaders/ComplexPrimitiveShader.js +++ b/src/core/renderers/webgl/shaders/ComplexPrimitiveShader.js @@ -3,6 +3,7 @@ /** * @class * @memberof PIXI + * @extends Shader * @param shaderManager {ShaderManager} The webgl shader manager this shader works for. */ function ComplexPrimitiveShader(shaderManager) diff --git a/src/core/renderers/webgl/shaders/PrimitiveShader.js b/src/core/renderers/webgl/shaders/PrimitiveShader.js index b7eed82..d89a547 100644 --- a/src/core/renderers/webgl/shaders/PrimitiveShader.js +++ b/src/core/renderers/webgl/shaders/PrimitiveShader.js @@ -3,6 +3,7 @@ /** * @class * @memberof PIXI + * @extends Shader * @param shaderManager {ShaderManager} The webgl shader manager this shader works for. */ function PrimitiveShader(shaderManager) diff --git a/src/core/renderers/webgl/shaders/Shader.js b/src/core/renderers/webgl/shaders/Shader.js index 9f25245..20079d7 100644 --- a/src/core/renderers/webgl/shaders/Shader.js +++ b/src/core/renderers/webgl/shaders/Shader.js @@ -37,10 +37,25 @@ */ this.program = null; + /** + * The uniforms as an object + * @member {object} + * @private + */ this.uniforms = uniforms || {}; + /** + * The attributes as an object + * @member {object} + * @private + */ this.attributes = attributes || {}; + /** + * Internal texture counter + * @member {number} + * @private + */ this.textureCount = 1; /** @@ -63,6 +78,10 @@ Shader.prototype.constructor = Shader; module.exports = Shader; +/* + * Creates the shader and uses it + * + */ Shader.prototype.init = function () { this.compile(); @@ -73,6 +92,10 @@ this.cacheAttributeLocations(Object.keys(this.attributes)); }; +/* + * Caches the locations of the uniform for reuse + * @param key {string} the uniform to cache + */ Shader.prototype.cacheUniformLocations = function (keys) { for (var i = 0; i < keys.length; ++i) @@ -81,6 +104,10 @@ } }; +/* + * Caches the locations of the attribute for reuse + * @param key {string} the attribute to cache + */ Shader.prototype.cacheAttributeLocations = function (keys) { for (var i = 0; i < keys.length; ++i) @@ -103,6 +130,9 @@ // End worst hack eva // }; +/* + * Attaches the shaders and creates the program + */ Shader.prototype.compile = function () { var gl = this.gl; @@ -119,14 +149,14 @@ // if linking fails, then log and cleanup if (!gl.getProgramParameter(program, gl.LINK_STATUS)) { - window.console.error('Pixi.js Error: Could not initialize shader.'); - window.console.error('gl.VALIDATE_STATUS', gl.getProgramParameter(program, gl.VALIDATE_STATUS)); - window.console.error('gl.getError()', gl.getError()); + console.error('Pixi.js Error: Could not initialize shader.'); + console.error('gl.VALIDATE_STATUS', gl.getProgramParameter(program, gl.VALIDATE_STATUS)); + console.error('gl.getError()', gl.getError()); // if there is a program info log, log it if (gl.getProgramInfoLog(program) !== '') { - window.console.warn('Pixi.js Warning: gl.getProgramInfoLog()', gl.getProgramInfoLog(program)); + console.warn('Pixi.js Warning: gl.getProgramInfoLog()', gl.getProgramInfoLog(program)); } gl.deleteProgram(program); @@ -176,6 +206,11 @@ }*/ +/** +* Adds a new uniform +* +* @param uniform {Object} the new uniform to attach +*/ Shader.prototype.syncUniform = function (uniform) { var location = uniform._location, @@ -407,6 +442,9 @@ } }; +/* + * Updates the shader uniform values. + */ Shader.prototype.syncUniforms = function () { this.textureCount = 1; diff --git a/src/core/renderers/webgl/shaders/TextureShader.js b/src/core/renderers/webgl/shaders/TextureShader.js index 7e30f83..000463f 100644 --- a/src/core/renderers/webgl/shaders/TextureShader.js +++ b/src/core/renderers/webgl/shaders/TextureShader.js @@ -3,6 +3,7 @@ /** * @class * @memberof PIXI + * @extends Shader * @param shaderManager {ShaderManager} The webgl shader manager this shader works for. * @param [vertexSrc] {string} The source of the vertex shader. * @param [fragmentSrc] {string} The source of the fragment shader. diff --git a/src/core/renderers/webgl/utils/RenderTarget.js b/src/core/renderers/webgl/utils/RenderTarget.js index 24585ed..4e63203 100644 --- a/src/core/renderers/webgl/utils/RenderTarget.js +++ b/src/core/renderers/webgl/utils/RenderTarget.js @@ -12,49 +12,81 @@ * @class * @memberof PIXI * @param gl {WebGLRenderingContext} the current WebGL drawing context - * @param width {Number} the horizontal range of the filter - * @param height {Number} the vertical range of the filter - * @param scaleMode {Number} See {{#crossLink "PIXI/scaleModes:property"}}PIXI.scaleModes{{/crossLink}} for possible values + * @param width {number} the horizontal range of the filter + * @param height {number} the vertical range of the filter + * @param scaleMode {number} See {{#crossLink "PIXI/scaleModes:property"}}PIXI.scaleModes{{/crossLink}} for possible values + * @param resolution {number} the current resolution + * @param root {boolean} Whether this object is the root element or not */ var RenderTarget = function(gl, width, height, scaleMode, resolution, root) { //TODO Resolution could go here ( eg low res blurs ) /** - * @property gl - * @type WebGLRenderingContext + * The current WebGL drawing context + * member {WebGLRenderingContext} */ this.gl = gl; // next time to create a frame buffer and texture /** - * @property frameBuffer - * @type Any + * A frame buffer + * @member {WebGLFrameBuffer} */ this.frameBuffer = null; /** - * @property texture - * @type Any + * @member {Texture} */ this.texture = null; + /** + * The size of the object as a rectangle + * @member {Rectangle} + */ this.size = new math.Rectangle(0, 0, 1, 1); + /** + * The current resolution + * @member {number} + */ this.resolution = resolution || CONST.RESOLUTION; + /** + * The projection matrix + * @member {Matrix} + */ this.projectionMatrix = new math.Matrix(); + /** + * The object's transform + * @member {Matrix} + */ this.transform = null; + /** + * + * @member {Rectangle} + */ this.frame = null; - // stores masking data for the render target + /** + * The stencil buffer stores masking data for the render target + * @member {WebGLRenderBuffer} + */ this.stencilBuffer = null; + + /** + * The data structure for the stencil masks + * @member {StencilMaskStack} + */ this.stencilMaskStack = new StencilMaskStack(); - // stores filter data for the render target + /** + * Stores filter data for the render target + * @member {Array} + */ this.filterStack = [ { renderTarget:this, @@ -65,11 +97,16 @@ /** - * @property scaleMode - * @type Number + * The scale mode + * @member {number} + * @default CONST.SCALE_MODES.DEFAULT */ this.scaleMode = scaleMode || CONST.SCALE_MODES.DEFAULT; + /** + * Whether this object is the root element or not + * @member {boolean} + */ this.root = root; if (!this.root) @@ -129,6 +166,10 @@ gl.clear(gl.COLOR_BUFFER_BIT); }; +/** +* Binds the stencil buffer. +* +*/ RenderTarget.prototype.attachStencilBuffer = function() { @@ -152,6 +193,10 @@ } }; +/** +* Binds the buffers and initialises the viewport. +* +*/ RenderTarget.prototype.activate = function() { //TOOD refactor usage of frame.. @@ -172,6 +217,10 @@ gl.viewport(0,0, projectionFrame.width * this.resolution, projectionFrame.height * this.resolution); }; +/** +* Updates the projection matrix based on a projection frame (which is a rectangle) +* +*/ RenderTarget.prototype.calculateProjection = function( projectionFrame ) { var pm = this.projectionMatrix; @@ -237,7 +286,7 @@ }; /** - * Destroys the filter texture. + * Destroys the render target. * */ RenderTarget.prototype.destroy = function() diff --git a/src/core/renderers/canvas/CanvasRenderer.js b/src/core/renderers/canvas/CanvasRenderer.js index 24eafc9..389ae5e 100644 --- a/src/core/renderers/canvas/CanvasRenderer.js +++ b/src/core/renderers/canvas/CanvasRenderer.js @@ -10,6 +10,7 @@ * * @class * @memberof PIXI + * @extends SystemRenderer * @param [width=800] {number} the width of the canvas view * @param [height=600] {number} the height of the canvas view * @param [options] {object} The optional renderer parameters diff --git a/src/core/renderers/webgl/WebGLRenderer.js b/src/core/renderers/webgl/WebGLRenderer.js index 15ce4fe..6bfb6de 100644 --- a/src/core/renderers/webgl/WebGLRenderer.js +++ b/src/core/renderers/webgl/WebGLRenderer.js @@ -265,7 +265,7 @@ * Renders a Display Object. * * @param displayObject {DisplayObject} The DisplayObject to render - * @param renderTarget {Point} TODO @alvin + * @param renderTarget {RenderTarget} The render target to use to render this display object * */ WebGLRenderer.prototype.renderDisplayObject = function (displayObject, renderTarget)//projection, buffer) @@ -305,7 +305,7 @@ /** * Changes the current render target to the one given in parameter * - * @param renderTarget {Object} the new render target + * @param renderTarget {RenderTarget} the new render target * */ WebGLRenderer.prototype.setRenderTarget = function (renderTarget) diff --git a/src/core/renderers/webgl/filters/AbstractFilter.js b/src/core/renderers/webgl/filters/AbstractFilter.js index 91e874c..7a3cb01 100644 --- a/src/core/renderers/webgl/filters/AbstractFilter.js +++ b/src/core/renderers/webgl/filters/AbstractFilter.js @@ -84,6 +84,13 @@ return shader; }; +/* + * Applies the filter + * @param renderer {Shader} + * @param input {Any} + * @param output {Any} + * @param clear {boolean} Whether or not we want to clear the outputTarget + */ AbstractFilter.prototype.applyFilter = function (renderer, input, output, clear) { var shader = this.getShader(renderer); diff --git a/src/core/renderers/webgl/filters/FXAAFilter.js b/src/core/renderers/webgl/filters/FXAAFilter.js index f9398d1..bda7830 100644 --- a/src/core/renderers/webgl/filters/FXAAFilter.js +++ b/src/core/renderers/webgl/filters/FXAAFilter.js @@ -1,14 +1,19 @@ var AbstractFilter = require('./AbstractFilter'); /** - * The FXAAFilter class uses the pixel values from the specified texture (called the displacement map) to perform a displacement of an object. - * You can use this filter to apply all manor of crazy warping effects - * Currently the r property of the texture is used to offset the x and the g property of the texture is used to offset the y. + * + * Basic FXAA implementation based on the code on geeks3d.com with the + * modification that the texture2DLod stuff was removed since it's + * unsupported by WebGL. + * + * -- + * From: + * https://github.com/mitsuhiko/webgl-meincraft * * @class * @extends AbstractFilter * @memberof PIXI - * @param texture {Texture} The texture used for the displacement map * must be power of 2 texture at the moment + * */ function FXAAFilter() { @@ -25,52 +30,6 @@ } ); - /** -Basic FXAA implementation based on the code on geeks3d.com with the -modification that the texture2DLod stuff was removed since it's -unsupported by WebGL. - --- - -From: -https://github.com/mitsuhiko/webgl-meincraft - -Copyright (c) 2011 by Armin Ronacher. - -Some rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. - - * The names of the contributors may not be used to endorse or - promote products derived from this software without specific - prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - - - - } FXAAFilter.prototype = Object.create(AbstractFilter.prototype); diff --git a/src/core/renderers/webgl/filters/SpriteMaskFilter.js b/src/core/renderers/webgl/filters/SpriteMaskFilter.js index 4b09a8c..e1e5167 100644 --- a/src/core/renderers/webgl/filters/SpriteMaskFilter.js +++ b/src/core/renderers/webgl/filters/SpriteMaskFilter.js @@ -2,14 +2,12 @@ math = require('../../../math'); /** - * The SpriteMaskFilter class uses the pixel values from the specified texture (called the displacement map) to perform a displacement of an object. - * You can use this filter to apply all manor of crazy warping effects - * Currently the r property of the texture is used to offset the x and the g property of the texture is used to offset the y. + * The SpriteMaskFilter class * * @class * @extends AbstractFilter * @memberof PIXI - * @param texture {Texture} The texture used for the displacement map * must be power of 2 texture at the moment + * @param sprite {Sprite} the target sprite */ function SpriteMaskFilter(sprite) { @@ -72,6 +70,13 @@ SpriteMaskFilter.prototype.constructor = SpriteMaskFilter; module.exports = SpriteMaskFilter; +/** + * Applies the filter ? @alvin + * + * @param renderer {WebGLRenderer} A reference to the WebGL renderer + * @param input {} + * @param output {} + */ SpriteMaskFilter.prototype.applyFilter = function (renderer, input, output) { var filterManager = renderer.filterManager; diff --git a/src/core/renderers/webgl/managers/BlendModeManager.js b/src/core/renderers/webgl/managers/BlendModeManager.js index be51394..356f641 100644 --- a/src/core/renderers/webgl/managers/BlendModeManager.js +++ b/src/core/renderers/webgl/managers/BlendModeManager.js @@ -3,6 +3,7 @@ /** * @class * @memberof PIXI + * @extends WebGlManager * @param renderer {WebGLRenderer} The renderer this manager works for. */ function BlendModeManager(renderer) diff --git a/src/core/renderers/webgl/managers/FilterManager.js b/src/core/renderers/webgl/managers/FilterManager.js index b22513d..7576ef3 100644 --- a/src/core/renderers/webgl/managers/FilterManager.js +++ b/src/core/renderers/webgl/managers/FilterManager.js @@ -6,6 +6,7 @@ /** * @class * @memberof PIXI + * @extends WebGLManager * @param renderer {WebGLRenderer} The renderer this manager works for. */ function FilterManager(renderer) @@ -41,6 +42,10 @@ module.exports = FilterManager; +/** + * Called when there is a WebGL context change. + * + */ FilterManager.prototype.onContextChange = function () { this.texturePool.length = 0; @@ -117,7 +122,7 @@ /** - * Removes the last filter from the filter stack and doesn't return it. + * Removes the last filter from the filter stack and returns it. * */ FilterManager.prototype.popFilter = function () @@ -192,6 +197,12 @@ return filterData.filter; }; +/** + * Grabs an render target from the internal pool + * + * @param clear {boolean} Whether or not we need to clear the RenderTarget + * @return {RenderTarget} + */ FilterManager.prototype.getRenderTarget = function ( clear ) { var renderTarget = this.texturePool.pop() || new RenderTarget(this.renderer.gl, this.textureSize.width, this.textureSize.height, null, this.renderer.resolution); @@ -205,11 +216,22 @@ return renderTarget; }; +/* + * Returns a RenderTarget to the internal pool + * @param renderTarget {RenderTarget} The RenderTarget we want to return to the pool + */ FilterManager.prototype.returnRenderTarget = function (renderTarget) { this.texturePool.push( renderTarget ); }; +/* + * Applies the filter + * @param shader {Shader} + * @param inputTarget {Any} + * @param outputTarget {Any} + * @param clear {boolean} Whether or not we want to clear the outputTarget + */ FilterManager.prototype.applyFilter = function (shader, inputTarget, outputTarget, clear) { var gl = this.renderer.gl; @@ -240,7 +262,12 @@ gl.drawElements(gl.TRIANGLES, 6, gl.UNSIGNED_SHORT, 0 ); }; - +/* + * Constrains the filter area to the texture size + * @param filterArea {Rectangle} The filter area + * @param sprite {Sprite} the target sprite + * @param outputMatrix {Matrix} @alvin + */ // TODO playing around here.. this is temporary - (will end up in the shader) FilterManager.prototype.calculateMappedMatrix = function (filterArea, sprite, outputMatrix) { @@ -308,6 +335,10 @@ // return transform; }; +/* + * Constrains the filter area to the texture size + * @param filterArea {Rectangle} The filter area we want to cap + */ FilterManager.prototype.capFilterArea = function (filterArea) { if (filterArea.x < 0) @@ -333,6 +364,11 @@ } }; +/* + * Resizes all the render targets in the pool + * @param width {number} the new width + * @param height {number} the new height + */ FilterManager.prototype.resize = function ( width, height ) { this.textureSize.width = width; diff --git a/src/core/renderers/webgl/managers/MaskManager.js b/src/core/renderers/webgl/managers/MaskManager.js index 472eea1..fbc8e9c 100644 --- a/src/core/renderers/webgl/managers/MaskManager.js +++ b/src/core/renderers/webgl/managers/MaskManager.js @@ -40,6 +40,12 @@ }; +/** + * Removes the last mask from the mask stack and doesn't return it. + * + * @param target {RenderTarget} + * @param maskData {any[]} + */ MaskManager.prototype.popMask = function (target, maskData) { if (maskData.texture) @@ -52,6 +58,12 @@ } }; +/** + * Applies the Mask and adds it to the current filter stack. + * + * @param target {RenderTarget} + * @param maskData {any[]} + */ MaskManager.prototype.pushSpriteMask = function (target, maskData) { var alphaMaskFilter = this.alphaMaskPool.pop(); @@ -79,9 +91,9 @@ /** * Applies the Mask and adds it to the current filter stack. * + * @param target {RenderTarget} * @param maskData {any[]} */ - MaskManager.prototype.pushStencilMask = function (target, maskData) { this.renderer.stencilManager.pushMask(maskData); @@ -89,7 +101,7 @@ /** * Removes the last filter from the filter stack and doesn't return it. - * + * @param target {RenderTarget} * @param maskData {any[]} */ MaskManager.prototype.popStencilMask = function (target, maskData) diff --git a/src/core/renderers/webgl/managers/ShaderManager.js b/src/core/renderers/webgl/managers/ShaderManager.js index 32dabf0..d3ee07a 100644 --- a/src/core/renderers/webgl/managers/ShaderManager.js +++ b/src/core/renderers/webgl/managers/ShaderManager.js @@ -7,6 +7,7 @@ /** * @class * @memberof PIXI + * @extends WebGLManager * @param renderer {WebGLRenderer} The renderer this manager works for. */ function ShaderManager(renderer) @@ -59,6 +60,10 @@ module.exports = ShaderManager; +/** + * Called when there is a WebGL context change. + * + */ ShaderManager.prototype.onContextChange = function () { this.initPlugins(); diff --git a/src/core/renderers/webgl/managers/WebGLManager.js b/src/core/renderers/webgl/managers/WebGLManager.js index 41ddec2..dfb5573 100644 --- a/src/core/renderers/webgl/managers/WebGLManager.js +++ b/src/core/renderers/webgl/managers/WebGLManager.js @@ -23,11 +23,19 @@ WebGLManager.prototype.constructor = WebGLManager; module.exports = WebGLManager; +/** + * Generic method called when there is a WebGL context change. + * + */ WebGLManager.prototype.onContextChange = function () { // do some codes init! }; +/** + * Generic destroy methods to be overridden by the subclass + * + */ WebGLManager.prototype.destroy = function () { this.renderer.off('context', this._onContextChangeFn); diff --git a/src/core/renderers/webgl/shaders/ComplexPrimitiveShader.js b/src/core/renderers/webgl/shaders/ComplexPrimitiveShader.js index e3b06ac..15fae67 100644 --- a/src/core/renderers/webgl/shaders/ComplexPrimitiveShader.js +++ b/src/core/renderers/webgl/shaders/ComplexPrimitiveShader.js @@ -3,6 +3,7 @@ /** * @class * @memberof PIXI + * @extends Shader * @param shaderManager {ShaderManager} The webgl shader manager this shader works for. */ function ComplexPrimitiveShader(shaderManager) diff --git a/src/core/renderers/webgl/shaders/PrimitiveShader.js b/src/core/renderers/webgl/shaders/PrimitiveShader.js index b7eed82..d89a547 100644 --- a/src/core/renderers/webgl/shaders/PrimitiveShader.js +++ b/src/core/renderers/webgl/shaders/PrimitiveShader.js @@ -3,6 +3,7 @@ /** * @class * @memberof PIXI + * @extends Shader * @param shaderManager {ShaderManager} The webgl shader manager this shader works for. */ function PrimitiveShader(shaderManager) diff --git a/src/core/renderers/webgl/shaders/Shader.js b/src/core/renderers/webgl/shaders/Shader.js index 9f25245..20079d7 100644 --- a/src/core/renderers/webgl/shaders/Shader.js +++ b/src/core/renderers/webgl/shaders/Shader.js @@ -37,10 +37,25 @@ */ this.program = null; + /** + * The uniforms as an object + * @member {object} + * @private + */ this.uniforms = uniforms || {}; + /** + * The attributes as an object + * @member {object} + * @private + */ this.attributes = attributes || {}; + /** + * Internal texture counter + * @member {number} + * @private + */ this.textureCount = 1; /** @@ -63,6 +78,10 @@ Shader.prototype.constructor = Shader; module.exports = Shader; +/* + * Creates the shader and uses it + * + */ Shader.prototype.init = function () { this.compile(); @@ -73,6 +92,10 @@ this.cacheAttributeLocations(Object.keys(this.attributes)); }; +/* + * Caches the locations of the uniform for reuse + * @param key {string} the uniform to cache + */ Shader.prototype.cacheUniformLocations = function (keys) { for (var i = 0; i < keys.length; ++i) @@ -81,6 +104,10 @@ } }; +/* + * Caches the locations of the attribute for reuse + * @param key {string} the attribute to cache + */ Shader.prototype.cacheAttributeLocations = function (keys) { for (var i = 0; i < keys.length; ++i) @@ -103,6 +130,9 @@ // End worst hack eva // }; +/* + * Attaches the shaders and creates the program + */ Shader.prototype.compile = function () { var gl = this.gl; @@ -119,14 +149,14 @@ // if linking fails, then log and cleanup if (!gl.getProgramParameter(program, gl.LINK_STATUS)) { - window.console.error('Pixi.js Error: Could not initialize shader.'); - window.console.error('gl.VALIDATE_STATUS', gl.getProgramParameter(program, gl.VALIDATE_STATUS)); - window.console.error('gl.getError()', gl.getError()); + console.error('Pixi.js Error: Could not initialize shader.'); + console.error('gl.VALIDATE_STATUS', gl.getProgramParameter(program, gl.VALIDATE_STATUS)); + console.error('gl.getError()', gl.getError()); // if there is a program info log, log it if (gl.getProgramInfoLog(program) !== '') { - window.console.warn('Pixi.js Warning: gl.getProgramInfoLog()', gl.getProgramInfoLog(program)); + console.warn('Pixi.js Warning: gl.getProgramInfoLog()', gl.getProgramInfoLog(program)); } gl.deleteProgram(program); @@ -176,6 +206,11 @@ }*/ +/** +* Adds a new uniform +* +* @param uniform {Object} the new uniform to attach +*/ Shader.prototype.syncUniform = function (uniform) { var location = uniform._location, @@ -407,6 +442,9 @@ } }; +/* + * Updates the shader uniform values. + */ Shader.prototype.syncUniforms = function () { this.textureCount = 1; diff --git a/src/core/renderers/webgl/shaders/TextureShader.js b/src/core/renderers/webgl/shaders/TextureShader.js index 7e30f83..000463f 100644 --- a/src/core/renderers/webgl/shaders/TextureShader.js +++ b/src/core/renderers/webgl/shaders/TextureShader.js @@ -3,6 +3,7 @@ /** * @class * @memberof PIXI + * @extends Shader * @param shaderManager {ShaderManager} The webgl shader manager this shader works for. * @param [vertexSrc] {string} The source of the vertex shader. * @param [fragmentSrc] {string} The source of the fragment shader. diff --git a/src/core/renderers/webgl/utils/RenderTarget.js b/src/core/renderers/webgl/utils/RenderTarget.js index 24585ed..4e63203 100644 --- a/src/core/renderers/webgl/utils/RenderTarget.js +++ b/src/core/renderers/webgl/utils/RenderTarget.js @@ -12,49 +12,81 @@ * @class * @memberof PIXI * @param gl {WebGLRenderingContext} the current WebGL drawing context - * @param width {Number} the horizontal range of the filter - * @param height {Number} the vertical range of the filter - * @param scaleMode {Number} See {{#crossLink "PIXI/scaleModes:property"}}PIXI.scaleModes{{/crossLink}} for possible values + * @param width {number} the horizontal range of the filter + * @param height {number} the vertical range of the filter + * @param scaleMode {number} See {{#crossLink "PIXI/scaleModes:property"}}PIXI.scaleModes{{/crossLink}} for possible values + * @param resolution {number} the current resolution + * @param root {boolean} Whether this object is the root element or not */ var RenderTarget = function(gl, width, height, scaleMode, resolution, root) { //TODO Resolution could go here ( eg low res blurs ) /** - * @property gl - * @type WebGLRenderingContext + * The current WebGL drawing context + * member {WebGLRenderingContext} */ this.gl = gl; // next time to create a frame buffer and texture /** - * @property frameBuffer - * @type Any + * A frame buffer + * @member {WebGLFrameBuffer} */ this.frameBuffer = null; /** - * @property texture - * @type Any + * @member {Texture} */ this.texture = null; + /** + * The size of the object as a rectangle + * @member {Rectangle} + */ this.size = new math.Rectangle(0, 0, 1, 1); + /** + * The current resolution + * @member {number} + */ this.resolution = resolution || CONST.RESOLUTION; + /** + * The projection matrix + * @member {Matrix} + */ this.projectionMatrix = new math.Matrix(); + /** + * The object's transform + * @member {Matrix} + */ this.transform = null; + /** + * + * @member {Rectangle} + */ this.frame = null; - // stores masking data for the render target + /** + * The stencil buffer stores masking data for the render target + * @member {WebGLRenderBuffer} + */ this.stencilBuffer = null; + + /** + * The data structure for the stencil masks + * @member {StencilMaskStack} + */ this.stencilMaskStack = new StencilMaskStack(); - // stores filter data for the render target + /** + * Stores filter data for the render target + * @member {Array} + */ this.filterStack = [ { renderTarget:this, @@ -65,11 +97,16 @@ /** - * @property scaleMode - * @type Number + * The scale mode + * @member {number} + * @default CONST.SCALE_MODES.DEFAULT */ this.scaleMode = scaleMode || CONST.SCALE_MODES.DEFAULT; + /** + * Whether this object is the root element or not + * @member {boolean} + */ this.root = root; if (!this.root) @@ -129,6 +166,10 @@ gl.clear(gl.COLOR_BUFFER_BIT); }; +/** +* Binds the stencil buffer. +* +*/ RenderTarget.prototype.attachStencilBuffer = function() { @@ -152,6 +193,10 @@ } }; +/** +* Binds the buffers and initialises the viewport. +* +*/ RenderTarget.prototype.activate = function() { //TOOD refactor usage of frame.. @@ -172,6 +217,10 @@ gl.viewport(0,0, projectionFrame.width * this.resolution, projectionFrame.height * this.resolution); }; +/** +* Updates the projection matrix based on a projection frame (which is a rectangle) +* +*/ RenderTarget.prototype.calculateProjection = function( projectionFrame ) { var pm = this.projectionMatrix; @@ -237,7 +286,7 @@ }; /** - * Destroys the filter texture. + * Destroys the render target. * */ RenderTarget.prototype.destroy = function() diff --git a/src/core/renderers/webgl/utils/StencilMaskStack.js b/src/core/renderers/webgl/utils/StencilMaskStack.js index fb8940e..d7a78ff 100644 --- a/src/core/renderers/webgl/utils/StencilMaskStack.js +++ b/src/core/renderers/webgl/utils/StencilMaskStack.js @@ -1,4 +1,5 @@ /** + * Generic Mask Stack data structure * @class * @memberof PIXI * @param renderer {WebGLRenderer} The renderer this manager works for. diff --git a/src/core/renderers/canvas/CanvasRenderer.js b/src/core/renderers/canvas/CanvasRenderer.js index 24eafc9..389ae5e 100644 --- a/src/core/renderers/canvas/CanvasRenderer.js +++ b/src/core/renderers/canvas/CanvasRenderer.js @@ -10,6 +10,7 @@ * * @class * @memberof PIXI + * @extends SystemRenderer * @param [width=800] {number} the width of the canvas view * @param [height=600] {number} the height of the canvas view * @param [options] {object} The optional renderer parameters diff --git a/src/core/renderers/webgl/WebGLRenderer.js b/src/core/renderers/webgl/WebGLRenderer.js index 15ce4fe..6bfb6de 100644 --- a/src/core/renderers/webgl/WebGLRenderer.js +++ b/src/core/renderers/webgl/WebGLRenderer.js @@ -265,7 +265,7 @@ * Renders a Display Object. * * @param displayObject {DisplayObject} The DisplayObject to render - * @param renderTarget {Point} TODO @alvin + * @param renderTarget {RenderTarget} The render target to use to render this display object * */ WebGLRenderer.prototype.renderDisplayObject = function (displayObject, renderTarget)//projection, buffer) @@ -305,7 +305,7 @@ /** * Changes the current render target to the one given in parameter * - * @param renderTarget {Object} the new render target + * @param renderTarget {RenderTarget} the new render target * */ WebGLRenderer.prototype.setRenderTarget = function (renderTarget) diff --git a/src/core/renderers/webgl/filters/AbstractFilter.js b/src/core/renderers/webgl/filters/AbstractFilter.js index 91e874c..7a3cb01 100644 --- a/src/core/renderers/webgl/filters/AbstractFilter.js +++ b/src/core/renderers/webgl/filters/AbstractFilter.js @@ -84,6 +84,13 @@ return shader; }; +/* + * Applies the filter + * @param renderer {Shader} + * @param input {Any} + * @param output {Any} + * @param clear {boolean} Whether or not we want to clear the outputTarget + */ AbstractFilter.prototype.applyFilter = function (renderer, input, output, clear) { var shader = this.getShader(renderer); diff --git a/src/core/renderers/webgl/filters/FXAAFilter.js b/src/core/renderers/webgl/filters/FXAAFilter.js index f9398d1..bda7830 100644 --- a/src/core/renderers/webgl/filters/FXAAFilter.js +++ b/src/core/renderers/webgl/filters/FXAAFilter.js @@ -1,14 +1,19 @@ var AbstractFilter = require('./AbstractFilter'); /** - * The FXAAFilter class uses the pixel values from the specified texture (called the displacement map) to perform a displacement of an object. - * You can use this filter to apply all manor of crazy warping effects - * Currently the r property of the texture is used to offset the x and the g property of the texture is used to offset the y. + * + * Basic FXAA implementation based on the code on geeks3d.com with the + * modification that the texture2DLod stuff was removed since it's + * unsupported by WebGL. + * + * -- + * From: + * https://github.com/mitsuhiko/webgl-meincraft * * @class * @extends AbstractFilter * @memberof PIXI - * @param texture {Texture} The texture used for the displacement map * must be power of 2 texture at the moment + * */ function FXAAFilter() { @@ -25,52 +30,6 @@ } ); - /** -Basic FXAA implementation based on the code on geeks3d.com with the -modification that the texture2DLod stuff was removed since it's -unsupported by WebGL. - --- - -From: -https://github.com/mitsuhiko/webgl-meincraft - -Copyright (c) 2011 by Armin Ronacher. - -Some rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. - - * The names of the contributors may not be used to endorse or - promote products derived from this software without specific - prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - - - - } FXAAFilter.prototype = Object.create(AbstractFilter.prototype); diff --git a/src/core/renderers/webgl/filters/SpriteMaskFilter.js b/src/core/renderers/webgl/filters/SpriteMaskFilter.js index 4b09a8c..e1e5167 100644 --- a/src/core/renderers/webgl/filters/SpriteMaskFilter.js +++ b/src/core/renderers/webgl/filters/SpriteMaskFilter.js @@ -2,14 +2,12 @@ math = require('../../../math'); /** - * The SpriteMaskFilter class uses the pixel values from the specified texture (called the displacement map) to perform a displacement of an object. - * You can use this filter to apply all manor of crazy warping effects - * Currently the r property of the texture is used to offset the x and the g property of the texture is used to offset the y. + * The SpriteMaskFilter class * * @class * @extends AbstractFilter * @memberof PIXI - * @param texture {Texture} The texture used for the displacement map * must be power of 2 texture at the moment + * @param sprite {Sprite} the target sprite */ function SpriteMaskFilter(sprite) { @@ -72,6 +70,13 @@ SpriteMaskFilter.prototype.constructor = SpriteMaskFilter; module.exports = SpriteMaskFilter; +/** + * Applies the filter ? @alvin + * + * @param renderer {WebGLRenderer} A reference to the WebGL renderer + * @param input {} + * @param output {} + */ SpriteMaskFilter.prototype.applyFilter = function (renderer, input, output) { var filterManager = renderer.filterManager; diff --git a/src/core/renderers/webgl/managers/BlendModeManager.js b/src/core/renderers/webgl/managers/BlendModeManager.js index be51394..356f641 100644 --- a/src/core/renderers/webgl/managers/BlendModeManager.js +++ b/src/core/renderers/webgl/managers/BlendModeManager.js @@ -3,6 +3,7 @@ /** * @class * @memberof PIXI + * @extends WebGlManager * @param renderer {WebGLRenderer} The renderer this manager works for. */ function BlendModeManager(renderer) diff --git a/src/core/renderers/webgl/managers/FilterManager.js b/src/core/renderers/webgl/managers/FilterManager.js index b22513d..7576ef3 100644 --- a/src/core/renderers/webgl/managers/FilterManager.js +++ b/src/core/renderers/webgl/managers/FilterManager.js @@ -6,6 +6,7 @@ /** * @class * @memberof PIXI + * @extends WebGLManager * @param renderer {WebGLRenderer} The renderer this manager works for. */ function FilterManager(renderer) @@ -41,6 +42,10 @@ module.exports = FilterManager; +/** + * Called when there is a WebGL context change. + * + */ FilterManager.prototype.onContextChange = function () { this.texturePool.length = 0; @@ -117,7 +122,7 @@ /** - * Removes the last filter from the filter stack and doesn't return it. + * Removes the last filter from the filter stack and returns it. * */ FilterManager.prototype.popFilter = function () @@ -192,6 +197,12 @@ return filterData.filter; }; +/** + * Grabs an render target from the internal pool + * + * @param clear {boolean} Whether or not we need to clear the RenderTarget + * @return {RenderTarget} + */ FilterManager.prototype.getRenderTarget = function ( clear ) { var renderTarget = this.texturePool.pop() || new RenderTarget(this.renderer.gl, this.textureSize.width, this.textureSize.height, null, this.renderer.resolution); @@ -205,11 +216,22 @@ return renderTarget; }; +/* + * Returns a RenderTarget to the internal pool + * @param renderTarget {RenderTarget} The RenderTarget we want to return to the pool + */ FilterManager.prototype.returnRenderTarget = function (renderTarget) { this.texturePool.push( renderTarget ); }; +/* + * Applies the filter + * @param shader {Shader} + * @param inputTarget {Any} + * @param outputTarget {Any} + * @param clear {boolean} Whether or not we want to clear the outputTarget + */ FilterManager.prototype.applyFilter = function (shader, inputTarget, outputTarget, clear) { var gl = this.renderer.gl; @@ -240,7 +262,12 @@ gl.drawElements(gl.TRIANGLES, 6, gl.UNSIGNED_SHORT, 0 ); }; - +/* + * Constrains the filter area to the texture size + * @param filterArea {Rectangle} The filter area + * @param sprite {Sprite} the target sprite + * @param outputMatrix {Matrix} @alvin + */ // TODO playing around here.. this is temporary - (will end up in the shader) FilterManager.prototype.calculateMappedMatrix = function (filterArea, sprite, outputMatrix) { @@ -308,6 +335,10 @@ // return transform; }; +/* + * Constrains the filter area to the texture size + * @param filterArea {Rectangle} The filter area we want to cap + */ FilterManager.prototype.capFilterArea = function (filterArea) { if (filterArea.x < 0) @@ -333,6 +364,11 @@ } }; +/* + * Resizes all the render targets in the pool + * @param width {number} the new width + * @param height {number} the new height + */ FilterManager.prototype.resize = function ( width, height ) { this.textureSize.width = width; diff --git a/src/core/renderers/webgl/managers/MaskManager.js b/src/core/renderers/webgl/managers/MaskManager.js index 472eea1..fbc8e9c 100644 --- a/src/core/renderers/webgl/managers/MaskManager.js +++ b/src/core/renderers/webgl/managers/MaskManager.js @@ -40,6 +40,12 @@ }; +/** + * Removes the last mask from the mask stack and doesn't return it. + * + * @param target {RenderTarget} + * @param maskData {any[]} + */ MaskManager.prototype.popMask = function (target, maskData) { if (maskData.texture) @@ -52,6 +58,12 @@ } }; +/** + * Applies the Mask and adds it to the current filter stack. + * + * @param target {RenderTarget} + * @param maskData {any[]} + */ MaskManager.prototype.pushSpriteMask = function (target, maskData) { var alphaMaskFilter = this.alphaMaskPool.pop(); @@ -79,9 +91,9 @@ /** * Applies the Mask and adds it to the current filter stack. * + * @param target {RenderTarget} * @param maskData {any[]} */ - MaskManager.prototype.pushStencilMask = function (target, maskData) { this.renderer.stencilManager.pushMask(maskData); @@ -89,7 +101,7 @@ /** * Removes the last filter from the filter stack and doesn't return it. - * + * @param target {RenderTarget} * @param maskData {any[]} */ MaskManager.prototype.popStencilMask = function (target, maskData) diff --git a/src/core/renderers/webgl/managers/ShaderManager.js b/src/core/renderers/webgl/managers/ShaderManager.js index 32dabf0..d3ee07a 100644 --- a/src/core/renderers/webgl/managers/ShaderManager.js +++ b/src/core/renderers/webgl/managers/ShaderManager.js @@ -7,6 +7,7 @@ /** * @class * @memberof PIXI + * @extends WebGLManager * @param renderer {WebGLRenderer} The renderer this manager works for. */ function ShaderManager(renderer) @@ -59,6 +60,10 @@ module.exports = ShaderManager; +/** + * Called when there is a WebGL context change. + * + */ ShaderManager.prototype.onContextChange = function () { this.initPlugins(); diff --git a/src/core/renderers/webgl/managers/WebGLManager.js b/src/core/renderers/webgl/managers/WebGLManager.js index 41ddec2..dfb5573 100644 --- a/src/core/renderers/webgl/managers/WebGLManager.js +++ b/src/core/renderers/webgl/managers/WebGLManager.js @@ -23,11 +23,19 @@ WebGLManager.prototype.constructor = WebGLManager; module.exports = WebGLManager; +/** + * Generic method called when there is a WebGL context change. + * + */ WebGLManager.prototype.onContextChange = function () { // do some codes init! }; +/** + * Generic destroy methods to be overridden by the subclass + * + */ WebGLManager.prototype.destroy = function () { this.renderer.off('context', this._onContextChangeFn); diff --git a/src/core/renderers/webgl/shaders/ComplexPrimitiveShader.js b/src/core/renderers/webgl/shaders/ComplexPrimitiveShader.js index e3b06ac..15fae67 100644 --- a/src/core/renderers/webgl/shaders/ComplexPrimitiveShader.js +++ b/src/core/renderers/webgl/shaders/ComplexPrimitiveShader.js @@ -3,6 +3,7 @@ /** * @class * @memberof PIXI + * @extends Shader * @param shaderManager {ShaderManager} The webgl shader manager this shader works for. */ function ComplexPrimitiveShader(shaderManager) diff --git a/src/core/renderers/webgl/shaders/PrimitiveShader.js b/src/core/renderers/webgl/shaders/PrimitiveShader.js index b7eed82..d89a547 100644 --- a/src/core/renderers/webgl/shaders/PrimitiveShader.js +++ b/src/core/renderers/webgl/shaders/PrimitiveShader.js @@ -3,6 +3,7 @@ /** * @class * @memberof PIXI + * @extends Shader * @param shaderManager {ShaderManager} The webgl shader manager this shader works for. */ function PrimitiveShader(shaderManager) diff --git a/src/core/renderers/webgl/shaders/Shader.js b/src/core/renderers/webgl/shaders/Shader.js index 9f25245..20079d7 100644 --- a/src/core/renderers/webgl/shaders/Shader.js +++ b/src/core/renderers/webgl/shaders/Shader.js @@ -37,10 +37,25 @@ */ this.program = null; + /** + * The uniforms as an object + * @member {object} + * @private + */ this.uniforms = uniforms || {}; + /** + * The attributes as an object + * @member {object} + * @private + */ this.attributes = attributes || {}; + /** + * Internal texture counter + * @member {number} + * @private + */ this.textureCount = 1; /** @@ -63,6 +78,10 @@ Shader.prototype.constructor = Shader; module.exports = Shader; +/* + * Creates the shader and uses it + * + */ Shader.prototype.init = function () { this.compile(); @@ -73,6 +92,10 @@ this.cacheAttributeLocations(Object.keys(this.attributes)); }; +/* + * Caches the locations of the uniform for reuse + * @param key {string} the uniform to cache + */ Shader.prototype.cacheUniformLocations = function (keys) { for (var i = 0; i < keys.length; ++i) @@ -81,6 +104,10 @@ } }; +/* + * Caches the locations of the attribute for reuse + * @param key {string} the attribute to cache + */ Shader.prototype.cacheAttributeLocations = function (keys) { for (var i = 0; i < keys.length; ++i) @@ -103,6 +130,9 @@ // End worst hack eva // }; +/* + * Attaches the shaders and creates the program + */ Shader.prototype.compile = function () { var gl = this.gl; @@ -119,14 +149,14 @@ // if linking fails, then log and cleanup if (!gl.getProgramParameter(program, gl.LINK_STATUS)) { - window.console.error('Pixi.js Error: Could not initialize shader.'); - window.console.error('gl.VALIDATE_STATUS', gl.getProgramParameter(program, gl.VALIDATE_STATUS)); - window.console.error('gl.getError()', gl.getError()); + console.error('Pixi.js Error: Could not initialize shader.'); + console.error('gl.VALIDATE_STATUS', gl.getProgramParameter(program, gl.VALIDATE_STATUS)); + console.error('gl.getError()', gl.getError()); // if there is a program info log, log it if (gl.getProgramInfoLog(program) !== '') { - window.console.warn('Pixi.js Warning: gl.getProgramInfoLog()', gl.getProgramInfoLog(program)); + console.warn('Pixi.js Warning: gl.getProgramInfoLog()', gl.getProgramInfoLog(program)); } gl.deleteProgram(program); @@ -176,6 +206,11 @@ }*/ +/** +* Adds a new uniform +* +* @param uniform {Object} the new uniform to attach +*/ Shader.prototype.syncUniform = function (uniform) { var location = uniform._location, @@ -407,6 +442,9 @@ } }; +/* + * Updates the shader uniform values. + */ Shader.prototype.syncUniforms = function () { this.textureCount = 1; diff --git a/src/core/renderers/webgl/shaders/TextureShader.js b/src/core/renderers/webgl/shaders/TextureShader.js index 7e30f83..000463f 100644 --- a/src/core/renderers/webgl/shaders/TextureShader.js +++ b/src/core/renderers/webgl/shaders/TextureShader.js @@ -3,6 +3,7 @@ /** * @class * @memberof PIXI + * @extends Shader * @param shaderManager {ShaderManager} The webgl shader manager this shader works for. * @param [vertexSrc] {string} The source of the vertex shader. * @param [fragmentSrc] {string} The source of the fragment shader. diff --git a/src/core/renderers/webgl/utils/RenderTarget.js b/src/core/renderers/webgl/utils/RenderTarget.js index 24585ed..4e63203 100644 --- a/src/core/renderers/webgl/utils/RenderTarget.js +++ b/src/core/renderers/webgl/utils/RenderTarget.js @@ -12,49 +12,81 @@ * @class * @memberof PIXI * @param gl {WebGLRenderingContext} the current WebGL drawing context - * @param width {Number} the horizontal range of the filter - * @param height {Number} the vertical range of the filter - * @param scaleMode {Number} See {{#crossLink "PIXI/scaleModes:property"}}PIXI.scaleModes{{/crossLink}} for possible values + * @param width {number} the horizontal range of the filter + * @param height {number} the vertical range of the filter + * @param scaleMode {number} See {{#crossLink "PIXI/scaleModes:property"}}PIXI.scaleModes{{/crossLink}} for possible values + * @param resolution {number} the current resolution + * @param root {boolean} Whether this object is the root element or not */ var RenderTarget = function(gl, width, height, scaleMode, resolution, root) { //TODO Resolution could go here ( eg low res blurs ) /** - * @property gl - * @type WebGLRenderingContext + * The current WebGL drawing context + * member {WebGLRenderingContext} */ this.gl = gl; // next time to create a frame buffer and texture /** - * @property frameBuffer - * @type Any + * A frame buffer + * @member {WebGLFrameBuffer} */ this.frameBuffer = null; /** - * @property texture - * @type Any + * @member {Texture} */ this.texture = null; + /** + * The size of the object as a rectangle + * @member {Rectangle} + */ this.size = new math.Rectangle(0, 0, 1, 1); + /** + * The current resolution + * @member {number} + */ this.resolution = resolution || CONST.RESOLUTION; + /** + * The projection matrix + * @member {Matrix} + */ this.projectionMatrix = new math.Matrix(); + /** + * The object's transform + * @member {Matrix} + */ this.transform = null; + /** + * + * @member {Rectangle} + */ this.frame = null; - // stores masking data for the render target + /** + * The stencil buffer stores masking data for the render target + * @member {WebGLRenderBuffer} + */ this.stencilBuffer = null; + + /** + * The data structure for the stencil masks + * @member {StencilMaskStack} + */ this.stencilMaskStack = new StencilMaskStack(); - // stores filter data for the render target + /** + * Stores filter data for the render target + * @member {Array} + */ this.filterStack = [ { renderTarget:this, @@ -65,11 +97,16 @@ /** - * @property scaleMode - * @type Number + * The scale mode + * @member {number} + * @default CONST.SCALE_MODES.DEFAULT */ this.scaleMode = scaleMode || CONST.SCALE_MODES.DEFAULT; + /** + * Whether this object is the root element or not + * @member {boolean} + */ this.root = root; if (!this.root) @@ -129,6 +166,10 @@ gl.clear(gl.COLOR_BUFFER_BIT); }; +/** +* Binds the stencil buffer. +* +*/ RenderTarget.prototype.attachStencilBuffer = function() { @@ -152,6 +193,10 @@ } }; +/** +* Binds the buffers and initialises the viewport. +* +*/ RenderTarget.prototype.activate = function() { //TOOD refactor usage of frame.. @@ -172,6 +217,10 @@ gl.viewport(0,0, projectionFrame.width * this.resolution, projectionFrame.height * this.resolution); }; +/** +* Updates the projection matrix based on a projection frame (which is a rectangle) +* +*/ RenderTarget.prototype.calculateProjection = function( projectionFrame ) { var pm = this.projectionMatrix; @@ -237,7 +286,7 @@ }; /** - * Destroys the filter texture. + * Destroys the render target. * */ RenderTarget.prototype.destroy = function() diff --git a/src/core/renderers/webgl/utils/StencilMaskStack.js b/src/core/renderers/webgl/utils/StencilMaskStack.js index fb8940e..d7a78ff 100644 --- a/src/core/renderers/webgl/utils/StencilMaskStack.js +++ b/src/core/renderers/webgl/utils/StencilMaskStack.js @@ -1,4 +1,5 @@ /** + * Generic Mask Stack data structure * @class * @memberof PIXI * @param renderer {WebGLRenderer} The renderer this manager works for. diff --git a/src/interaction/InteractionManager.js b/src/interaction/InteractionManager.js index 0680bf9..b60face 100644 --- a/src/interaction/InteractionManager.js +++ b/src/interaction/InteractionManager.js @@ -725,8 +725,8 @@ /** * Grabs an interaction data object from the internal pool - * - * @param touchEvent {} The touch event we need to pair with a touchData object + * + * @param touchEvent {Event @alvin} The touch event we need to pair with a touchData object * * @private */ @@ -748,7 +748,7 @@ /** * Returns an interaction data object to the internal pool * - * @param touchEvent {InteractionData} The touch data object we want to return to the pool + * @param touchData {InteractionData} The touch data object we want to return to the pool * * @private */ @@ -757,7 +757,5 @@ this.interactiveDataPool.push( touchData ); }; - - core.WebGLRenderer.registerPlugin('interaction', InteractionManager); core.CanvasRenderer.registerPlugin('interaction', InteractionManager);