Remove prePathMatrix from SkDevice::drawPath
Change-Id: Id49d171252cab33378f00021bb395e6ae6991178
Reviewed-on: https://skia-review.googlesource.com/147101
Commit-Queue: Robert Phillips <robertphillips@google.com>
Reviewed-by: Mike Reed <reed@google.com>
diff --git a/src/gpu/GrBlurUtils.cpp b/src/gpu/GrBlurUtils.cpp
index 4a0f9fe..4d527cb 100644
--- a/src/gpu/GrBlurUtils.cpp
+++ b/src/gpu/GrBlurUtils.cpp
@@ -267,41 +267,17 @@
void GrBlurUtils::drawPathWithMaskFilter(GrContext* context,
GrRenderTargetContext* renderTargetContext,
const GrClip& clip,
- const SkPath& origPath,
+ const SkPath& path,
const SkPaint& paint,
- const SkMatrix& origViewMatrix,
- const SkMatrix* prePathMatrix,
+ const SkMatrix& viewMatrix,
bool pathIsMutable) {
if (context->abandoned()) {
return;
}
- SkASSERT(!pathIsMutable || origPath.isVolatile());
+ SkASSERT(!pathIsMutable || path.isVolatile());
GrStyle style(paint);
- // If we have a prematrix, apply it to the path, optimizing for the case
- // where the original path can in fact be modified in place (even though
- // its parameter type is const).
-
- const SkPath* path = &origPath;
- SkTLazy<SkPath> tmpPath;
-
- SkMatrix viewMatrix = origViewMatrix;
-
- if (prePathMatrix) {
- // Styling, blurs, and shading are supposed to be applied *after* the prePathMatrix.
- if (!paint.getMaskFilter() && !paint.getShader() && !style.applies()) {
- viewMatrix.preConcat(*prePathMatrix);
- } else {
- SkPath* result = pathIsMutable ? const_cast<SkPath*>(path) : tmpPath.init();
- pathIsMutable = true;
- path->transform(*prePathMatrix, result);
- path = result;
- result->setIsVolatile(true);
- }
- }
- // at this point we're done with prePathMatrix
- SkDEBUGCODE(prePathMatrix = (const SkMatrix*)0x50FF8001;)
GrPaint grPaint;
if (!SkPaintToGrPaint(context, renderTargetContext->colorSpaceInfo(), paint, viewMatrix,
@@ -313,8 +289,8 @@
if (mf && !mf->hasFragmentProcessor()) {
// The MaskFilter wasn't already handled in SkPaintToGrPaint
draw_path_with_mask_filter(context, renderTargetContext, clip, std::move(grPaint), aa,
- viewMatrix, mf, style, path, pathIsMutable);
+ viewMatrix, mf, style, &path, pathIsMutable);
} else {
- renderTargetContext->drawPath(clip, std::move(grPaint), aa, viewMatrix, *path, style);
+ renderTargetContext->drawPath(clip, std::move(grPaint), aa, viewMatrix, path, style);
}
}
diff --git a/src/gpu/GrBlurUtils.h b/src/gpu/GrBlurUtils.h
index c15ca51..d8648bc 100644
--- a/src/gpu/GrBlurUtils.h
+++ b/src/gpu/GrBlurUtils.h
@@ -37,7 +37,6 @@
const SkPath& origSrcPath,
const SkPaint& paint,
const SkMatrix& origViewMatrix,
- const SkMatrix* prePathMatrix,
bool pathIsMutable);
/**
diff --git a/src/gpu/GrRenderTargetContext.cpp b/src/gpu/GrRenderTargetContext.cpp
index 69b092e..787bf7c 100644
--- a/src/gpu/GrRenderTargetContext.cpp
+++ b/src/gpu/GrRenderTargetContext.cpp
@@ -69,10 +69,9 @@
}
void drawPath(const GrClip& clip, const SkPath& path, const SkPaint& paint,
- const SkMatrix& viewMatrix, const SkMatrix* pathMatrix) override {
+ const SkMatrix& viewMatrix, bool pathIsMutable) override {
GrBlurUtils::drawPathWithMaskFilter(fRenderTargetContext->fContext, fRenderTargetContext,
- clip, path, paint, viewMatrix, pathMatrix,
- false);
+ clip, path, paint, viewMatrix, pathIsMutable);
}
void makeGrPaint(GrMaskFormat maskFormat, const SkPaint& skPaint, const SkMatrix& viewMatrix,
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index bce9275..1fe2ae4 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -383,7 +383,7 @@
path.setIsVolatile(true);
path.addRect(rect);
GrBlurUtils::drawPathWithMaskFilter(fContext.get(), fRenderTargetContext.get(),
- this->clip(), path, paint, this->ctm(), nullptr, true);
+ this->clip(), path, paint, this->ctm(), true);
return;
}
@@ -443,7 +443,7 @@
path.setIsVolatile(true);
path.addRRect(rrect);
GrBlurUtils::drawPathWithMaskFilter(fContext.get(), fRenderTargetContext.get(),
- this->clip(), path, paint, this->ctm(), nullptr, true);
+ this->clip(), path, paint, this->ctm(), true);
return;
}
@@ -487,7 +487,7 @@
path.setFillType(SkPath::kEvenOdd_FillType);
GrBlurUtils::drawPathWithMaskFilter(fContext.get(), fRenderTargetContext.get(), this->clip(),
- path, paint, this->ctm(), nullptr, true);
+ path, paint, this->ctm(), true);
}
@@ -497,7 +497,8 @@
if (paint.getMaskFilter()) {
SkPath path;
region.getBoundaryPath(&path);
- return this->drawPath(path, paint, nullptr, false);
+ path.setIsVolatile(true);
+ return this->drawPath(path, paint, true);
}
GrPaint grPaint;
@@ -605,10 +606,10 @@
}
void SkGpuDevice::drawPath(const SkPath& origSrcPath,
- const SkPaint& paint, const SkMatrix* prePathMatrix,
+ const SkPaint& paint,
bool pathIsMutable) {
ASSERT_SINGLE_OWNER
- if (!origSrcPath.isInverseFillType() && !paint.getPathEffect() && !prePathMatrix) {
+ if (!origSrcPath.isInverseFillType() && !paint.getPathEffect()) {
SkPoint points[2];
if (SkPaint::kStroke_Style == paint.getStyle() && paint.getStrokeWidth() > 0 &&
!paint.getMaskFilter() && SkPaint::kRound_Cap != paint.getStrokeCap() &&
@@ -625,7 +626,7 @@
}
GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawPath", fContext.get());
- if (!prePathMatrix && !paint.getMaskFilter()) {
+ if (!paint.getMaskFilter()) {
GrPaint grPaint;
if (!SkPaintToGrPaint(this->context(), fRenderTargetContext->colorSpaceInfo(), paint,
this->ctm(), &grPaint)) {
@@ -636,8 +637,7 @@
return;
}
GrBlurUtils::drawPathWithMaskFilter(fContext.get(), fRenderTargetContext.get(), this->clip(),
- origSrcPath, paint, this->ctm(), prePathMatrix,
- pathIsMutable);
+ origSrcPath, paint, this->ctm(), pathIsMutable);
}
static const int kBmpSmallTileSize = 1 << 10;
diff --git a/src/gpu/SkGpuDevice.h b/src/gpu/SkGpuDevice.h
index 6cd1ae6..a3233ad 100644
--- a/src/gpu/SkGpuDevice.h
+++ b/src/gpu/SkGpuDevice.h
@@ -73,16 +73,13 @@
const SkPaint& paint) override;
void drawRect(const SkRect& r, const SkPaint& paint) override;
void drawRRect(const SkRRect& r, const SkPaint& paint) override;
- void drawDRRect(const SkRRect& outer, const SkRRect& inner,
- const SkPaint& paint) override;
+ void drawDRRect(const SkRRect& outer, const SkRRect& inner, const SkPaint& paint) override;
void drawRegion(const SkRegion& r, const SkPaint& paint) override;
void drawOval(const SkRect& oval, const SkPaint& paint) override;
void drawArc(const SkRect& oval, SkScalar startAngle, SkScalar sweepAngle,
bool useCenter, const SkPaint& paint) override;
- void drawPath(const SkPath& path, const SkPaint& paint,
- const SkMatrix* prePathMatrix, bool pathIsMutable) override;
- void drawBitmap(const SkBitmap&, SkScalar x, SkScalar y,
- const SkPaint&) override;
+ void drawPath(const SkPath& path, const SkPaint& paint, bool pathIsMutable) override;
+ void drawBitmap(const SkBitmap&, SkScalar x, SkScalar y, const SkPaint&) override;
void drawBitmapRect(const SkBitmap&, const SkRect* srcOrNull, const SkRect& dst,
const SkPaint& paint, SkCanvas::SrcRectConstraint) override;
void drawSprite(const SkBitmap& bitmap, int x, int y,
diff --git a/src/gpu/text/GrTextBlob.cpp b/src/gpu/text/GrTextBlob.cpp
index 53b3b4d..bba3328 100644
--- a/src/gpu/text/GrTextBlob.cpp
+++ b/src/gpu/text/GrTextBlob.cpp
@@ -9,6 +9,7 @@
#include "GrBlurUtils.h"
#include "GrClip.h"
#include "GrContext.h"
+#include "GrStyle.h"
#include "GrTextTarget.h"
#include "SkColorFilter.h"
#include "SkGlyphCache.h"
@@ -295,11 +296,31 @@
GrTextBlob::Run::PathGlyph& pathGlyph = run.fPathGlyphs[i];
calculate_translation(pathGlyph.fPreTransformed, viewMatrix, x, y,
fInitialViewMatrix, fInitialX, fInitialY, &transX, &transY);
- const SkMatrix& ctm = pathGlyph.fPreTransformed ? SkMatrix::I() : viewMatrix;
+
+ const SkMatrix* ctm = pathGlyph.fPreTransformed ? &SkMatrix::I() : &viewMatrix;
SkMatrix pathMatrix;
pathMatrix.setScale(pathGlyph.fScale, pathGlyph.fScale);
pathMatrix.postTranslate(pathGlyph.fX + transX, pathGlyph.fY + transY);
- target->drawPath(clip, pathGlyph.fPath, runPaint, ctm, &pathMatrix);
+
+ const SkPath* path = &pathGlyph.fPath;
+ bool pathIsMutable = false;
+ SkTLazy<SkPath> tmpPath;
+
+ GrStyle style(runPaint);
+
+ // Styling, blurs, and shading are supposed to be applied *after* the pathMatrix.
+ if (!runPaint.getMaskFilter() && !runPaint.getShader() && !style.applies()) {
+ pathMatrix.postConcat(*ctm);
+ ctm = &pathMatrix;
+ } else {
+ SkPath* result = tmpPath.init();
+ path->transform(pathMatrix, result);
+ result->setIsVolatile(true);
+ path = result;
+ pathIsMutable = true;
+ }
+
+ target->drawPath(clip, *path, runPaint, *ctm, pathIsMutable);
}
}
diff --git a/src/gpu/text/GrTextTarget.h b/src/gpu/text/GrTextTarget.h
index 3bcbe9a..d220a1a 100644
--- a/src/gpu/text/GrTextTarget.h
+++ b/src/gpu/text/GrTextTarget.h
@@ -31,7 +31,7 @@
virtual void addDrawOp(const GrClip&, std::unique_ptr<GrAtlasTextOp> op) = 0;
virtual void drawPath(const GrClip&, const SkPath&, const SkPaint&,
- const SkMatrix& viewMatrix, const SkMatrix* pathMatrix) = 0;
+ const SkMatrix& viewMatrix, bool pathIsMutable) = 0;
virtual void makeGrPaint(GrMaskFormat, const SkPaint&, const SkMatrix& viewMatrix,
GrPaint*) = 0;