Attempt to throw away rrect clips of rrects.
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2241273003
Review-Url: https://codereview.chromium.org/2241273003
diff --git a/src/gpu/GrClipStackClip.cpp b/src/gpu/GrClipStackClip.cpp
index 6cb216e..a3a0de5 100644
--- a/src/gpu/GrClipStackClip.cpp
+++ b/src/gpu/GrClipStackClip.cpp
@@ -30,6 +30,14 @@
SkIntToScalar(fOrigin.y())));
}
+bool GrClipStackClip::quickContains(const SkRRect& rrect) const {
+ if (!fStack) {
+ return true;
+ }
+ return fStack->quickContains(rrect.makeOffset(SkIntToScalar(fOrigin.fX),
+ SkIntToScalar(fOrigin.fY)));
+}
+
void GrClipStackClip::getConservativeBounds(int width, int height, SkIRect* devResult,
bool* isIntersectionOfRects) const {
if (!fStack) {
diff --git a/src/gpu/GrClipStackClip.h b/src/gpu/GrClipStackClip.h
index 98675e6..1502547 100644
--- a/src/gpu/GrClipStackClip.h
+++ b/src/gpu/GrClipStackClip.h
@@ -31,6 +31,7 @@
}
bool quickContains(const SkRect&) const final;
+ bool quickContains(const SkRRect&) const final;
void getConservativeBounds(int width, int height, SkIRect* devResult,
bool* isIntersectionOfRects) const final;
bool apply(GrContext*, GrDrawContext*, bool useHWAA, bool hasUserStencilSettings,
diff --git a/src/gpu/GrDrawContext.cpp b/src/gpu/GrDrawContext.cpp
index 76e0d8a..202be23 100644
--- a/src/gpu/GrDrawContext.cpp
+++ b/src/gpu/GrDrawContext.cpp
@@ -781,7 +781,7 @@
///////////////////////////////////////////////////////////////////////////////
-void GrDrawContext::drawRRect(const GrClip& clip,
+void GrDrawContext::drawRRect(const GrClip& origClip,
const GrPaint& paint,
const SkMatrix& viewMatrix,
const SkRRect& rrect,
@@ -790,11 +790,23 @@
RETURN_IF_ABANDONED
SkDEBUGCODE(this->validate();)
GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawRRect");
-
if (rrect.isEmpty()) {
return;
}
+ GrNoClip noclip;
+ const GrClip* clip = &origClip;
+#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
+ // The Android framework frequently clips rrects to themselves where the clip is non-aa and the
+ // draw is aa. Since our lower level clip code works from batch bounds, which are SkRects, it
+ // doesn't detect that the clip can be ignored (modulo antialiasing). The following test
+ // attempts to mitigate the stencil clip cost but will only help when the entire clip stack
+ // can be ignored. We'd prefer to fix this in the framework by removing the clips calls.
+ SkRRect devRRect;
+ if (rrect.transform(viewMatrix, &devRRect) && clip->quickContains(devRRect)) {
+ clip = &noclip;
+ }
+#endif
SkASSERT(!style.pathEffect()); // this should've been devolved to a path in SkGpuDevice
AutoCheckFlush acf(fDrawingManager);
@@ -809,7 +821,7 @@
&useHWAA));
if (batch) {
GrPipelineBuilder pipelineBuilder(paint, useHWAA);
- this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch);
+ this->getDrawTarget()->drawBatch(pipelineBuilder, this, *clip, batch);
return;
}
}
@@ -823,7 +835,7 @@
shaderCaps));
if (batch) {
GrPipelineBuilder pipelineBuilder(paint, useHWAA);
- this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch);
+ this->getDrawTarget()->drawBatch(pipelineBuilder, this, *clip, batch);
return;
}
}
@@ -831,7 +843,7 @@
SkPath path;
path.setIsVolatile(true);
path.addRRect(rrect);
- this->internalDrawPath(clip, paint, viewMatrix, path, style);
+ this->internalDrawPath(*clip, paint, viewMatrix, path, style);
}
bool GrDrawContext::drawFilledDRRect(const GrClip& clip,