diff options
author | 2016-08-15 14:49:10 -0700 | |
---|---|---|
committer | 2016-08-15 14:49:10 -0700 | |
commit | 7f0d9f39206d0bf67e0a14e9cf3351243c9b5a1b (patch) | |
tree | 529d2ffba4cd03d30c599169bbc9a64324d9f7af /include | |
parent | 583bc2e98d8105fc799897daea28eea03c23fbbc (diff) |
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
Diffstat (limited to 'include')
-rw-r--r-- | include/core/SkClipStack.h | 22 | ||||
-rw-r--r-- | include/core/SkRRect.h | 13 | ||||
-rw-r--r-- | include/gpu/GrClip.h | 3 |
3 files changed, 36 insertions, 2 deletions
diff --git a/include/core/SkClipStack.h b/include/core/SkClipStack.h index 3156941125..2f2e940c8c 100644 --- a/include/core/SkClipStack.h +++ b/include/core/SkClipStack.h @@ -158,6 +158,23 @@ public: } } + bool contains(const SkRRect& rrect) const { + switch (fType) { + case kRect_Type: + return this->getRect().contains(rrect.getBounds()); + case kRRect_Type: + // We don't currently have a generalized rrect-rrect containment. + return fRRect.contains(rrect.getBounds()) || rrect == fRRect; + case kPath_Type: + return fPath.get()->conservativelyContainsRect(rrect.getBounds()); + case kEmpty_Type: + return false; + default: + SkDEBUGFAIL("Unexpected type."); + return false; + } + } + /** * Is the clip shape inverse filled. */ @@ -312,11 +329,12 @@ public: bool* isIntersectionOfRects = NULL) const; /** - * Returns true if the input rect in device space is entirely contained - * by the clip. A return value of false does not guarantee that the rect + * Returns true if the input (r)rect in device space is entirely contained + * by the clip. A return value of false does not guarantee that the (r)rect * is not contained by the clip. */ bool quickContains(const SkRect& devRect) const; + bool quickContains(const SkRRect& devRRect) const; /** * Flattens the clip stack into a single SkPath. Returns true if any of diff --git a/include/core/SkRRect.h b/include/core/SkRRect.h index d025412d64..64db2f317b 100644 --- a/include/core/SkRRect.h +++ b/include/core/SkRRect.h @@ -47,6 +47,10 @@ class SkMatrix; */ class SK_API SkRRect { public: + SkRRect() { /* unititialized */ } + SkRRect(const SkRRect&) = default; + SkRRect& operator=(const SkRRect&) = default; + /** * Enum to capture the various possible subtypes of RR. Accessed * by type(). The subtypes become progressively less restrictive. @@ -274,6 +278,10 @@ public: fRect.offset(dx, dy); } + SkRRect SK_WARN_UNUSED_RESULT makeOffset(SkScalar dx, SkScalar dy) const { + return SkRRect(fRect.makeOffset(dx, dy), fRadii, fType); + } + /** * Returns true if 'rect' is wholy inside the RR, and both * are not empty. @@ -322,6 +330,11 @@ public: void dumpHex() const { this->dump(true); } private: + SkRRect(const SkRect& rect, const SkVector radii[4], int32_t type) + : fRect(rect) + , fRadii{radii[0], radii[1], radii[2], radii[3]} + , fType(type) {} + SkRect fRect; // Radii order is UL, UR, LR, LL. Use Corner enum to index into fRadii[] SkVector fRadii[4]; diff --git a/include/gpu/GrClip.h b/include/gpu/GrClip.h index 9db76f0942..a6a0a665bd 100644 --- a/include/gpu/GrClip.h +++ b/include/gpu/GrClip.h @@ -66,6 +66,9 @@ private: class GrClip { public: virtual bool quickContains(const SkRect&) const = 0; + virtual bool quickContains(const SkRRect& rrect) const { + return this->quickContains(rrect.getBounds()); + } virtual void getConservativeBounds(int width, int height, SkIRect* devResult, bool* isIntersectionOfRects = nullptr) const = 0; virtual bool apply(GrContext*, GrDrawContext*, bool useHWAA, bool hasUserStencilSettings, |