aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core
diff options
context:
space:
mode:
authorGravatar Brian Salomon <bsalomon@google.com>2017-08-30 11:37:57 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-08-30 15:58:12 +0000
commitf3b46e5193da843cac07d42fdc36c76c05f7fa77 (patch)
treea8ca8aef3e0f070606eaaa2d9c908db7ff436795 /src/core
parentf9810666bd40db8fb1650e6c727c1a83b8090136 (diff)
Rename methods and enum on SkClipStack::Element to indicate "device space"
Change-Id: I83056843b530f76590f755f97e3d0a5a58f371fa Reviewed-on: https://skia-review.googlesource.com/39402 Commit-Queue: Brian Salomon <bsalomon@google.com> Reviewed-by: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'src/core')
-rw-r--r--src/core/SkClipStack.cpp269
-rw-r--r--src/core/SkClipStack.h71
2 files changed, 178 insertions, 162 deletions
diff --git a/src/core/SkClipStack.cpp b/src/core/SkClipStack.cpp
index 2f0a4936a4..bf12a1391d 100644
--- a/src/core/SkClipStack.cpp
+++ b/src/core/SkClipStack.cpp
@@ -20,24 +20,24 @@ static const int32_t kFirstUnreservedGenID = 3;
int32_t SkClipStack::gGenID = kFirstUnreservedGenID;
SkClipStack::Element::Element(const Element& that) {
- switch (that.getType()) {
- case kEmpty_Type:
- fRRect.setEmpty();
- fPath.reset();
+ switch (that.getDeviceSpaceType()) {
+ case DeviceSpaceType::kEmpty:
+ fDeviceSpaceRRect.setEmpty();
+ fDeviceSpacePath.reset();
break;
- case kRect_Type: // Rect uses rrect
- case kRRect_Type:
- fPath.reset();
- fRRect = that.fRRect;
+ case DeviceSpaceType::kRect: // Rect uses rrect
+ case DeviceSpaceType::kRRect:
+ fDeviceSpacePath.reset();
+ fDeviceSpaceRRect = that.fDeviceSpaceRRect;
break;
- case kPath_Type:
- fPath.set(that.getPath());
+ case DeviceSpaceType::kPath:
+ fDeviceSpacePath.set(that.getDeviceSpacePath());
break;
}
fSaveCount = that.fSaveCount;
fOp = that.fOp;
- fType = that.fType;
+ fDeviceSpaceType = that.fDeviceSpaceType;
fDoAA = that.fDoAA;
fFiniteBoundType = that.fFiniteBoundType;
fFiniteBound = that.fFiniteBound;
@@ -49,20 +49,18 @@ bool SkClipStack::Element::operator== (const Element& element) const {
if (this == &element) {
return true;
}
- if (fOp != element.fOp ||
- fType != element.fType ||
- fDoAA != element.fDoAA ||
- fSaveCount != element.fSaveCount) {
+ if (fOp != element.fOp || fDeviceSpaceType != element.fDeviceSpaceType ||
+ fDoAA != element.fDoAA || fSaveCount != element.fSaveCount) {
return false;
}
- switch (fType) {
- case kPath_Type:
- return this->getPath() == element.getPath();
- case kRRect_Type:
- return fRRect == element.fRRect;
- case kRect_Type:
- return this->getRect() == element.getRect();
- case kEmpty_Type:
+ switch (fDeviceSpaceType) {
+ case DeviceSpaceType::kPath:
+ return this->getDeviceSpacePath() == element.getDeviceSpacePath();
+ case DeviceSpaceType::kRRect:
+ return fDeviceSpaceRRect == element.fDeviceSpaceRRect;
+ case DeviceSpaceType::kRect:
+ return this->getDeviceSpaceRect() == element.getDeviceSpaceRect();
+ case DeviceSpaceType::kEmpty:
return true;
default:
SkDEBUGFAIL("Unexpected type.");
@@ -72,13 +70,13 @@ bool SkClipStack::Element::operator== (const Element& element) const {
const SkRect& SkClipStack::Element::getBounds() const {
static const SkRect kEmpty = {0, 0, 0, 0};
- switch (fType) {
- case kRect_Type: // fallthrough
- case kRRect_Type:
- return fRRect.getBounds();
- case kPath_Type:
- return fPath.get()->getBounds();
- case kEmpty_Type:
+ switch (fDeviceSpaceType) {
+ case DeviceSpaceType::kRect: // fallthrough
+ case DeviceSpaceType::kRRect:
+ return fDeviceSpaceRRect.getBounds();
+ case DeviceSpaceType::kPath:
+ return fDeviceSpacePath.get()->getBounds();
+ case DeviceSpaceType::kEmpty:
return kEmpty;
default:
SkDEBUGFAIL("Unexpected type.");
@@ -87,14 +85,14 @@ const SkRect& SkClipStack::Element::getBounds() const {
}
bool SkClipStack::Element::contains(const SkRect& rect) const {
- switch (fType) {
- case kRect_Type:
- return this->getRect().contains(rect);
- case kRRect_Type:
- return fRRect.contains(rect);
- case kPath_Type:
- return fPath.get()->conservativelyContainsRect(rect);
- case kEmpty_Type:
+ switch (fDeviceSpaceType) {
+ case DeviceSpaceType::kRect:
+ return this->getDeviceSpaceRect().contains(rect);
+ case DeviceSpaceType::kRRect:
+ return fDeviceSpaceRRect.contains(rect);
+ case DeviceSpaceType::kPath:
+ return fDeviceSpacePath.get()->conservativelyContainsRect(rect);
+ case DeviceSpaceType::kEmpty:
return false;
default:
SkDEBUGFAIL("Unexpected type.");
@@ -103,15 +101,15 @@ bool SkClipStack::Element::contains(const SkRect& rect) const {
}
bool SkClipStack::Element::contains(const SkRRect& rrect) const {
- switch (fType) {
- case kRect_Type:
- return this->getRect().contains(rrect.getBounds());
- case kRRect_Type:
+ switch (fDeviceSpaceType) {
+ case DeviceSpaceType::kRect:
+ return this->getDeviceSpaceRect().contains(rrect.getBounds());
+ case DeviceSpaceType::kRRect:
// 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 fDeviceSpaceRRect.contains(rrect.getBounds()) || rrect == fDeviceSpaceRRect;
+ case DeviceSpaceType::kPath:
+ return fDeviceSpacePath.get()->conservativelyContainsRect(rrect.getBounds());
+ case DeviceSpaceType::kEmpty:
return false;
default:
SkDEBUGFAIL("Unexpected type.");
@@ -120,23 +118,23 @@ bool SkClipStack::Element::contains(const SkRRect& rrect) const {
}
void SkClipStack::Element::invertShapeFillType() {
- switch (fType) {
- case kRect_Type:
- fPath.init();
- fPath.get()->addRect(this->getRect());
- fPath.get()->setFillType(SkPath::kInverseEvenOdd_FillType);
- fType = kPath_Type;
+ switch (fDeviceSpaceType) {
+ case DeviceSpaceType::kRect:
+ fDeviceSpacePath.init();
+ fDeviceSpacePath.get()->addRect(this->getDeviceSpaceRect());
+ fDeviceSpacePath.get()->setFillType(SkPath::kInverseEvenOdd_FillType);
+ fDeviceSpaceType = DeviceSpaceType::kPath;
break;
- case kRRect_Type:
- fPath.init();
- fPath.get()->addRRect(fRRect);
- fPath.get()->setFillType(SkPath::kInverseEvenOdd_FillType);
- fType = kPath_Type;
+ case DeviceSpaceType::kRRect:
+ fDeviceSpacePath.init();
+ fDeviceSpacePath.get()->addRRect(fDeviceSpaceRRect);
+ fDeviceSpacePath.get()->setFillType(SkPath::kInverseEvenOdd_FillType);
+ fDeviceSpaceType = DeviceSpaceType::kPath;
break;
- case kPath_Type:
- fPath.get()->toggleInverseFillType();
+ case DeviceSpaceType::kPath:
+ fDeviceSpacePath.get()->toggleInverseFillType();
break;
- case kEmpty_Type:
+ case DeviceSpaceType::kEmpty:
// Should this set to an empty, inverse filled path?
break;
}
@@ -159,8 +157,8 @@ void SkClipStack::Element::initRect(int saveCount, const SkRect& rect, const SkM
if (m.rectStaysRect()) {
SkRect devRect;
m.mapRect(&devRect, rect);
- fRRect.setRect(devRect);
- fType = kRect_Type;
+ fDeviceSpaceRRect.setRect(devRect);
+ fDeviceSpaceType = DeviceSpaceType::kRect;
this->initCommon(saveCount, op, doAA);
return;
}
@@ -172,12 +170,12 @@ void SkClipStack::Element::initRect(int saveCount, const SkRect& rect, const SkM
void SkClipStack::Element::initRRect(int saveCount, const SkRRect& rrect, const SkMatrix& m,
SkClipOp op, bool doAA) {
- if (rrect.transform(m, &fRRect)) {
- SkRRect::Type type = fRRect.getType();
+ if (rrect.transform(m, &fDeviceSpaceRRect)) {
+ SkRRect::Type type = fDeviceSpaceRRect.getType();
if (SkRRect::kRect_Type == type || SkRRect::kEmpty_Type == type) {
- fType = kRect_Type;
+ fDeviceSpaceType = DeviceSpaceType::kRect;
} else {
- fType = kRRect_Type;
+ fDeviceSpaceType = DeviceSpaceType::kRRect;
}
this->initCommon(saveCount, op, doAA);
return;
@@ -209,42 +207,42 @@ void SkClipStack::Element::initPath(int saveCount, const SkPath& path, const SkM
void SkClipStack::Element::initAsPath(int saveCount, const SkPath& path, const SkMatrix& m,
SkClipOp op, bool doAA) {
- path.transform(m, fPath.init());
- fPath.get()->setIsVolatile(true);
- fType = kPath_Type;
+ path.transform(m, fDeviceSpacePath.init());
+ fDeviceSpacePath.get()->setIsVolatile(true);
+ fDeviceSpaceType = DeviceSpaceType::kPath;
this->initCommon(saveCount, op, doAA);
}
-void SkClipStack::Element::asPath(SkPath* path) const {
- switch (fType) {
- case kEmpty_Type:
+void SkClipStack::Element::asDeviceSpacePath(SkPath* path) const {
+ switch (fDeviceSpaceType) {
+ case DeviceSpaceType::kEmpty:
path->reset();
path->setIsVolatile(true);
break;
- case kRect_Type:
+ case DeviceSpaceType::kRect:
path->reset();
- path->addRect(this->getRect());
+ path->addRect(this->getDeviceSpaceRect());
path->setIsVolatile(true);
break;
- case kRRect_Type:
+ case DeviceSpaceType::kRRect:
path->reset();
- path->addRRect(fRRect);
+ path->addRRect(fDeviceSpaceRRect);
path->setIsVolatile(true);
break;
- case kPath_Type:
- *path = *fPath.get();
+ case DeviceSpaceType::kPath:
+ *path = *fDeviceSpacePath.get();
break;
}
path->setIsVolatile(true);
}
void SkClipStack::Element::setEmpty() {
- fType = kEmpty_Type;
+ fDeviceSpaceType = DeviceSpaceType::kEmpty;
fFiniteBound.setEmpty();
fFiniteBoundType = kNormal_BoundsType;
fIsIntersectionOfRects = false;
- fRRect.setEmpty();
- fPath.reset();
+ fDeviceSpaceRRect.setEmpty();
+ fDeviceSpacePath.reset();
fGenID = kEmptyGenID;
SkDEBUGCODE(this->checkEmpty();)
}
@@ -254,12 +252,12 @@ void SkClipStack::Element::checkEmpty() const {
SkASSERT(kNormal_BoundsType == fFiniteBoundType);
SkASSERT(!fIsIntersectionOfRects);
SkASSERT(kEmptyGenID == fGenID);
- SkASSERT(fRRect.isEmpty());
- SkASSERT(!fPath.isValid());
+ SkASSERT(fDeviceSpaceRRect.isEmpty());
+ SkASSERT(!fDeviceSpacePath.isValid());
}
bool SkClipStack::Element::canBeIntersectedInPlace(int saveCount, SkClipOp op) const {
- if (kEmpty_Type == fType &&
+ if (DeviceSpaceType::kEmpty == fDeviceSpaceType &&
(kDifference_SkClipOp == op || kIntersect_SkClipOp == op)) {
return true;
}
@@ -271,19 +269,19 @@ bool SkClipStack::Element::canBeIntersectedInPlace(int saveCount, SkClipOp op) c
}
bool SkClipStack::Element::rectRectIntersectAllowed(const SkRect& newR, bool newAA) const {
- SkASSERT(kRect_Type == fType);
+ SkASSERT(DeviceSpaceType::kRect == fDeviceSpaceType);
if (fDoAA == newAA) {
// if the AA setting is the same there is no issue
return true;
}
- if (!SkRect::Intersects(this->getRect(), newR)) {
+ if (!SkRect::Intersects(this->getDeviceSpaceRect(), newR)) {
// The calling code will correctly set the result to the empty clip
return true;
}
- if (this->getRect().contains(newR)) {
+ if (this->getDeviceSpaceRect().contains(newR)) {
// if the new rect carves out a portion of the old one there is no
// issue
return true;
@@ -476,32 +474,31 @@ void SkClipStack::Element::updateBoundAndGenID(const Element* prior) {
// First, optimistically update the current Element's bound information
// with the current clip's bound
fIsIntersectionOfRects = false;
- switch (fType) {
- case kRect_Type:
- fFiniteBound = this->getRect();
+ switch (fDeviceSpaceType) {
+ case DeviceSpaceType::kRect:
+ fFiniteBound = this->getDeviceSpaceRect();
fFiniteBoundType = kNormal_BoundsType;
- if (kReplace_SkClipOp == fOp ||
- (kIntersect_SkClipOp == fOp && nullptr == prior) ||
+ if (kReplace_SkClipOp == fOp || (kIntersect_SkClipOp == fOp && nullptr == prior) ||
(kIntersect_SkClipOp == fOp && prior->fIsIntersectionOfRects &&
- prior->rectRectIntersectAllowed(this->getRect(), fDoAA))) {
+ prior->rectRectIntersectAllowed(this->getDeviceSpaceRect(), fDoAA))) {
fIsIntersectionOfRects = true;
}
break;
- case kRRect_Type:
- fFiniteBound = fRRect.getBounds();
+ case DeviceSpaceType::kRRect:
+ fFiniteBound = fDeviceSpaceRRect.getBounds();
fFiniteBoundType = kNormal_BoundsType;
break;
- case kPath_Type:
- fFiniteBound = fPath.get()->getBounds();
+ case DeviceSpaceType::kPath:
+ fFiniteBound = fDeviceSpacePath.get()->getBounds();
- if (fPath.get()->isInverseFillType()) {
+ if (fDeviceSpacePath.get()->isInverseFillType()) {
fFiniteBoundType = kInsideOut_BoundsType;
} else {
fFiniteBoundType = kNormal_BoundsType;
}
break;
- case kEmpty_Type:
+ case DeviceSpaceType::kEmpty:
SkDEBUGFAIL("We shouldn't get here with an empty element.");
break;
}
@@ -763,8 +760,8 @@ bool SkClipStack::asPath(SkPath *path) const {
SkClipStack::Iter iter(*this, SkClipStack::Iter::kBottom_IterStart);
while (const SkClipStack::Element* element = iter.next()) {
SkPath operand;
- if (element->getType() != SkClipStack::Element::kEmpty_Type) {
- element->asPath(&operand);
+ if (element->getDeviceSpaceType() != SkClipStack::Element::DeviceSpaceType::kEmpty) {
+ element->asDeviceSpacePath(&operand);
}
SkClipOp elementOp = element->getOp();
@@ -790,20 +787,22 @@ void SkClipStack::pushElement(const Element& element) {
if (prior) {
if (prior->canBeIntersectedInPlace(fSaveCount, element.getOp())) {
- switch (prior->fType) {
- case Element::kEmpty_Type:
+ switch (prior->fDeviceSpaceType) {
+ case Element::DeviceSpaceType::kEmpty:
SkDEBUGCODE(prior->checkEmpty();)
return;
- case Element::kRect_Type:
- if (Element::kRect_Type == element.getType()) {
- if (prior->rectRectIntersectAllowed(element.getRect(), element.isAA())) {
+ case Element::DeviceSpaceType::kRect:
+ if (Element::DeviceSpaceType::kRect == element.getDeviceSpaceType()) {
+ if (prior->rectRectIntersectAllowed(element.getDeviceSpaceRect(),
+ element.isAA())) {
SkRect isectRect;
- if (!isectRect.intersect(prior->getRect(), element.getRect())) {
+ if (!isectRect.intersect(prior->getDeviceSpaceRect(),
+ element.getDeviceSpaceRect())) {
prior->setEmpty();
return;
}
- prior->fRRect.setRect(isectRect);
+ prior->fDeviceSpaceRRect.setRect(isectRect);
prior->fDoAA = element.isAA();
Element* priorPrior = (Element*) iter.prev();
prior->updateBoundAndGenID(priorPrior);
@@ -971,19 +970,19 @@ bool SkClipStack::isRRect(const SkRect& bounds, SkRRect* rrect, bool* aa) const
return false;
}
const Element* back = static_cast<const Element*>(fDeque.back());
- if (back->getType() != SkClipStack::Element::kRect_Type &&
- back->getType() != SkClipStack::Element::kRRect_Type) {
+ if (back->getDeviceSpaceType() != SkClipStack::Element::DeviceSpaceType::kRect &&
+ back->getDeviceSpaceType() != SkClipStack::Element::DeviceSpaceType::kRRect) {
return false;
}
if (back->getOp() == kReplace_SkClipOp) {
- *rrect = back->asRRect();
+ *rrect = back->asDeviceSpaceRRect();
*aa = back->isAA();
return true;
}
if (back->getOp() == kIntersect_SkClipOp) {
SkRect backBounds;
- if (!backBounds.intersect(bounds, back->asRRect().rect())) {
+ if (!backBounds.intersect(bounds, back->asDeviceSpaceRRect().rect())) {
return false;
}
if (cnt > 1) {
@@ -1000,7 +999,7 @@ bool SkClipStack::isRRect(const SkRect& bounds, SkRRect* rrect, bool* aa) const
}
}
}
- *rrect = back->asRRect();
+ *rrect = back->asDeviceSpaceRRect();
*aa = back->isAA();
return true;
}
@@ -1036,11 +1035,11 @@ void SkClipStack::Element::dump() const {
"rrect",
"path"
};
- static_assert(0 == kEmpty_Type, "type_str");
- static_assert(1 == kRect_Type, "type_str");
- static_assert(2 == kRRect_Type, "type_str");
- static_assert(3 == kPath_Type, "type_str");
- static_assert(SK_ARRAY_COUNT(kTypeStrings) == kTypeCnt, "type_str");
+ static_assert(0 == static_cast<int>(DeviceSpaceType::kEmpty), "enum mismatch");
+ static_assert(1 == static_cast<int>(DeviceSpaceType::kRect), "enum mismatch");
+ static_assert(2 == static_cast<int>(DeviceSpaceType::kRRect), "enum mismatch");
+ static_assert(3 == static_cast<int>(DeviceSpaceType::kPath), "enum mismatch");
+ static_assert(SK_ARRAY_COUNT(kTypeStrings) == kTypeCnt, "enum mismatch");
static const char* kOpStrings[] = {
"difference",
@@ -1050,30 +1049,30 @@ void SkClipStack::Element::dump() const {
"reverse-difference",
"replace",
};
- static_assert(0 == static_cast<int>(kDifference_SkClipOp), "op_str");
- static_assert(1 == static_cast<int>(kIntersect_SkClipOp), "op_str");
- static_assert(2 == static_cast<int>(kUnion_SkClipOp), "op_str");
- static_assert(3 == static_cast<int>(kXOR_SkClipOp), "op_str");
- static_assert(4 == static_cast<int>(kReverseDifference_SkClipOp), "op_str");
- static_assert(5 == static_cast<int>(kReplace_SkClipOp), "op_str");
- static_assert(SK_ARRAY_COUNT(kOpStrings) == SkRegion::kOpCnt, "op_str");
-
- SkDebugf("Type: %s, Op: %s, AA: %s, Save Count: %d\n", kTypeStrings[fType],
+ static_assert(0 == static_cast<int>(kDifference_SkClipOp), "enum mismatch");
+ static_assert(1 == static_cast<int>(kIntersect_SkClipOp), "enum mismatch");
+ static_assert(2 == static_cast<int>(kUnion_SkClipOp), "enum mismatch");
+ static_assert(3 == static_cast<int>(kXOR_SkClipOp), "enum mismatch");
+ static_assert(4 == static_cast<int>(kReverseDifference_SkClipOp), "enum mismatch");
+ static_assert(5 == static_cast<int>(kReplace_SkClipOp), "enum mismatch");
+ static_assert(SK_ARRAY_COUNT(kOpStrings) == SkRegion::kOpCnt, "enum mismatch");
+
+ SkDebugf("Type: %s, Op: %s, AA: %s, Save Count: %d\n", kTypeStrings[(int)fDeviceSpaceType],
kOpStrings[static_cast<int>(fOp)], (fDoAA ? "yes" : "no"), fSaveCount);
- switch (fType) {
- case kEmpty_Type:
+ switch (fDeviceSpaceType) {
+ case DeviceSpaceType::kEmpty:
SkDebugf("\n");
break;
- case kRect_Type:
- this->getRect().dump();
+ case DeviceSpaceType::kRect:
+ this->getDeviceSpaceRect().dump();
SkDebugf("\n");
break;
- case kRRect_Type:
- this->getRRect().dump();
+ case DeviceSpaceType::kRRect:
+ this->getDeviceSpaceRRect().dump();
SkDebugf("\n");
break;
- case kPath_Type:
- this->getPath().dump(nullptr, true, false);
+ case DeviceSpaceType::kPath:
+ this->getDeviceSpacePath().dump(nullptr, true, false);
break;
}
}
diff --git a/src/core/SkClipStack.h b/src/core/SkClipStack.h
index 84acb3c51c..050f30ed4e 100644
--- a/src/core/SkClipStack.h
+++ b/src/core/SkClipStack.h
@@ -41,21 +41,26 @@ public:
kInsideOut_BoundsType
};
+ /**
+ * An element of the clip stack. It represents a shape combined with the prevoius clip using a
+ * set operator. Each element can be antialiased or not.
+ */
class Element {
public:
- enum Type {
+ /** This indicates the shape type of the clip element in device space. */
+ enum class DeviceSpaceType {
//!< This element makes the clip empty (regardless of previous elements).
- kEmpty_Type,
- //!< This element combines a rect with the current clip using a set operation
- kRect_Type,
- //!< This element combines a round-rect with the current clip using a set operation
- kRRect_Type,
- //!< This element combines a path with the current clip using a set operation
- kPath_Type,
-
- kLastType = kPath_Type
+ kEmpty,
+ //!< This element combines a device space rect with the current clip.
+ kRect,
+ //!< This element combines a device space round-rect with the current clip.
+ kRRect,
+ //!< This element combines a device space path with the current clip.
+ kPath,
+
+ kLastType = kPath
};
- static const int kTypeCnt = kLastType + 1;
+ static const int kTypeCnt = (int)DeviceSpaceType::kLastType + 1;
Element() {
this->initCommon(0, kReplace_SkClipOp, false);
@@ -88,31 +93,42 @@ public:
bool operator!= (const Element& element) const { return !(*this == element); }
//!< Call to get the type of the clip element.
- Type getType() const { return fType; }
+ DeviceSpaceType getDeviceSpaceType() const { return fDeviceSpaceType; }
//!< Call to get the save count associated with this clip element.
int getSaveCount() const { return fSaveCount; }
- //!< Call if getType() is kPath to get the path.
- const SkPath& getPath() const { SkASSERT(kPath_Type == fType); return *fPath.get(); }
+ //!< Call if getDeviceSpaceType() is kPath to get the path.
+ const SkPath& getDeviceSpacePath() const {
+ SkASSERT(DeviceSpaceType::kPath == fDeviceSpaceType);
+ return *fDeviceSpacePath.get();
+ }
- //!< Call if getType() is kRRect to get the round-rect.
- const SkRRect& getRRect() const { SkASSERT(kRRect_Type == fType); return fRRect; }
+ //!< Call if getDeviceSpaceType() is kRRect to get the round-rect.
+ const SkRRect& getDeviceSpaceRRect() const {
+ SkASSERT(DeviceSpaceType::kRRect == fDeviceSpaceType);
+ return fDeviceSpaceRRect;
+ }
- //!< Call if getType() is kRect to get the rect.
- const SkRect& getRect() const {
- SkASSERT(kRect_Type == fType && (fRRect.isRect() || fRRect.isEmpty()));
- return fRRect.getBounds();
+ //!< Call if getDeviceSpaceType() is kRect to get the rect.
+ const SkRect& getDeviceSpaceRect() const {
+ SkASSERT(DeviceSpaceType::kRect == fDeviceSpaceType &&
+ (fDeviceSpaceRRect.isRect() || fDeviceSpaceRRect.isEmpty()));
+ return fDeviceSpaceRRect.getBounds();
}
- //!< Call if getType() is not kEmpty to get the set operation used to combine this element.
+ //!< Call if getDeviceSpaceType() is not kEmpty to get the set operation used to combine
+ //!< this element.
SkClipOp getOp() const { return fOp; }
//!< Call to get the element as a path, regardless of its type.
- void asPath(SkPath* path) const;
+ void asDeviceSpacePath(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; }
+ const SkRRect& asDeviceSpaceRRect() const {
+ SkASSERT(DeviceSpaceType::kPath != fDeviceSpaceType);
+ return fDeviceSpaceRRect;
+ }
/** If getType() is not kEmpty this indicates whether the clip shape should be anti-aliased
when it is rasterized. */
@@ -148,7 +164,8 @@ public:
* Is the clip shape inverse filled.
*/
bool isInverseFilled() const {
- return kPath_Type == fType && fPath.get()->isInverseFillType();
+ return DeviceSpaceType::kPath == fDeviceSpaceType &&
+ fDeviceSpacePath.get()->isInverseFillType();
}
#ifdef SK_DEBUG
@@ -173,11 +190,11 @@ public:
private:
friend class SkClipStack;
- SkTLazy<SkPath> fPath;
- SkRRect fRRect;
+ SkTLazy<SkPath> fDeviceSpacePath;
+ SkRRect fDeviceSpaceRRect;
int fSaveCount; // save count of stack when this element was added.
SkClipOp fOp;
- Type fType;
+ DeviceSpaceType fDeviceSpaceType;
bool fDoAA;
/* fFiniteBoundType and fFiniteBound are used to incrementally update the clip stack's