| 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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 return draw_mask(drawContext, clipData, viewMatrix, maskRect, grp, texture); | 92 return draw_mask(drawContext, clipData, viewMatrix, maskRect, grp, texture); |
| 93 } | 93 } |
| 94 | 94 |
| 95 // Create a mask of 'devPath' and place the result in 'mask'. | 95 // Create a mask of 'devPath' and place the result in 'mask'. |
| 96 static GrTexture* create_mask_GPU(GrContext* context, | 96 static GrTexture* create_mask_GPU(GrContext* context, |
| 97 SkRect* maskRect, | 97 SkRect* maskRect, |
| 98 const SkPath& devPath, | 98 const SkPath& devPath, |
| 99 const GrStrokeInfo& strokeInfo, | 99 const GrStrokeInfo& strokeInfo, |
| 100 bool doAA, | 100 bool doAA, |
| 101 int sampleCnt) { | 101 int sampleCnt) { |
| 102 // This mask will ultimately be drawn as a non-AA rect (see draw_mask). | 102 // This mask will ultimately be drawn as a non-AA rect (see draw_mask). |
| 103 // Non-AA rects have a bad habit of snapping arbitrarily. Integerize here | 103 // Non-AA rects have a bad habit of snapping arbitrarily. Integerize here |
| 104 // so the mask draws in a reproducible manner. | 104 // so the mask draws in a reproducible manner. |
| 105 *maskRect = SkRect::Make(maskRect->roundOut()); | 105 *maskRect = SkRect::Make(maskRect->roundOut()); |
| 106 | 106 |
| 107 GrSurfaceDesc desc; | 107 GrSurfaceDesc desc; |
| 108 desc.fFlags = kRenderTarget_GrSurfaceFlag; | 108 desc.fFlags = kRenderTarget_GrSurfaceFlag; |
| 109 desc.fWidth = SkScalarCeilToInt(maskRect->width()); | 109 desc.fWidth = SkScalarCeilToInt(maskRect->width()); |
| 110 desc.fHeight = SkScalarCeilToInt(maskRect->height()); | 110 desc.fHeight = SkScalarCeilToInt(maskRect->height()); |
| 111 desc.fSampleCnt = doAA ? sampleCnt : 0; | 111 desc.fSampleCnt = doAA ? sampleCnt : 0; |
| 112 // We actually only need A8, but it often isn't supported as a | 112 // We actually only need A8, but it often isn't supported as a |
| 113 // render target so default to RGBA_8888 | 113 // render target so default to RGBA_8888 |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 pathPtr = tmpPath.get(); | 268 pathPtr = tmpPath.get(); |
| 269 pathPtr->setIsVolatile(true); | 269 pathPtr->setIsVolatile(true); |
| 270 pathIsMutable = true; | 270 pathIsMutable = true; |
| 271 pathEffect = nullptr; | 271 pathEffect = nullptr; |
| 272 } | 272 } |
| 273 | 273 |
| 274 draw_path_with_mask_filter(context, drawContext, clip, paint, viewMatrix, mf
, pathEffect, | 274 draw_path_with_mask_filter(context, drawContext, clip, paint, viewMatrix, mf
, pathEffect, |
| 275 strokeInfo, pathPtr, pathIsMutable); | 275 strokeInfo, pathPtr, pathIsMutable); |
| 276 } | 276 } |
| 277 | 277 |
| 278 void GrBlurUtils::drawPathWithMaskFilter(GrContext* context, | 278 void GrBlurUtils::drawPathWithMaskFilter(GrContext* context, |
| 279 GrDrawContext* drawContext, | 279 GrDrawContext* drawContext, |
| 280 const GrClip& clip, | 280 const GrClip& clip, |
| 281 const SkPath& origSrcPath, | 281 const SkPath& origSrcPath, |
| 282 const SkPaint& paint, | 282 const SkPaint& paint, |
| 283 const SkMatrix& origViewMatrix, | 283 const SkMatrix& origViewMatrix, |
| 284 const SkMatrix* prePathMatrix, | 284 const SkMatrix* prePathMatrix, |
| 285 const SkIRect& clipBounds, | 285 const SkIRect& clipBounds, |
| 286 bool pathIsMutable) { | 286 bool pathIsMutable) { |
| 287 SkASSERT(!pathIsMutable || origSrcPath.isVolatile()); | 287 SkASSERT(!pathIsMutable || origSrcPath.isVolatile()); |
| 288 | 288 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 } | 340 } |
| 341 | 341 |
| 342 if (paint.getMaskFilter()) { | 342 if (paint.getMaskFilter()) { |
| 343 draw_path_with_mask_filter(context, drawContext, clip, &grPaint, viewMat
rix, | 343 draw_path_with_mask_filter(context, drawContext, clip, &grPaint, viewMat
rix, |
| 344 paint.getMaskFilter(), pathEffect, strokeInfo
, | 344 paint.getMaskFilter(), pathEffect, strokeInfo
, |
| 345 pathPtr, pathIsMutable); | 345 pathPtr, pathIsMutable); |
| 346 } else { | 346 } else { |
| 347 drawContext->drawPath(clip, grPaint, viewMatrix, *pathPtr, strokeInfo); | 347 drawContext->drawPath(clip, grPaint, viewMatrix, *pathPtr, strokeInfo); |
| 348 } | 348 } |
| 349 } | 349 } |
| 350 | |
| OLD | NEW |