|
57 | 57 | }
|
58 | 58 |
|
59 | 59 | stencil._renderCmd.rendering = function (ctx, scaleX, scaleY) {
|
60 |
| - scaleX = scaleX || cc.view.getScaleX(); |
61 |
| - scaleY = scaleY ||cc.view.getScaleY(); |
62 |
| - var wrapper = ctx || cc._renderContext, context = wrapper.getContext(); |
| 60 | + //make it do nothing and draw it in clipp render command |
| 61 | + return; |
| 62 | + }; |
63 | 63 |
|
64 |
| - var t = this._transform; |
65 |
| - context.transform(t.a, t.b, t.c, t.d, t.tx * scaleX, -t.ty * scaleY); |
66 |
| - for (var i = 0; i < stencil._buffer.length; i++) { |
67 |
| - var vertices = stencil._buffer[i].verts; |
68 |
| - //TODO: need support circle etc |
69 |
| - //cc.assert(cc.vertexListIsClockwise(vertices), |
70 |
| - // "Only clockwise polygons should be used as stencil"); |
| 64 | + stencil._renderCmd._canUseDirtyRegion = true; |
| 65 | + this._rendererSaveCmd._canUseDirtyRegion = true; |
| 66 | + this._rendererClipCmd._canUseDirtyRegion = true; |
| 67 | + this._rendererRestoreCmd._canUseDirtyRegion = true; |
71 | 68 |
|
72 |
| - var firstPoint = vertices[0]; |
73 |
| - context.moveTo(firstPoint.x * scaleX, -firstPoint.y * scaleY); |
74 |
| - for (var j = vertices.length - 1; j > 0; j--) |
75 |
| - context.lineTo(vertices[j].x * scaleX, -vertices[j].y * scaleY); |
76 |
| - } |
77 |
| - }; |
78 | 69 | }else{
|
79 | 70 | stencil._parent = this._node;
|
80 | 71 | }
|
|
92 | 83 | locCacheCtx.drawImage(canvas, 0, 0); //save the result to shareCache canvas
|
93 | 84 | } else {
|
94 | 85 | wrapper.save();
|
95 |
| - context.beginPath(); //save for clip |
96 | 86 | //Because drawNode's content size is zero
|
97 | 87 | wrapper.setTransform(this._worldTransform, scaleX, scaleY);
|
98 | 88 |
|
99 | 89 | if (this._node.inverted) {
|
| 90 | + context.beginPath(); //save for clip |
100 | 91 | context.rect(0, 0, context.canvas.width, -context.canvas.height);
|
101 | 92 | context.clip();
|
102 | 93 | }
|
|
126 | 117 | //hack
|
127 | 118 | this._setStencilCompositionOperation(node._stencil);
|
128 | 119 | } else {
|
| 120 | + var stencil = this._node._stencil; |
| 121 | + if(stencil instanceof cc.DrawNode) { |
| 122 | + context.beginPath(); |
| 123 | + var t = stencil._renderCmd._transform; |
| 124 | + context.transform(t.a, t.b, t.c, t.d, t.tx, -t.ty); |
| 125 | + for (var i = 0; i < stencil._buffer.length; i++) { |
| 126 | + var vertices = stencil._buffer[i].verts; |
| 127 | + //TODO: need support circle etc |
| 128 | + //cc.assert(cc.vertexListIsClockwise(vertices), |
| 129 | + // "Only clockwise polygons should be used as stencil"); |
| 130 | + |
| 131 | + var firstPoint = vertices[0]; |
| 132 | + context.moveTo(firstPoint.x , -firstPoint.y ); |
| 133 | + for (var j = vertices.length - 1; j > 0; j--) |
| 134 | + context.lineTo(vertices[j].x , -vertices[j].y ); |
| 135 | + } |
| 136 | + } |
129 | 137 | context.clip();
|
130 | 138 | }
|
131 | 139 | };
|
|
0 commit comments