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 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 const SkMatrix& viewMatrix, | 165 const SkMatrix& viewMatrix, |
166 const SkIRect& rect) { | 166 const SkIRect& rect) { |
167 SkMatrix invert; | 167 SkMatrix invert; |
168 if (!viewMatrix.invert(&invert)) { | 168 if (!viewMatrix.invert(&invert)) { |
169 return; | 169 return; |
170 } | 170 } |
171 | 171 |
172 SkRect dstRect = SkRect::MakeLTRB(SK_Scalar1 * rect.fLeft, | 172 SkRect dstRect = SkRect::MakeLTRB(SK_Scalar1 * rect.fLeft, |
173 SK_Scalar1 * rect.fTop, | 173 SK_Scalar1 * rect.fTop, |
174 SK_Scalar1 * rect.fRight, | 174 SK_Scalar1 * rect.fRight, |
175 SK_Scalar1 * rect.fBottom); | 175 SK_Scalar1 * rect.fBottom); |
176 | 176 |
177 // 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 |
178 // 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 |
179 // matrix to normalized coords. | 179 // matrix to normalized coords. |
180 SkMatrix maskMatrix; | 180 SkMatrix maskMatrix; |
181 maskMatrix.setIDiv(texture->width(), texture->height()); | 181 maskMatrix.setIDiv(texture->width(), texture->height()); |
182 maskMatrix.preTranslate(SkIntToScalar(-rect.fLeft), SkIntToScalar(-rect.fTop
)); | 182 maskMatrix.preTranslate(SkIntToScalar(-rect.fLeft), SkIntToScalar(-rect.fTop
)); |
183 | 183 |
184 GrPipelineBuilder pipelineBuilder(paint, drawContext->mustUseHWAA(paint)); | 184 GrPipelineBuilder pipelineBuilder(paint, drawContext->mustUseHWAA(paint)); |
185 pipelineBuilder.setUserStencil(userStencilSettings); | 185 pipelineBuilder.setUserStencil(&userStencilSettings); |
186 | 186 |
187 pipelineBuilder.addCoverageFragmentProcessor( | 187 pipelineBuilder.addCoverageFragmentProcessor( |
188 GrSimpleTextureEffect::Make(texture, | 188 GrSimpleTextureEffect::Make(texture, |
189 nullptr, | 189 nullptr, |
190 maskMatrix, | 190 maskMatrix, |
191 GrTextureParams::kNone_Filt
erMode, | 191 GrTextureParams::kNone_Filt
erMode, |
192 kDevice_GrCoordSet)); | 192 kDevice_GrCoordSet)); |
193 | 193 |
194 SkAutoTUnref<GrDrawBatch> batch(GrRectBatchFactory::CreateNonAAFill(paint.ge
tColor(), | 194 SkAutoTUnref<GrDrawBatch> batch(GrRectBatchFactory::CreateNonAAFill(paint.ge
tColor(), |
195 SkMatrix
::I(), | 195 SkMatrix
::I(), |
196 dstRect,
nullptr, &invert)); | 196 dstRect,
nullptr, &invert)); |
197 drawContext->drawBatch(pipelineBuilder, clip, batch); | 197 drawContext->drawBatch(pipelineBuilder, clip, batch); |
198 } | 198 } |
OLD | NEW |