Fold directFilterRRectMaskGPU into directFilterMaskGPU
Change-Id: Id4b636ea305c7cb28dd5efe139d3410f17177f42
Reviewed-on: https://skia-review.googlesource.com/148982
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
diff --git a/src/core/SkBlurMF.cpp b/src/core/SkBlurMF.cpp
index 290f772..f4907b9 100644
--- a/src/core/SkBlurMF.cpp
+++ b/src/core/SkBlurMF.cpp
@@ -61,14 +61,6 @@
const GrClip&,
const SkMatrix& viewMatrix,
const GrShape& shape) const override;
- bool directFilterRRectMaskGPU(GrContext*,
- GrRenderTargetContext* renderTargetContext,
- GrPaint&&,
- const GrClip&,
- const SkMatrix& viewMatrix,
- const SkStrokeRec& strokeRec,
- const SkRRect& rrect,
- const SkRRect& devRRect) const override;
sk_sp<GrTextureProxy> filterMaskGPU(GrContext*,
sk_sp<GrTextureProxy> srcProxy,
const SkMatrix& ctm,
@@ -741,7 +733,7 @@
return false;
}
- if (!viewMatrix.rectStaysRect()) {
+ if (!viewMatrix.isScaleTranslate()) {
return false;
}
@@ -755,75 +747,25 @@
return false;
}
+ SkRRect srcRRect;
+ bool inverted;
+ if (!shape.asRRect(&srcRRect, nullptr, nullptr, &inverted) || inverted) {
+ return false;
+ }
+
+ SkRRect devRRect;
+ if (!srcRRect.transform(viewMatrix, &devRRect)) {
+ return false;
+ }
+
+ if (!SkRRectPriv::AllCornersCircular(devRRect)) {
+ return false;
+ }
+
GrProxyProvider* proxyProvider = context->contextPriv().proxyProvider();
std::unique_ptr<GrFragmentProcessor> fp;
- SkRRect rrect;
- SkRect rect;
- bool inverted;
- if (shape.asRRect(&rrect, nullptr, nullptr, &inverted) && !inverted) {
- rect = rrect.rect();
- SkAssertResult(viewMatrix.mapRect(&rect));
- if (rrect.isRect()) {
- SkScalar pad = 3.0f * xformedSigma;
- rect.outset(pad, pad);
-
- fp = GrRectBlurEffect::Make(proxyProvider, *context->contextPriv().caps()->shaderCaps(),
- rect, xformedSigma);
- } else if (SkRRectPriv::IsCircle(rrect)) {
- fp = GrCircleBlurFragmentProcessor::Make(proxyProvider, rect, xformedSigma);
-
- // expand the rect for the coverage geometry
- int pad = SkScalarCeilToInt(6*xformedSigma)/2;
- rect.outset(SkIntToScalar(pad), SkIntToScalar(pad));
- } else {
- return false;
- }
- } else {
- return false;
- }
-
- if (!fp) {
- return false;
- }
-
- SkMatrix inverse;
- if (!viewMatrix.invert(&inverse)) {
- return false;
- }
-
- paint.addCoverageFragmentProcessor(std::move(fp));
- renderTargetContext->fillRectWithLocalMatrix(clip, std::move(paint), GrAA::kNo, SkMatrix::I(),
- rect, inverse);
- return true;
-}
-
-bool SkBlurMaskFilterImpl::directFilterRRectMaskGPU(GrContext* context,
- GrRenderTargetContext* renderTargetContext,
- GrPaint&& paint,
- const GrClip& clip,
- const SkMatrix& viewMatrix,
- const SkStrokeRec& strokeRec,
- const SkRRect& srcRRect,
- const SkRRect& devRRect) const {
- SkASSERT(renderTargetContext);
-
- if (fBlurStyle != kNormal_SkBlurStyle) {
- return false;
- }
-
- if (!strokeRec.isFillStyle()) {
- return false;
- }
-
- GrProxyProvider* proxyProvider = context->contextPriv().proxyProvider();
- SkScalar xformedSigma = this->computeXformedSigma(viewMatrix);
- if (xformedSigma <= 0) {
- return false;
- }
-
if (devRRect.isRect() || SkRRectPriv::IsCircle(devRRect)) {
- std::unique_ptr<GrFragmentProcessor> fp;
if (devRRect.isRect()) {
SkScalar pad = 3.0f * xformedSigma;
const SkRect dstCoverageRect = devRRect.rect().makeOutset(pad, pad);
@@ -831,8 +773,7 @@
fp = GrRectBlurEffect::Make(proxyProvider, *context->contextPriv().caps()->shaderCaps(),
dstCoverageRect, xformedSigma);
} else {
- fp = GrCircleBlurFragmentProcessor::Make(proxyProvider,
- devRRect.rect(), xformedSigma);
+ fp = GrCircleBlurFragmentProcessor::Make(proxyProvider, devRRect.rect(), xformedSigma);
}
if (!fp) {
@@ -856,7 +797,7 @@
return true;
}
- auto fp = GrRRectBlurEffect::Make(context, fSigma, xformedSigma, srcRRect, devRRect);
+ fp = GrRRectBlurEffect::Make(context, fSigma, xformedSigma, srcRRect, devRRect);
if (!fp) {
return false;
}
diff --git a/src/core/SkMaskFilter.cpp b/src/core/SkMaskFilter.cpp
index 5c20066..470f984 100644
--- a/src/core/SkMaskFilter.cpp
+++ b/src/core/SkMaskFilter.cpp
@@ -340,17 +340,6 @@
return false;
}
-bool SkMaskFilterBase::directFilterRRectMaskGPU(GrContext*,
- GrRenderTargetContext*,
- GrPaint&&,
- const GrClip&,
- const SkMatrix& viewMatrix,
- const SkStrokeRec&,
- const SkRRect& rrect,
- const SkRRect& devRRect) const {
- return false;
-}
-
sk_sp<GrTextureProxy> SkMaskFilterBase::filterMaskGPU(GrContext*,
sk_sp<GrTextureProxy> srcProxy,
const SkMatrix& ctm,
diff --git a/src/core/SkMaskFilterBase.h b/src/core/SkMaskFilterBase.h
index d907263..d3a257c 100644
--- a/src/core/SkMaskFilterBase.h
+++ b/src/core/SkMaskFilterBase.h
@@ -114,18 +114,6 @@
const GrClip&,
const SkMatrix& viewMatrix,
const GrShape& shape) const;
- /**
- * Try to directly render a rounded rect mask filter into the target. Returns
- * true if drawing was successful. If false is returned then paint is unmodified.
- */
- virtual bool directFilterRRectMaskGPU(GrContext*,
- GrRenderTargetContext*,
- GrPaint&&,
- const GrClip&,
- const SkMatrix& viewMatrix,
- const SkStrokeRec&,
- const SkRRect& rrect,
- const SkRRect& devRRect) const;
/**
* This function is used to implement filters that require an explicit src mask. It should only
diff --git a/src/core/SkRRect.cpp b/src/core/SkRRect.cpp
index 669dbd2..2b92f4b 100644
--- a/src/core/SkRRect.cpp
+++ b/src/core/SkRRect.cpp
@@ -371,12 +371,6 @@
SkASSERT(this->isValid());
}
-static bool matrix_only_scale_and_translate(const SkMatrix& matrix) {
- const SkMatrix::TypeMask m = (SkMatrix::TypeMask) (SkMatrix::kAffine_Mask
- | SkMatrix::kPerspective_Mask);
- return (matrix.getType() & m) == 0;
-}
-
bool SkRRect::transform(const SkMatrix& matrix, SkRRect* dst) const {
if (nullptr == dst) {
return false;
@@ -394,7 +388,7 @@
// If transform supported 90 degree rotations (which it could), we could
// use SkMatrix::rectStaysRect() to check for a valid transformation.
- if (!matrix_only_scale_and_translate(matrix)) {
+ if (!matrix.isScaleTranslate()) {
return false;
}
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index 58c1de8..4b71068 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -406,12 +406,6 @@
ASSERT_SINGLE_OWNER
GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawRRect", fContext.get());
- GrPaint grPaint;
- if (!SkPaintToGrPaint(this->context(), fRenderTargetContext->colorSpaceInfo(), paint,
- this->ctm(), &grPaint)) {
- return;
- }
-
SkMaskFilterBase* mf = as_MFB(paint.getMaskFilter());
if (mf) {
if (mf->hasFragmentProcessor()) {
@@ -420,28 +414,11 @@
}
GrStyle style(paint);
- if (mf) {
- // try to hit the fast path for drawing filtered round rects
-
- SkRRect devRRect;
- if (rrect.transform(this->ctm(), &devRRect)) {
- if (SkRRectPriv::AllCornersCircular(devRRect)) {
- if (mf->directFilterRRectMaskGPU(this->context(), fRenderTargetContext.get(),
- std::move(grPaint), this->clip(), this->ctm(),
- style.strokeRec(), rrect, devRRect)) {
- return;
- }
- }
- }
- }
if (mf || style.pathEffect()) {
- // The only mask filter the native rrect drawing code could've handle was taken
- // care of above.
// A path effect will presumably transform this rrect into something else.
GrShape shape(rrect, style);
- // TODO: this is throwing away to work we did to create the GrPaint
GrBlurUtils::drawShapeWithMaskFilter(fContext.get(), fRenderTargetContext.get(),
this->clip(), paint, this->ctm(), shape);
return;
@@ -449,6 +426,12 @@
SkASSERT(!style.pathEffect());
+ GrPaint grPaint;
+ if (!SkPaintToGrPaint(this->context(), fRenderTargetContext->colorSpaceInfo(), paint,
+ this->ctm(), &grPaint)) {
+ return;
+ }
+
fRenderTargetContext->drawRRect(this->clip(), std::move(grPaint), GrAA(paint.isAntiAlias()),
this->ctm(), rrect, style);
}
diff --git a/src/gpu/SkGpuDevice_drawTexture.cpp b/src/gpu/SkGpuDevice_drawTexture.cpp
index c916fc3..3c5488e 100644
--- a/src/gpu/SkGpuDevice_drawTexture.cpp
+++ b/src/gpu/SkGpuDevice_drawTexture.cpp
@@ -321,24 +321,6 @@
return;
}
- // First see if we can do the draw + mask filter direct to the dst.
- if (viewMatrix.isScaleTranslate()) {
- SkRect devClippedDstRect;
- viewMatrix.mapRectScaleTranslate(&devClippedDstRect, clippedDstRect);
-
- SkStrokeRec rec(SkStrokeRec::kFill_InitStyle);
- if (as_MFB(mf)->directFilterRRectMaskGPU(fContext.get(),
- fRenderTargetContext.get(),
- std::move(grPaint),
- this->clip(),
- viewMatrix,
- rec,
- SkRRect::MakeRect(clippedDstRect),
- SkRRect::MakeRect(devClippedDstRect))) {
- return;
- }
- }
-
GrShape shape(clippedDstRect, GrStyle::SimpleFill());
GrBlurUtils::drawShapeWithMaskFilter(this->context(), fRenderTargetContext.get(), this->clip(),