aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-02-21 20:09:13 +0000
committerGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-02-21 20:09:13 +0000
commit032a52fd4ceda001e44b80ff0462b570817bfe6f (patch)
tree1c1d1bc8266076bf029b1c134b3aa1337a29efd1
parent374ea4ee26b9d537c1b9635544105f915766f61b (diff)
Use SkRRect to store rects in SkClipStack::Element
BUG=skia:2181 R=robertphillips@google.com Author: bsalomon@google.com Review URL: https://codereview.chromium.org/163483003 git-svn-id: http://skia.googlecode.com/svn/trunk@13544 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r--include/core/SkClipStack.h19
-rw-r--r--src/core/SkClipStack.cpp19
2 files changed, 20 insertions, 18 deletions
diff --git a/include/core/SkClipStack.h b/include/core/SkClipStack.h
index a23ef4a5a5..5da53ae894 100644
--- a/include/core/SkClipStack.h
+++ b/include/core/SkClipStack.h
@@ -78,7 +78,10 @@ public:
const SkRRect& getRRect() const { SkASSERT(kRRect_Type == fType); return fRRect; }
//!< Call if getType() is kRect to get the rect.
- const SkRect& getRect() const { SkASSERT(kRect_Type == fType); return fRect; }
+ const SkRect& getRect() const {
+ SkASSERT(kRect_Type == fType && (fRRect.isRect() || fRRect.isEmpty()));
+ return fRRect.getBounds();
+ }
//!< Call if getType() is not kEmpty to get the set operation used to combine this element.
SkRegion::Op getOp() const { return fOp; }
@@ -110,8 +113,7 @@ public:
const SkRect& getBounds() const {
static const SkRect kEmpty = { 0, 0, 0, 0 };
switch (fType) {
- case kRect_Type:
- return fRect;
+ case kRect_Type: // fallthrough
case kRRect_Type:
return fRRect.getBounds();
case kPath_Type:
@@ -131,7 +133,7 @@ public:
bool contains(const SkRect& rect) const {
switch (fType) {
case kRect_Type:
- return fRect.contains(rect);
+ return this->getRect().contains(rect);
case kRRect_Type:
return fRRect.contains(rect);
case kPath_Type:
@@ -155,7 +157,6 @@ public:
friend class SkClipStack;
SkPath fPath;
- SkRect fRect;
SkRRect fRRect;
int fSaveCount; // save count of stack when this element was added.
SkRegion::Op fOp;
@@ -211,17 +212,17 @@ public:
}
void initRect(int saveCount, const SkRect& rect, SkRegion::Op op, bool doAA) {
- fRect = rect;
+ fRRect.setRect(rect);
fType = kRect_Type;
this->initCommon(saveCount, op, doAA);
}
void initRRect(int saveCount, const SkRRect& rrect, SkRegion::Op op, bool doAA) {
- if (rrect.isRect()) {
- fRect = rrect.getBounds();
+ SkRRect::Type type = rrect.getType();
+ fRRect = rrect;
+ if (SkRRect::kRect_Type == type || SkRRect::kEmpty_Type == type) {
fType = kRect_Type;
} else {
- fRRect = rrect;
fType = kRRect_Type;
}
this->initCommon(saveCount, op, doAA);
diff --git a/src/core/SkClipStack.cpp b/src/core/SkClipStack.cpp
index e5016977c9..7e67ddf2b4 100644
--- a/src/core/SkClipStack.cpp
+++ b/src/core/SkClipStack.cpp
@@ -32,7 +32,7 @@ bool SkClipStack::Element::operator== (const Element& element) const {
case kRRect_Type:
return fRRect == element.fRRect;
case kRect_Type:
- return fRect == element.fRect;
+ return this->getRect() == element.getRect();
case kEmpty_Type:
return true;
default:
@@ -45,7 +45,7 @@ void SkClipStack::Element::invertShapeFillType() {
switch (fType) {
case kRect_Type:
fPath.reset();
- fPath.addRect(fRect);
+ fPath.addRect(this->getRect());
fPath.setFillType(SkPath::kInverseEvenOdd_FillType);
fType = kPath_Type;
break;
@@ -91,7 +91,7 @@ void SkClipStack::Element::asPath(SkPath* path) const {
break;
case kRect_Type:
path->reset();
- path->addRect(fRect);
+ path->addRect(this->getRect());
break;
case kRRect_Type:
path->reset();
@@ -108,7 +108,6 @@ void SkClipStack::Element::setEmpty() {
fFiniteBound.setEmpty();
fFiniteBoundType = kNormal_BoundsType;
fIsIntersectionOfRects = false;
- fRect.setEmpty();
fRRect.setEmpty();
fPath.reset();
fGenID = kEmptyGenID;
@@ -143,12 +142,12 @@ bool SkClipStack::Element::rectRectIntersectAllowed(const SkRect& newR, bool new
return true;
}
- if (!SkRect::Intersects(fRect, newR)) {
+ if (!SkRect::Intersects(this->getRect(), newR)) {
// The calling code will correctly set the result to the empty clip
return true;
}
- if (fRect.contains(newR)) {
+ if (this->getRect().contains(newR)) {
// if the new rect carves out a portion of the old one there is no
// issue
return true;
@@ -343,13 +342,13 @@ void SkClipStack::Element::updateBoundAndGenID(const Element* prior) {
fIsIntersectionOfRects = false;
switch (fType) {
case kRect_Type:
- fFiniteBound = fRect;
+ fFiniteBound = this->getRect();
fFiniteBoundType = kNormal_BoundsType;
if (SkRegion::kReplace_Op == fOp ||
(SkRegion::kIntersect_Op == fOp && NULL == prior) ||
(SkRegion::kIntersect_Op == fOp && prior->fIsIntersectionOfRects &&
- prior->rectRectIntersectAllowed(fRect, fDoAA))) {
+ prior->rectRectIntersectAllowed(this->getRect(), fDoAA))) {
fIsIntersectionOfRects = true;
}
break;
@@ -632,11 +631,13 @@ void SkClipStack::pushElement(const Element& element) {
case Element::kRect_Type:
if (Element::kRect_Type == element.getType()) {
if (prior->rectRectIntersectAllowed(element.getRect(), element.isAA())) {
- if (!prior->fRect.intersect(element.getRect())) {
+ SkRect isectRect;
+ if (!isectRect.intersect(prior->getRect(), element.getRect())) {
prior->setEmpty();
return;
}
+ prior->fRRect.setRect(isectRect);
prior->fDoAA = element.isAA();
Element* priorPrior = (Element*) iter.prev();
prior->updateBoundAndGenID(priorPrior);