aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar robertphillips <robertphillips@google.com>2015-11-30 05:45:06 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2015-11-30 05:45:06 -0800
commit0e7029eaef917d314475dcc9df9df174af88de52 (patch)
tree80a47cc25bc13a911aa701b6484a85aa69b55d30 /src
parent09f8e1b14e5096741bc1c28145acdb352d66ef58 (diff)
Clean up Ganesh path render a little bit
I'm not sure if this is an improvement but this is an attempt to start moving the handling of pathEffects up the call stack (ideally to SkGpuDevice). Note that the duplicate path sniffing in GrDrawContext::drawPath is still useful since it can be invoked if a path has to be explicitly drawn for a mask filter. Review URL: https://codereview.chromium.org/1472333003
Diffstat (limited to 'src')
-rw-r--r--src/gpu/GrBlurUtils.cpp75
-rw-r--r--src/gpu/GrBlurUtils.h3
-rw-r--r--src/gpu/GrDrawContext.cpp2
-rw-r--r--src/gpu/SkGpuDevice.cpp21
-rw-r--r--src/gpu/SkGpuDevice_drawTexture.cpp3
5 files changed, 60 insertions, 44 deletions
diff --git a/src/gpu/GrBlurUtils.cpp b/src/gpu/GrBlurUtils.cpp
index c6cff60b34..8cd569b1b9 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);
}
}
diff --git a/src/gpu/GrBlurUtils.h b/src/gpu/GrBlurUtils.h
index d64f492473..1de669c5d6 100644
--- a/src/gpu/GrBlurUtils.h
+++ b/src/gpu/GrBlurUtils.h
@@ -53,7 +53,8 @@ namespace GrBlurUtils {
const SkMatrix& viewMatrix,
const SkMaskFilter*,
const SkPathEffect*,
- const GrStrokeInfo&);
+ const GrStrokeInfo&,
+ bool pathIsMutable);
};
diff --git a/src/gpu/GrDrawContext.cpp b/src/gpu/GrDrawContext.cpp
index b017b50fea..17cdbf3b6b 100644
--- a/src/gpu/GrDrawContext.cpp
+++ b/src/gpu/GrDrawContext.cpp
@@ -590,7 +590,7 @@ static bool is_nested_rects(const SkMatrix& viewMatrix,
// TODO: this restriction could be lifted if we were willing to apply
// the matrix to all the points individually rather than just to the rect
- if (!viewMatrix.preservesAxisAlignment()) {
+ if (!viewMatrix.rectStaysRect()) {
return false;
}
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index 929b57c6b5..46e8df4443 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -456,7 +456,6 @@ void SkGpuDevice::drawPoints(const SkDraw& draw, SkCanvas::PointMode mode,
void SkGpuDevice::drawRect(const SkDraw& draw, const SkRect& rect, const SkPaint& paint) {
GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawRect", fContext);
-
CHECK_FOR_ANNOTATION(paint);
CHECK_SHOULD_DRAW(draw);
@@ -569,21 +568,20 @@ void SkGpuDevice::drawRRect(const SkDraw& draw, const SkRRect& rect,
void SkGpuDevice::drawDRRect(const SkDraw& draw, const SkRRect& outer,
const SkRRect& inner, const SkPaint& paint) {
- SkStrokeRec stroke(paint);
- if (stroke.isFillStyle()) {
+ GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawDRRect", fContext);
+ CHECK_FOR_ANNOTATION(paint);
+ CHECK_SHOULD_DRAW(draw);
- CHECK_FOR_ANNOTATION(paint);
- CHECK_SHOULD_DRAW(draw);
+ SkStrokeRec stroke(paint);
+ if (stroke.isFillStyle() && !paint.getMaskFilter() && !paint.getPathEffect()) {
GrPaint grPaint;
if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, &grPaint)) {
return;
}
- if (nullptr == paint.getMaskFilter() && nullptr == paint.getPathEffect()) {
- fDrawContext->drawDRRect(fClip, grPaint, *draw.fMatrix, outer, inner);
- return;
- }
+ fDrawContext->drawDRRect(fClip, grPaint, *draw.fMatrix, outer, inner);
+ return;
}
SkPath path;
@@ -592,7 +590,10 @@ void SkGpuDevice::drawDRRect(const SkDraw& draw, const SkRRect& outer,
path.addRRect(inner);
path.setFillType(SkPath::kEvenOdd_FillType);
- this->drawPath(draw, path, paint, nullptr, true);
+ GrBlurUtils::drawPathWithMaskFilter(fContext, fDrawContext, fRenderTarget,
+ fClip, path, paint,
+ *draw.fMatrix, nullptr,
+ draw.fClip->getBounds(), true);
}
diff --git a/src/gpu/SkGpuDevice_drawTexture.cpp b/src/gpu/SkGpuDevice_drawTexture.cpp
index 6a43d37762..443bcf102b 100644
--- a/src/gpu/SkGpuDevice_drawTexture.cpp
+++ b/src/gpu/SkGpuDevice_drawTexture.cpp
@@ -233,7 +233,8 @@ void SkGpuDevice::drawTextureProducerImpl(GrTextureProducer* producer,
}
SkPath rectPath;
rectPath.addRect(clippedDstRect);
+ rectPath.setIsVolatile(true);
GrBlurUtils::drawPathWithMaskFilter(this->context(), fDrawContext, fRenderTarget, fClip,
rectPath, &grPaint, viewMatrix, mf, paint.getPathEffect(),
- GrStrokeInfo::FillInfo());
+ GrStrokeInfo::FillInfo(), true);
}