OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2012 Google Inc. | 3 * Copyright 2012 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 #include "GrStencilAndCoverPathRenderer.h" | 10 #include "GrStencilAndCoverPathRenderer.h" |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 0xffff, | 114 0xffff, |
115 0x0000, | 115 0x0000, |
116 0xffff); | 116 0xffff); |
117 | 117 |
118 drawState->setStencil(kInvertedStencilPass); | 118 drawState->setStencil(kInvertedStencilPass); |
119 | 119 |
120 // fake inverse with a stencil and cover | 120 // fake inverse with a stencil and cover |
121 SkAutoTUnref<GrPathProcessor> pp(GrPathProcessor::Create(GrColor_WHITE))
; | 121 SkAutoTUnref<GrPathProcessor> pp(GrPathProcessor::Create(GrColor_WHITE))
; |
122 target->stencilPath(drawState, pp, p, convert_skpath_filltype(path.getFi
llType())); | 122 target->stencilPath(drawState, pp, p, convert_skpath_filltype(path.getFi
llType())); |
123 | 123 |
| 124 SkMatrix invert = SkMatrix::I(); |
124 GrDrawState::AutoViewMatrixRestore avmr; | 125 GrDrawState::AutoViewMatrixRestore avmr; |
125 SkRect bounds = SkRect::MakeLTRB(0, 0, | 126 SkRect bounds = SkRect::MakeLTRB(0, 0, |
126 SkIntToScalar(drawState->getRenderTarge
t()->width()), | 127 SkIntToScalar(drawState->getRenderTarge
t()->width()), |
127 SkIntToScalar(drawState->getRenderTarge
t()->height())); | 128 SkIntToScalar(drawState->getRenderTarge
t()->height())); |
128 SkMatrix vmi; | 129 SkMatrix vmi; |
129 // mapRect through persp matrix may not be correct | 130 // mapRect through persp matrix may not be correct |
130 if (!drawState->getViewMatrix().hasPerspective() && drawState->getViewIn
verse(&vmi)) { | 131 if (!drawState->getViewMatrix().hasPerspective() && drawState->getViewIn
verse(&vmi)) { |
131 vmi.mapRect(&bounds); | 132 vmi.mapRect(&bounds); |
132 // theoretically could set bloat = 0, instead leave it because of ma
trix inversion | 133 // theoretically could set bloat = 0, instead leave it because of ma
trix inversion |
133 // precision. | 134 // precision. |
134 SkScalar bloat = drawState->getViewMatrix().getMaxScale() * SK_Scala
rHalf; | 135 SkScalar bloat = drawState->getViewMatrix().getMaxScale() * SK_Scala
rHalf; |
135 bounds.outset(bloat, bloat); | 136 bounds.outset(bloat, bloat); |
136 } else { | 137 } else { |
| 138 if (!drawState->getViewMatrix().invert(&invert)) { |
| 139 return false; |
| 140 } |
137 avmr.setIdentity(drawState); | 141 avmr.setIdentity(drawState); |
138 } | 142 } |
139 target->drawSimpleRect(drawState, color, bounds); | 143 target->drawRect(drawState, color, bounds, NULL, &invert); |
140 } else { | 144 } else { |
141 GR_STATIC_CONST_SAME_STENCIL(kStencilPass, | 145 GR_STATIC_CONST_SAME_STENCIL(kStencilPass, |
142 kZero_StencilOp, | 146 kZero_StencilOp, |
143 kZero_StencilOp, | 147 kZero_StencilOp, |
144 kNotEqual_StencilFunc, | 148 kNotEqual_StencilFunc, |
145 0xffff, | 149 0xffff, |
146 0x0000, | 150 0x0000, |
147 0xffff); | 151 0xffff); |
148 | 152 |
149 drawState->setStencil(kStencilPass); | 153 drawState->setStencil(kStencilPass); |
150 SkAutoTUnref<GrPathProcessor> pp(GrPathProcessor::Create(color)); | 154 SkAutoTUnref<GrPathProcessor> pp(GrPathProcessor::Create(color)); |
151 target->drawPath(drawState, pp, p, convert_skpath_filltype(path.getFillT
ype())); | 155 target->drawPath(drawState, pp, p, convert_skpath_filltype(path.getFillT
ype())); |
152 } | 156 } |
153 | 157 |
154 drawState->stencil()->setDisabled(); | 158 drawState->stencil()->setDisabled(); |
155 return true; | 159 return true; |
156 } | 160 } |
OLD | NEW |