diff --git a/cocos2d/core/components/CCMask.js b/cocos2d/core/components/CCMask.js index a242d8b3d3..f20ef0fba2 100644 --- a/cocos2d/core/components/CCMask.js +++ b/cocos2d/core/components/CCMask.js @@ -241,6 +241,7 @@ let Mask = cc.Class({ this._graphics = new Graphics(); this._graphics.node = this.node; this._graphics.lineWidth = 0; + this._graphics.strokeColor = cc.color(0, 0, 0, 0); }, onRestore () { @@ -393,7 +394,12 @@ let Mask = cc.Class({ ry = height / 2; graphics.ellipse(cx, cy, rx, ry); } - graphics.fill(); + if (cc.game.renderType === cc.game.RENDER_TYPE_CANVAS) { + graphics.stroke(); + } + else { + graphics.fill(); + } }, _hitTest (cameraPt) { diff --git a/cocos2d/core/components/WXSubContextView.js b/cocos2d/core/components/WXSubContextView.js index ea22559628..5b313410c9 100644 --- a/cocos2d/core/components/WXSubContextView.js +++ b/cocos2d/core/components/WXSubContextView.js @@ -82,11 +82,13 @@ else { sharedCanvas.width = this.node.width; sharedCanvas.height = this.node.height; } + this._tex.setPremultiplyAlpha(true); this._tex.initWithElement(sharedCanvas); this._sprite = this.node.getComponent(cc.Sprite); if (!this._sprite) { this._sprite = this.node.addComponent(cc.Sprite); + this._sprite.srcBlendFactor = cc.macro.BlendFactor.ONE; } this._sprite.spriteFrame = new cc.SpriteFrame(this._tex); } diff --git a/cocos2d/core/renderer/canvas/renderers/mask.js b/cocos2d/core/renderer/canvas/renderers/mask.js index 0d368a867f..80c10f533b 100644 --- a/cocos2d/core/renderer/canvas/renderers/mask.js +++ b/cocos2d/core/renderer/canvas/renderers/mask.js @@ -23,48 +23,11 @@ THE SOFTWARE. ****************************************************************************/ -const Node = require('../../../CCNode'); const Mask = require('../../../components/CCMask'); -const Graphics = require('../../../graphics/graphics'); const graphicsHandler = require('./graphics'); -// for nested mask, we might need multiple graphics component to avoid data conflict -let _graphicsPool = []; - -function getGraphics () { - let graphics = _graphicsPool.pop(); - - if (!graphics) { - let graphicsNode = new Node(); - graphics = graphicsNode.addComponent(Graphics); - graphics.lineWidth = 0; - } - return graphics; -} - let beforeHandler = { updateRenderData (comp) {}, - updateGraphics (mask) { - let node = mask.node; - let graphics = mask._graphics; - // Share render data with graphics content - graphics.clear(false); - let width = node.width; - let height = node.height; - let x = -width * node.anchorX; - let y = -height * node.anchorY; - if (mask._type === Mask.Type.RECT) { - graphics.rect(x, y, width, height); - } - else if (mask._type === Mask.Type.ELLIPSE) { - let cx = x + width / 2, - cy = y + height / 2, - rx = width / 2, - ry = height / 2; - graphics.ellipse(cx, cy, rx, ry); - } - graphics.stroke(); - }, draw (ctx, mask) { let node = mask.node; @@ -74,11 +37,8 @@ let beforeHandler = { tx = matrix.m12, ty = matrix.m13; ctx.save(); - ctx.transform(a, b, c, d, tx, -ty); // draw stencil - mask._graphics = getGraphics(); - this.updateGraphics(mask); graphicsHandler.draw(ctx, mask._graphics); ctx.clip();