aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu
diff options
context:
space:
mode:
authorGravatar bsalomon <bsalomon@google.com>2016-08-15 14:49:10 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-08-15 14:49:10 -0700
commit7f0d9f39206d0bf67e0a14e9cf3351243c9b5a1b (patch)
tree529d2ffba4cd03d30c599169bbc9a64324d9f7af /src/gpu
parent583bc2e98d8105fc799897daea28eea03c23fbbc (diff)
Attempt to throw away rrect clips of rrects.
Diffstat (limited to 'src/gpu')
-rw-r--r--src/gpu/GrClipStackClip.cpp8
-rw-r--r--src/gpu/GrClipStackClip.h1
-rw-r--r--src/gpu/GrDrawContext.cpp22
3 files changed, 26 insertions, 5 deletions
diff --git a/src/gpu/GrClipStackClip.cpp b/src/gpu/GrClipStackClip.cpp
index 6cb216ee0c..a3a0de509c 100644
--- a/src/gpu/GrClipStackClip.cpp
+++ b/src/gpu/GrClipStackClip.cpp
@@ -30,6 +30,14 @@ bool GrClipStackClip::quickContains(const SkRect& rect) const {
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 98675e62ac..15025471d2 100644
--- a/src/gpu/GrClipStackClip.h
+++ b/src/gpu/GrClipStackClip.h
@@ -31,6 +31,7 @@ public:
}
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 76e0d8a66c..202be23590 100644
--- a/src/gpu/GrDrawContext.cpp
+++ b/src/gpu/GrDrawContext.cpp
@@ -781,7 +781,7 @@ void GrDrawContext::drawAtlas(const GrClip& clip,
///////////////////////////////////////////////////////////////////////////////
-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 @@ void GrDrawContext::drawRRect(const GrClip& clip,
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 @@ void GrDrawContext::drawRRect(const GrClip& clip,
&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 @@ void GrDrawContext::drawRRect(const GrClip& clip,
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 @@ void GrDrawContext::drawRRect(const GrClip& clip,
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,