Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(206)

Unified Diff: src/gpu/GrBlurUtils.cpp

Issue 1472333003: Clean up Ganesh path render a little bit (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Ooops Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/GrBlurUtils.h ('k') | src/gpu/GrDrawContext.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrBlurUtils.cpp
diff --git a/src/gpu/GrBlurUtils.cpp b/src/gpu/GrBlurUtils.cpp
index c6cff60b342377b1bd7c82003ee7e048086ac823..8cd569b1b9c297c359eb433b4a4c72f46b6c3727 100644
--- a/src/gpu/GrBlurUtils.cpp
+++ b/src/gpu/GrBlurUtils.cpp
@@ -46,15 +46,15 @@ static bool draw_mask(GrDrawContext* drawContext,
return true;
}
-static bool draw_with_mask_filter(GrDrawContext* drawContext,
- GrTextureProvider* textureProvider,
- const GrClip& clipData,
- const SkMatrix& viewMatrix,
- const SkPath& devPath,
- const SkMaskFilter* filter,
- const SkIRect& clipBounds,
- GrPaint* grp,
- SkPaint::Style style) {
+static bool sw_draw_with_mask_filter(GrDrawContext* drawContext,
+ GrTextureProvider* textureProvider,
+ const GrClip& clipData,
+ const SkMatrix& viewMatrix,
+ const SkPath& devPath,
+ const SkMaskFilter* filter,
+ const SkIRect& clipBounds,
+ GrPaint* grp,
+ SkPaint::Style style) {
SkMask srcM, dstM;
if (!SkDraw::DrawToMask(devPath, &clipBounds, filter, &viewMatrix, &srcM,
@@ -166,12 +166,8 @@ static void draw_path_with_mask_filter(GrContext* context,
static const SkRect* cullRect = nullptr; // TODO: what is our bounds?
- if (!strokeInfo.isDashed() && pathEffect && pathEffect->filterPath(tmpPath.init(), *pathPtr,
- &strokeInfo, cullRect)) {
- pathPtr = tmpPath.get();
- pathPtr->setIsVolatile(true);
- pathIsMutable = true;
- }
+ SkASSERT(strokeInfo.isDashed() || !pathEffect);
+
if (!strokeInfo.isHairlineStyle()) {
SkPath* strokedPath = pathIsMutable ? pathPtr : tmpPath.init();
if (strokeInfo.isDashed()) {
@@ -183,6 +179,7 @@ static void draw_path_with_mask_filter(GrContext* context,
strokeInfo.removeDash();
}
if (strokeInfo.applyToPath(strokedPath, *pathPtr)) {
+ // Apply the stroke to the path if there is one
pathPtr = strokedPath;
pathPtr->setIsVolatile(true);
pathIsMutable = true;
@@ -247,9 +244,9 @@ static void draw_path_with_mask_filter(GrContext* context,
// GPU path fails
SkPaint::Style style = strokeInfo.isHairlineStyle() ? SkPaint::kStroke_Style :
SkPaint::kFill_Style;
- draw_with_mask_filter(drawContext, context->textureProvider(),
- clip, viewMatrix, *devPathPtr,
- maskFilter, clipBounds, paint, style);
+ sw_draw_with_mask_filter(drawContext, context->textureProvider(),
+ clip, viewMatrix, *devPathPtr,
+ maskFilter, clipBounds, paint, style);
}
void GrBlurUtils::drawPathWithMaskFilter(GrContext* context,
@@ -260,11 +257,24 @@ void GrBlurUtils::drawPathWithMaskFilter(GrContext* context,
GrPaint* paint,
const SkMatrix& viewMatrix,
const SkMaskFilter* mf,
- const SkPathEffect* pe,
- const GrStrokeInfo& strokeInfo) {
- SkPath* path = const_cast<SkPath*>(&origPath);
- draw_path_with_mask_filter(context, drawContext, rt, clip, paint, viewMatrix, mf, pe,
- strokeInfo, path, false);
+ const SkPathEffect* pathEffect,
+ const GrStrokeInfo& origStrokeInfo,
+ bool pathIsMutable) {
+ SkPath* pathPtr = const_cast<SkPath*>(&origPath);
+
+ SkTLazy<SkPath> tmpPath;
+ GrStrokeInfo strokeInfo(origStrokeInfo);
+
+ if (!strokeInfo.isDashed() && pathEffect && pathEffect->filterPath(tmpPath.init(), *pathPtr,
+ &strokeInfo, nullptr)) {
+ pathPtr = tmpPath.get();
+ pathPtr->setIsVolatile(true);
+ pathIsMutable = true;
+ pathEffect = nullptr;
+ }
+
+ draw_path_with_mask_filter(context, drawContext, rt, clip, paint, viewMatrix, mf, pathEffect,
+ strokeInfo, pathPtr, pathIsMutable);
}
void GrBlurUtils::drawPathWithMaskFilter(GrContext* context,
@@ -314,6 +324,16 @@ void GrBlurUtils::drawPathWithMaskFilter(GrContext* context,
// at this point we're done with prePathMatrix
SkDEBUGCODE(prePathMatrix = (const SkMatrix*)0x50FF8001;)
+ SkTLazy<SkPath> tmpPath2;
+
+ if (!strokeInfo.isDashed() && pathEffect &&
+ pathEffect->filterPath(tmpPath2.init(), *pathPtr, &strokeInfo, nullptr)) {
+ pathPtr = tmpPath2.get();
+ pathPtr->setIsVolatile(true);
+ pathIsMutable = true;
+ pathEffect = nullptr;
+ }
+
GrPaint grPaint;
if (!SkPaintToGrPaint(context, paint, viewMatrix, &grPaint)) {
return;
@@ -321,16 +341,9 @@ void GrBlurUtils::drawPathWithMaskFilter(GrContext* context,
if (paint.getMaskFilter()) {
draw_path_with_mask_filter(context, drawContext, renderTarget, clip, &grPaint, viewMatrix,
- paint.getMaskFilter(), paint.getPathEffect(), strokeInfo,
+ paint.getMaskFilter(), pathEffect, strokeInfo,
pathPtr, pathIsMutable);
} else {
- SkTLazy<SkPath> tmpPath2;
- if (!strokeInfo.isDashed() && pathEffect &&
- pathEffect->filterPath(tmpPath2.init(), *pathPtr, &strokeInfo, nullptr)) {
- pathPtr = tmpPath2.get();
- pathPtr->setIsVolatile(true);
- pathIsMutable = true;
- }
drawContext->drawPath(clip, grPaint, viewMatrix, *pathPtr, strokeInfo);
}
}
« no previous file with comments | « src/gpu/GrBlurUtils.h ('k') | src/gpu/GrDrawContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698