aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar cdalton <cdalton@nvidia.com>2016-03-17 12:56:11 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-03-17 12:56:11 -0700
commitb893a4c569d0719a395abffb266d1d61af847e2f (patch)
treec314e002fea32b026dee2da28c2e546a01648021
parenta483da395a4f3b82073057420ac1318d2c7f3f95 (diff)
Add asRRect method to SkClipStack::Element
Adds an asRRect method alongside asPath, for clip implementations that can be generalized to round rects. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1793373002 Review URL: https://codereview.chromium.org/1793373002
-rw-r--r--include/core/SkClipStack.h3
-rw-r--r--src/core/SkClipStack.cpp2
2 files changed, 5 insertions, 0 deletions
diff --git a/include/core/SkClipStack.h b/include/core/SkClipStack.h
index 38d6d6751d..973f70a42b 100644
--- a/include/core/SkClipStack.h
+++ b/include/core/SkClipStack.h
@@ -98,6 +98,9 @@ public:
//!< Call to get the element as a path, regardless of its type.
void asPath(SkPath* path) const;
+ //!< Call if getType() is not kPath to get the element as a round rect.
+ const SkRRect& asRRect() const { SkASSERT(kPath_Type != fType); return fRRect; }
+
/** If getType() is not kEmpty this indicates whether the clip shape should be anti-aliased
when it is rasterized. */
bool isAA() const { return fDoAA; }
diff --git a/src/core/SkClipStack.cpp b/src/core/SkClipStack.cpp
index 4227eeac68..4e53d8b850 100644
--- a/src/core/SkClipStack.cpp
+++ b/src/core/SkClipStack.cpp
@@ -21,6 +21,7 @@ int32_t SkClipStack::gGenID = kFirstUnreservedGenID;
SkClipStack::Element::Element(const Element& that) {
switch (that.getType()) {
case kEmpty_Type:
+ fRRect.setEmpty();
fPath.reset();
break;
case kRect_Type: // Rect uses rrect
@@ -171,6 +172,7 @@ void SkClipStack::Element::checkEmpty() const {
SkASSERT(kNormal_BoundsType == fFiniteBoundType);
SkASSERT(!fIsIntersectionOfRects);
SkASSERT(kEmptyGenID == fGenID);
+ SkASSERT(fRRect.isEmpty());
SkASSERT(!fPath.isValid());
}