Skip to content

Commit

Permalink
Merge pull request #1842 from hightopo/fix-mask-filter-bug
Browse files Browse the repository at this point in the history
Fix mask combine filter bug
  • Loading branch information
photonstorm committed Feb 4, 2016
2 parents af4c938 + 6f5d4b9 commit 2a94883
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion src/pixi/renderers/webgl/utils/WebGLFilterManager.js
Expand Up @@ -73,7 +73,14 @@ PIXI.WebGLFilterManager.prototype.pushFilter = function(filterBlock)
var offset = this.renderSession.offset;

filterBlock._filterArea = filterBlock.target.filterArea || filterBlock.target.getBounds();


// >>> modify by nextht
filterBlock._previous_stencil_mgr = this.renderSession.stencilManager;
this.renderSession.stencilManager = new PIXI.WebGLStencilManager();
this.renderSession.stencilManager.setContext(gl);
gl.disable(gl.STENCIL_TEST);
// <<< modify by nextht

// filter program
// OPTIMISATION - the first filter is free if its a simple color change?
this.filterStack.push(filterBlock);
Expand Down Expand Up @@ -298,6 +305,20 @@ PIXI.WebGLFilterManager.prototype.popFilter = function()
gl.activeTexture(gl.TEXTURE0);
gl.bindTexture(gl.TEXTURE_2D, texture.texture);

// >>> modify by nextht
if (this.renderSession.stencilManager) {
this.renderSession.stencilManager.destroy();
}
this.renderSession.stencilManager = filterBlock._previous_stencil_mgr;
filterBlock._previous_stencil_mgr = null;
if (this.renderSession.stencilManager.count > 0) {
gl.enable(gl.STENCIL_TEST);
}
else {
gl.disable(gl.STENCIL_TEST);
}
// <<< modify by nextht

// apply!
this.applyFilterPass(filter, filterArea, sizeX, sizeY);

Expand Down

0 comments on commit 2a94883

Please sign in to comment.