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 | 9 |
10 #include "GrCaps.h" | 10 #include "GrCaps.h" |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 return nullptr; | 152 return nullptr; |
153 } | 153 } |
154 | 154 |
155 helper.toTexture(texture); | 155 helper.toTexture(texture); |
156 | 156 |
157 return texture; | 157 return texture; |
158 } | 158 } |
159 | 159 |
160 void GrSWMaskHelper::DrawToTargetWithShapeMask(GrTexture* texture, | 160 void GrSWMaskHelper::DrawToTargetWithShapeMask(GrTexture* texture, |
161 GrDrawContext* drawContext, | 161 GrDrawContext* drawContext, |
162 const GrPaint* paint, | 162 const GrPaint& paint, |
163 const GrUserStencilSettings* user
StencilSettings, | 163 const GrUserStencilSettings* user
StencilSettings, |
164 const GrClip& clip, | 164 const GrClip& clip, |
165 GrColor color, | |
166 const SkMatrix& viewMatrix, | 165 const SkMatrix& viewMatrix, |
167 const SkIRect& rect) { | 166 const SkIRect& rect) { |
168 SkMatrix invert; | 167 SkMatrix invert; |
169 if (!viewMatrix.invert(&invert)) { | 168 if (!viewMatrix.invert(&invert)) { |
170 return; | 169 return; |
171 } | 170 } |
172 | 171 |
173 SkRect dstRect = SkRect::MakeLTRB(SK_Scalar1 * rect.fLeft, | 172 SkRect dstRect = SkRect::MakeLTRB(SK_Scalar1 * rect.fLeft, |
174 SK_Scalar1 * rect.fTop, | 173 SK_Scalar1 * rect.fTop, |
175 SK_Scalar1 * rect.fRight, | 174 SK_Scalar1 * rect.fRight, |
176 SK_Scalar1 * rect.fBottom); | 175 SK_Scalar1 * rect.fBottom); |
177 | 176 |
178 // We use device coords to compute the texture coordinates. We take the devi
ce coords and apply | 177 // We use device coords to compute the texture coordinates. We take the devi
ce coords and apply |
179 // a translation so that the top-left of the device bounds maps to 0,0, and
then a scaling | 178 // a translation so that the top-left of the device bounds maps to 0,0, and
then a scaling |
180 // matrix to normalized coords. | 179 // matrix to normalized coords. |
181 SkMatrix maskMatrix; | 180 SkMatrix maskMatrix; |
182 maskMatrix.setIDiv(texture->width(), texture->height()); | 181 maskMatrix.setIDiv(texture->width(), texture->height()); |
183 maskMatrix.preTranslate(SkIntToScalar(-rect.fLeft), SkIntToScalar(-rect.fTop
)); | 182 maskMatrix.preTranslate(SkIntToScalar(-rect.fLeft), SkIntToScalar(-rect.fTop
)); |
184 | 183 |
185 GrPipelineBuilder pipelineBuilder(*paint, drawContext->mustUseHWAA(*paint)); | 184 GrPipelineBuilder pipelineBuilder(paint, drawContext->mustUseHWAA(paint)); |
186 pipelineBuilder.setUserStencil(userStencilSettings); | 185 pipelineBuilder.setUserStencil(userStencilSettings); |
187 | 186 |
188 pipelineBuilder.addCoverageFragmentProcessor( | 187 pipelineBuilder.addCoverageFragmentProcessor( |
189 GrSimpleTextureEffect::Make(texture, | 188 GrSimpleTextureEffect::Make(texture, |
190 maskMatrix, | 189 maskMatrix, |
191 GrTextureParams::kNone_Filt
erMode, | 190 GrTextureParams::kNone_Filt
erMode, |
192 kDevice_GrCoordSet)); | 191 kDevice_GrCoordSet)); |
193 | 192 |
194 SkAutoTUnref<GrDrawBatch> batch(GrRectBatchFactory::CreateNonAAFill(color, S
kMatrix::I(), | 193 SkAutoTUnref<GrDrawBatch> batch(GrRectBatchFactory::CreateNonAAFill(paint.ge
tColor(), |
| 194 SkMatrix
::I(), |
195 dstRect,
nullptr, &invert)); | 195 dstRect,
nullptr, &invert)); |
196 drawContext->drawBatch(pipelineBuilder, clip, batch); | 196 drawContext->drawBatch(pipelineBuilder, clip, batch); |
197 } | 197 } |
OLD | NEW |