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" |
11 #include "GrDrawTarget.h" | 11 #include "GrContext.h" |
| 12 #include "batches/GrDrawBatch.h" |
| 13 #include "GrDrawContext.h" |
12 #include "GrGpu.h" | 14 #include "GrGpu.h" |
13 #include "GrPipelineBuilder.h" | 15 #include "GrPipelineBuilder.h" |
14 #include "GrStyle.h" | 16 #include "GrStyle.h" |
15 | 17 |
16 #include "SkData.h" | 18 #include "SkData.h" |
17 #include "SkDistanceFieldGen.h" | 19 #include "SkDistanceFieldGen.h" |
18 #include "SkStrokeRec.h" | 20 #include "SkStrokeRec.h" |
19 | 21 |
20 #include "batches/GrRectBatchFactory.h" | 22 #include "batches/GrRectBatchFactory.h" |
21 | 23 |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 if (!texture) { | 154 if (!texture) { |
153 return nullptr; | 155 return nullptr; |
154 } | 156 } |
155 | 157 |
156 helper.toTexture(texture); | 158 helper.toTexture(texture); |
157 | 159 |
158 return texture; | 160 return texture; |
159 } | 161 } |
160 | 162 |
161 void GrSWMaskHelper::DrawToTargetWithPathMask(GrTexture* texture, | 163 void GrSWMaskHelper::DrawToTargetWithPathMask(GrTexture* texture, |
162 GrDrawTarget* target, | 164 GrDrawContext* drawContext, |
163 GrPipelineBuilder* pipelineBuilder
, | 165 const GrPaint* paint, |
| 166 const GrUserStencilSettings* userS
tencilSettings, |
164 const GrClip& clip, | 167 const GrClip& clip, |
165 GrColor color, | 168 GrColor color, |
166 const SkMatrix& viewMatrix, | 169 const SkMatrix& viewMatrix, |
167 const SkIRect& rect) { | 170 const SkIRect& rect) { |
168 SkMatrix invert; | 171 SkMatrix invert; |
169 if (!viewMatrix.invert(&invert)) { | 172 if (!viewMatrix.invert(&invert)) { |
170 return; | 173 return; |
171 } | 174 } |
172 GrPipelineBuilder::AutoRestoreFragmentProcessorState arfps(*pipelineBuilder)
; | |
173 | 175 |
174 SkRect dstRect = SkRect::MakeLTRB(SK_Scalar1 * rect.fLeft, | 176 SkRect dstRect = SkRect::MakeLTRB(SK_Scalar1 * rect.fLeft, |
175 SK_Scalar1 * rect.fTop, | 177 SK_Scalar1 * rect.fTop, |
176 SK_Scalar1 * rect.fRight, | 178 SK_Scalar1 * rect.fRight, |
177 SK_Scalar1 * rect.fBottom); | 179 SK_Scalar1 * rect.fBottom); |
178 | 180 |
179 // We use device coords to compute the texture coordinates. We take the devi
ce coords and apply | 181 // We use device coords to compute the texture coordinates. We take the devi
ce coords and apply |
180 // a translation so that the top-left of the device bounds maps to 0,0, and
then a scaling | 182 // a translation so that the top-left of the device bounds maps to 0,0, and
then a scaling |
181 // matrix to normalized coords. | 183 // matrix to normalized coords. |
182 SkMatrix maskMatrix; | 184 SkMatrix maskMatrix; |
183 maskMatrix.setIDiv(texture->width(), texture->height()); | 185 maskMatrix.setIDiv(texture->width(), texture->height()); |
184 maskMatrix.preTranslate(SkIntToScalar(-rect.fLeft), SkIntToScalar(-rect.fTop
)); | 186 maskMatrix.preTranslate(SkIntToScalar(-rect.fLeft), SkIntToScalar(-rect.fTop
)); |
185 | 187 |
186 pipelineBuilder->addCoverageFragmentProcessor( | 188 GrPipelineBuilder pipelineBuilder(*paint, drawContext->isUnifiedMultisampled
()); |
| 189 pipelineBuilder.setRenderTarget(drawContext->accessRenderTarget()); |
| 190 pipelineBuilder.setUserStencil(userStencilSettings); |
| 191 |
| 192 pipelineBuilder.addCoverageFragmentProcessor( |
187 GrSimpleTextureEffect::Create(texture, | 193 GrSimpleTextureEffect::Create(texture, |
188 maskMatrix, | 194 maskMatrix, |
189 GrTextureParams::kNone_Fi
lterMode, | 195 GrTextureParams::kNone_Fi
lterMode, |
190 kDevice_GrCoordSet))->unr
ef(); | 196 kDevice_GrCoordSet))->unr
ef(); |
191 | 197 |
192 SkAutoTUnref<GrDrawBatch> batch(GrRectBatchFactory::CreateNonAAFill(color, S
kMatrix::I(), | 198 SkAutoTUnref<GrDrawBatch> batch(GrRectBatchFactory::CreateNonAAFill(color, S
kMatrix::I(), |
193 dstRect,
nullptr, &invert)); | 199 dstRect,
nullptr, &invert)); |
194 target->drawBatch(*pipelineBuilder, clip, batch); | 200 drawContext->drawBatch(pipelineBuilder, clip, batch); |
195 } | 201 } |
OLD | NEW |