OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "GrSWMaskHelper.h" | 8 #include "GrSWMaskHelper.h" |
9 #include "GrDrawState.h" | 9 #include "GrDrawState.h" |
10 #include "GrGpu.h" | 10 #include "GrGpu.h" |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 void GrSWMaskHelper::DrawToTargetWithPathMask(GrTexture* texture, | 185 void GrSWMaskHelper::DrawToTargetWithPathMask(GrTexture* texture, |
186 GrDrawTarget* target, | 186 GrDrawTarget* target, |
187 const GrIRect& rect) { | 187 const GrIRect& rect) { |
188 GrDrawState* drawState = target->drawState(); | 188 GrDrawState* drawState = target->drawState(); |
189 | 189 |
190 GrDrawState::AutoViewMatrixRestore avmr; | 190 GrDrawState::AutoViewMatrixRestore avmr; |
191 if (!avmr.setIdentity(drawState)) { | 191 if (!avmr.setIdentity(drawState)) { |
192 return; | 192 return; |
193 } | 193 } |
194 GrDrawState::AutoRestoreEffects are(drawState); | 194 GrDrawState::AutoRestoreEffects are(drawState); |
195 enum { | |
196 // the SW path renderer shares this stage with glyph | |
197 // rendering (kGlyphMaskStage in GrTextContext) | |
198 // && edge rendering (kEdgeEffectStage in GrContext) | |
199 kPathMaskStage = GrPaint::kTotalStages, | |
200 }; | |
201 | 195 |
202 GrRect dstRect = GrRect::MakeLTRB( | 196 GrRect dstRect = GrRect::MakeLTRB( |
203 SK_Scalar1 * rect.fLeft, | 197 SK_Scalar1 * rect.fLeft, |
204 SK_Scalar1 * rect.fTop, | 198 SK_Scalar1 * rect.fTop, |
205 SK_Scalar1 * rect.fRight, | 199 SK_Scalar1 * rect.fRight, |
206 SK_Scalar1 * rect.fBottom); | 200 SK_Scalar1 * rect.fBottom); |
207 | 201 |
208 // We want to use device coords to compute the texture coordinates. We set o
ur matrix to be | 202 // We want to use device coords to compute the texture coordinates. We set o
ur matrix to be |
209 // equal to the view matrix followed by a translation so that the top-left o
f the device bounds | 203 // equal to the view matrix followed by a translation so that the top-left o
f the device bounds |
210 // maps to 0,0, and then a scaling matrix to normalized coords. We apply thi
s matrix to the | 204 // maps to 0,0, and then a scaling matrix to normalized coords. We apply thi
s matrix to the |
211 // vertex positions rather than local coords. | 205 // vertex positions rather than local coords. |
212 SkMatrix maskMatrix; | 206 SkMatrix maskMatrix; |
213 maskMatrix.setIDiv(texture->width(), texture->height()); | 207 maskMatrix.setIDiv(texture->width(), texture->height()); |
214 maskMatrix.preTranslate(SkIntToScalar(-rect.fLeft), SkIntToScalar(-rect.fTop
)); | 208 maskMatrix.preTranslate(SkIntToScalar(-rect.fLeft), SkIntToScalar(-rect.fTop
)); |
215 maskMatrix.preConcat(drawState->getViewMatrix()); | 209 maskMatrix.preConcat(drawState->getViewMatrix()); |
216 | 210 |
217 drawState->addCoverageEffect( | 211 drawState->addCoverageEffect( |
218 GrSimpleTextureEffect::Create(texture, | 212 GrSimpleTextureEffect::Create(texture, |
219 maskMatrix, | 213 maskMatrix, |
220 false, | 214 false, |
221 GrEffect::kPosition_Coord
sType))->unref(); | 215 GrEffect::kPosition_Coord
sType))->unref(); |
222 | 216 |
223 target->drawSimpleRect(dstRect); | 217 target->drawSimpleRect(dstRect); |
224 } | 218 } |
OLD | NEW |