diff --git a/src/core/graphics/Graphics.js b/src/core/graphics/Graphics.js index d0a9083..3915985 100644 --- a/src/core/graphics/Graphics.js +++ b/src/core/graphics/Graphics.js @@ -676,6 +676,13 @@ return this; }; +/** + * True if graphics consists of one rectangle, and thus, can be drawn like a Sprite and masked with gl.scissor + * @returns {boolean} + */ +Graphics.prototype.isFastRect = function() { + return this.graphicsData.length === 1 && this.graphicsData[0].shape.type === CONST.SHAPES.RECT && !this.graphicsData[0].lineWidth; +}; /** * Renders the object using the WebGL renderer @@ -691,7 +698,7 @@ { this.dirty = true; this.glDirty = false; - this._fastRect = this.graphicsData.length === 1 && this.graphicsData[0].shape.type === CONST.SHAPES.RECT && !this.graphicsData[0].lineWidth; + this._fastRect = this.isFastRect(); } //TODO this check can be moved to dirty? diff --git a/src/core/graphics/Graphics.js b/src/core/graphics/Graphics.js index d0a9083..3915985 100644 --- a/src/core/graphics/Graphics.js +++ b/src/core/graphics/Graphics.js @@ -676,6 +676,13 @@ return this; }; +/** + * True if graphics consists of one rectangle, and thus, can be drawn like a Sprite and masked with gl.scissor + * @returns {boolean} + */ +Graphics.prototype.isFastRect = function() { + return this.graphicsData.length === 1 && this.graphicsData[0].shape.type === CONST.SHAPES.RECT && !this.graphicsData[0].lineWidth; +}; /** * Renders the object using the WebGL renderer @@ -691,7 +698,7 @@ { this.dirty = true; this.glDirty = false; - this._fastRect = this.graphicsData.length === 1 && this.graphicsData[0].shape.type === CONST.SHAPES.RECT && !this.graphicsData[0].lineWidth; + this._fastRect = this.isFastRect(); } //TODO this check can be moved to dirty? diff --git a/src/core/renderers/webgl/managers/MaskManager.js b/src/core/renderers/webgl/managers/MaskManager.js index 6aa6d83..c0332b3 100644 --- a/src/core/renderers/webgl/managers/MaskManager.js +++ b/src/core/renderers/webgl/managers/MaskManager.js @@ -29,7 +29,7 @@ * Applies the Mask and adds it to the current filter stack. * * @param target {PIXI.DisplayObject} Display Object to push the mask to - * @param maskData {Array<*>} + * @param maskData {PIXI.Sprite|PIXI.Graphics} */ MaskManager.prototype.pushMask = function (target, maskData) { @@ -39,7 +39,7 @@ } else { - if(this.enableScissor && !this.scissor && !this.renderer.stencilManager.stencilMaskStack.length && maskData.graphicsData[0].shape.type === 1) + if(this.enableScissor && !this.scissor && !this.renderer.stencilManager.stencilMaskStack.length && maskData.isFastRect()) { var matrix = maskData.worldTransform;