aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu
diff options
context:
space:
mode:
Diffstat (limited to 'src/gpu')
-rw-r--r--src/gpu/GrClipStackClip.cpp21
-rw-r--r--src/gpu/GrClipStackClip.h2
-rw-r--r--src/gpu/GrDrawContext.cpp14
-rw-r--r--src/gpu/GrFixedClip.h16
4 files changed, 53 insertions, 0 deletions
diff --git a/src/gpu/GrClipStackClip.cpp b/src/gpu/GrClipStackClip.cpp
index 7138f4b68a..8233786ba2 100644
--- a/src/gpu/GrClipStackClip.cpp
+++ b/src/gpu/GrClipStackClip.cpp
@@ -41,6 +41,27 @@ bool GrClipStackClip::quickContains(const SkRRect& rrect) const {
SkIntToScalar(fOrigin.fY)));
}
+bool GrClipStackClip::isRRect(const SkRect& origRTBounds, SkRRect* rr, bool* aa) const {
+ if (!fStack) {
+ return false;
+ }
+ const SkRect* rtBounds = &origRTBounds;
+ SkRect tempRTBounds;
+ bool origin = fOrigin.fX || fOrigin.fY;
+ if (origin) {
+ tempRTBounds = origRTBounds;
+ tempRTBounds.offset(SkIntToScalar(fOrigin.fX), SkIntToScalar(fOrigin.fY));
+ rtBounds = &tempRTBounds;
+ }
+ if (fStack->isRRect(*rtBounds, rr, aa)) {
+ if (origin) {
+ rr->offset(-SkIntToScalar(fOrigin.fX), -SkIntToScalar(fOrigin.fY));
+ }
+ return true;
+ }
+ return false;
+}
+
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 cb1f683702..ad143d6969 100644
--- a/src/gpu/GrClipStackClip.h
+++ b/src/gpu/GrClipStackClip.h
@@ -38,6 +38,8 @@ public:
bool apply(GrContext*, GrDrawContext*, bool useHWAA, bool hasUserStencilSettings,
GrAppliedClip* out) const final;
+ bool isRRect(const SkRect& rtBounds, SkRRect* rr, bool* aa) const override;
+
private:
static bool PathNeedsSWRenderer(GrContext* context,
bool hasUserStencilSettings,
diff --git a/src/gpu/GrDrawContext.cpp b/src/gpu/GrDrawContext.cpp
index 5afb2eaec9..2bb9caa8b1 100644
--- a/src/gpu/GrDrawContext.cpp
+++ b/src/gpu/GrDrawContext.cpp
@@ -251,6 +251,20 @@ void GrDrawContext::drawPaint(const GrClip& clip,
SkIntToScalar(fRenderTarget->height()));
SkTCopyOnFirstWrite<GrPaint> paint(origPaint);
+ SkRRect rrect;
+ bool aaRRect;
+ // Check if we can replace a clipRRect()/drawPaint() with a drawRRect(). We only do the
+ // transformation for non-rect rrects. Rects caused a performance regression on an Android
+ // test that needs investigation. We also skip cases where there are fragment processors
+ // because they may depend on having correct local coords and this path draws in device space
+ // without a local matrix.
+ if (!paint->numTotalFragmentProcessors() &&
+ clip.isRRect(r, &rrect, &aaRRect) && !rrect.isRect()) {
+ paint.writable()->setAntiAlias(aaRRect);
+ this->drawRRect(GrNoClip(), *paint, SkMatrix::I(), rrect, GrStyle::SimpleFill());
+ return;
+ }
+
// by definition this fills the entire clip, no need for AA
if (paint->isAntiAlias()) {
paint.writable()->setAntiAlias(false);
diff --git a/src/gpu/GrFixedClip.h b/src/gpu/GrFixedClip.h
index 01498c1161..705b2eada9 100644
--- a/src/gpu/GrFixedClip.h
+++ b/src/gpu/GrFixedClip.h
@@ -39,6 +39,22 @@ public:
void getConservativeBounds(int width, int height, SkIRect* devResult,
bool* isIntersectionOfRects) const final;
+ bool isRRect(const SkRect& rtBounds, SkRRect* rr, bool* aa) const override {
+ if (fHasStencilClip) {
+ return false;
+ }
+ if (fScissorState.enabled()) {
+ SkRect rect = SkRect::Make(fScissorState.rect());
+ if (!rect.intersects(rtBounds)) {
+ return false;
+ }
+ rr->setRect(rect);
+ *aa = false;
+ return true;
+ }
+ return false;
+ };
+
private:
bool apply(GrContext*, GrDrawContext*, bool useHWAA, bool hasUserStencilSettings,
GrAppliedClip* out) const final;