| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 "GrBlurUtils.h" | 8 #include "GrBlurUtils.h" |
| 9 #include "GrDrawContext.h" | 9 #include "GrDrawContext.h" |
| 10 #include "GrCaps.h" | 10 #include "GrCaps.h" |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 | 148 |
| 149 void GrBlurUtils::drawPathWithMaskFilter(GrContext* context, | 149 void GrBlurUtils::drawPathWithMaskFilter(GrContext* context, |
| 150 GrDrawContext* drawContext, | 150 GrDrawContext* drawContext, |
| 151 GrRenderTarget* renderTarget, | 151 GrRenderTarget* renderTarget, |
| 152 const GrClip& clip, | 152 const GrClip& clip, |
| 153 const SkPath& origSrcPath, | 153 const SkPath& origSrcPath, |
| 154 const SkPaint& paint, | 154 const SkPaint& paint, |
| 155 const SkMatrix& origViewMatrix, | 155 const SkMatrix& origViewMatrix, |
| 156 const SkMatrix* prePathMatrix, | 156 const SkMatrix* prePathMatrix, |
| 157 const SkIRect& clipBounds, | 157 const SkIRect& clipBounds, |
| 158 bool pathIsMutable) { | 158 bool pathIsMutable, |
| 159 GrTextureProvider::SizeConstraint const
raint) { |
| 159 SkASSERT(!pathIsMutable || origSrcPath.isVolatile()); | 160 SkASSERT(!pathIsMutable || origSrcPath.isVolatile()); |
| 160 | 161 |
| 161 GrStrokeInfo strokeInfo(paint); | 162 GrStrokeInfo strokeInfo(paint); |
| 162 | 163 |
| 163 // If we have a prematrix, apply it to the path, optimizing for the case | 164 // If we have a prematrix, apply it to the path, optimizing for the case |
| 164 // where the original path can in fact be modified in place (even though | 165 // where the original path can in fact be modified in place (even though |
| 165 // its parameter type is const). | 166 // its parameter type is const). |
| 166 SkPath* pathPtr = const_cast<SkPath*>(&origSrcPath); | 167 SkPath* pathPtr = const_cast<SkPath*>(&origSrcPath); |
| 167 SkTLazy<SkPath> tmpPath; | 168 SkTLazy<SkPath> tmpPath; |
| 168 SkTLazy<SkPath> effectPath; | 169 SkTLazy<SkPath> effectPath; |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 SkAutoTUnref<GrTexture> mask(create_mask_GPU(context, | 259 SkAutoTUnref<GrTexture> mask(create_mask_GPU(context, |
| 259 &maskRect, | 260 &maskRect, |
| 260 *devPathPtr, | 261 *devPathPtr, |
| 261 strokeInfo, | 262 strokeInfo, |
| 262 grPaint.isAntiAlias(), | 263 grPaint.isAntiAlias(), |
| 263 renderTarget->numColorS
amples())); | 264 renderTarget->numColorS
amples())); |
| 264 if (mask) { | 265 if (mask) { |
| 265 GrTexture* filtered; | 266 GrTexture* filtered; |
| 266 | 267 |
| 267 if (paint.getMaskFilter()->filterMaskGPU(mask, viewMatrix, maskR
ect, | 268 if (paint.getMaskFilter()->filterMaskGPU(mask, viewMatrix, maskR
ect, |
| 268 &filtered, true)) { | 269 &filtered, true, constr
aint)) { |
| 269 // filterMaskGPU gives us ownership of a ref to the result | 270 // filterMaskGPU gives us ownership of a ref to the result |
| 270 SkAutoTUnref<GrTexture> atu(filtered); | 271 SkAutoTUnref<GrTexture> atu(filtered); |
| 271 if (draw_mask(drawContext, | 272 if (draw_mask(drawContext, |
| 272 clip, | 273 clip, |
| 273 viewMatrix, | 274 viewMatrix, |
| 274 maskRect, | 275 maskRect, |
| 275 &grPaint, | 276 &grPaint, |
| 276 filtered)) { | 277 filtered)) { |
| 277 // This path is completely drawn | 278 // This path is completely drawn |
| 278 return; | 279 return; |
| 279 } | 280 } |
| 280 } | 281 } |
| 281 } | 282 } |
| 282 } | 283 } |
| 283 | 284 |
| 284 // draw the mask on the CPU - this is a fallthrough path in case the | 285 // draw the mask on the CPU - this is a fallthrough path in case the |
| 285 // GPU path fails | 286 // GPU path fails |
| 286 SkPaint::Style style = strokeInfo.isHairlineStyle() ? SkPaint::kStroke_S
tyle : | 287 SkPaint::Style style = strokeInfo.isHairlineStyle() ? SkPaint::kStroke_S
tyle : |
| 287 SkPaint::kFill_Sty
le; | 288 SkPaint::kFill_Sty
le; |
| 288 draw_with_mask_filter(drawContext, context->textureProvider(), | 289 draw_with_mask_filter(drawContext, context->textureProvider(), |
| 289 clip, viewMatrix, *devPathPtr, | 290 clip, viewMatrix, *devPathPtr, |
| 290 paint.getMaskFilter(), clipBounds, &grPaint, style
); | 291 paint.getMaskFilter(), clipBounds, &grPaint, style
); |
| 291 return; | 292 return; |
| 292 } | 293 } |
| 293 | 294 |
| 294 drawContext->drawPath(clip, grPaint, viewMatrix, *pathPtr, strokeInfo); | 295 drawContext->drawPath(clip, grPaint, viewMatrix, *pathPtr, strokeInfo); |
| 295 } | 296 } |
| 296 | 297 |
| OLD | NEW |