Propagated AA flags through Ganesh's clip stack (in preparation for GL AA clipping)
http://codereview.appspot.com/6038051/
git-svn-id: http://skia.googlecode.com/svn/trunk@3685 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/include/core/SkClipStack.h b/include/core/SkClipStack.h
index 306ba2a..5ad118c 100644
--- a/include/core/SkClipStack.h
+++ b/include/core/SkClipStack.h
@@ -49,7 +49,8 @@
B2FIter(const SkClipStack& stack);
struct Clip {
- Clip() : fRect(NULL), fPath(NULL), fOp(SkRegion::kIntersect_Op) {}
+ Clip() : fRect(NULL), fPath(NULL), fOp(SkRegion::kIntersect_Op),
+ fDoAA(false) {}
friend bool operator==(const Clip& a, const Clip& b);
friend bool operator!=(const Clip& a, const Clip& b);
const SkRect* fRect; // if non-null, this is a rect clip
diff --git a/include/gpu/GrClip.h b/include/gpu/GrClip.h
index d86eb97..a23f99c 100644
--- a/include/gpu/GrClip.h
+++ b/include/gpu/GrClip.h
@@ -39,6 +39,8 @@
const GrRect& getConservativeBounds() const { return fConservativeBounds; }
+ bool requiresAA() const { return fRequiresAA; }
+
int getElementCount() const { return fList.count(); }
GrClipType getElementType(int i) const { return fList[i].fType; }
@@ -60,6 +62,8 @@
GrSetOp getOp(int i) const { return fList[i].fOp; }
+ bool getDoAA(int i) const { return fList[i].fDoAA; }
+
bool isRect() const {
if (1 == fList.count() && kRect_ClipType == fList[0].fType &&
(kIntersect_SetOp == fList[0].fOp ||
@@ -112,8 +116,9 @@
GrPath fPath;
GrPathFill fPathFill;
GrSetOp fOp;
+ bool fDoAA;
bool operator ==(const Element& e) const {
- if (e.fType != fType || e.fOp != fOp) {
+ if (e.fType != fType || e.fOp != fOp || e.fDoAA != fDoAA) {
return false;
}
switch (fType) {
@@ -132,6 +137,8 @@
GrRect fConservativeBounds;
bool fConservativeBoundsValid;
+ bool fRequiresAA;
+
enum {
kPreAllocElements = 4,
};
diff --git a/include/gpu/GrClipIterator.h b/include/gpu/GrClipIterator.h
index 4a5cc71..a540bb4 100644
--- a/include/gpu/GrClipIterator.h
+++ b/include/gpu/GrClipIterator.h
@@ -61,6 +61,11 @@
virtual GrSetOp getOp() const = 0;
/**
+ * Gets anti-aliasing setting desired for the current clip
+ */
+ virtual bool getDoAA() const = 0;
+
+ /**
* Call to move to the next element in the list, previous path iter can be
* made invalid.
*/
diff --git a/include/gpu/SkGr.h b/include/gpu/SkGr.h
index f4dab53..6bc6549 100644
--- a/include/gpu/SkGr.h
+++ b/include/gpu/SkGr.h
@@ -103,14 +103,16 @@
void reset(const SkClipStack& clipStack);
// overrides
- virtual bool isDone() const { return NULL == fCurr; }
- virtual void next() { fCurr = fIter.next(); }
- virtual void rewind() { this->reset(*fClipStack); }
- virtual GrClipType getType() const;
+ virtual bool isDone() const SK_OVERRIDE { return NULL == fCurr; }
+ virtual void next() SK_OVERRIDE { fCurr = fIter.next(); }
+ virtual void rewind() SK_OVERRIDE { this->reset(*fClipStack); }
+ virtual GrClipType getType() const SK_OVERRIDE;
- virtual GrSetOp getOp() const;
+ virtual GrSetOp getOp() const SK_OVERRIDE;
- virtual void getRect(GrRect* rect) const {
+ virtual bool getDoAA() const SK_OVERRIDE;
+
+ virtual void getRect(GrRect* rect) const SK_OVERRIDE {
if (!fCurr->fRect) {
rect->setEmpty();
} else {
@@ -118,11 +120,11 @@
}
}
- virtual const GrPath* getPath() {
+ virtual const GrPath* getPath() SK_OVERRIDE {
return fCurr->fPath;
}
- virtual GrPathFill getPathFill() const;
+ virtual GrPathFill getPathFill() const SK_OVERRIDE;
private:
const SkClipStack* fClipStack;
@@ -132,46 +134,6 @@
const SkClipStack::B2FIter::Clip* fCurr;
};
-class SkGrRegionIterator : public GrClipIterator {
-public:
- SkGrRegionIterator() {}
- SkGrRegionIterator(const SkRegion& region) { this->reset(region); }
-
- void reset(const SkRegion& region) {
- fRegion = ®ion;
- fIter.reset(region);
- }
-
- // overrides
- virtual bool isDone() const { return fIter.done(); }
- virtual void next() { fIter.next(); }
- virtual void rewind() { this->reset(*fRegion); }
- virtual GrClipType getType() const { return kRect_ClipType; }
-
- virtual GrSetOp getOp() const { return kUnion_SetOp; }
-
- virtual void getRect(GrRect* rect) const {
- const SkIRect& r = fIter.rect();
- rect->fLeft = GrIntToScalar(r.fLeft);
- rect->fTop = GrIntToScalar(r.fTop);
- rect->fRight = GrIntToScalar(r.fRight);
- rect->fBottom = GrIntToScalar(r.fBottom);
- }
-
- virtual const GrPath* getPath() {
- SkASSERT(0);
- return NULL;
- }
-
- virtual GrPathFill getPathFill() const {
- SkASSERT(0);
- return kWinding_PathFill;
- }
-private:
- const SkRegion* fRegion;
- SkRegion::Iterator fIter;
-};
-
class SkGlyphCache;
class SkGrFontScaler : public GrFontScaler {
diff --git a/src/gpu/GrClip.cpp b/src/gpu/GrClip.cpp
index a02d9f4..87d58c4 100644
--- a/src/gpu/GrClip.cpp
+++ b/src/gpu/GrClip.cpp
@@ -10,7 +10,8 @@
#include "GrClip.h"
-GrClip::GrClip() {
+GrClip::GrClip()
+ : fRequiresAA(false) {
fConservativeBounds.setEmpty();
fConservativeBoundsValid = true;
}
@@ -38,6 +39,7 @@
fList = src.fList;
fConservativeBounds = src.fConservativeBounds;
fConservativeBoundsValid = src.fConservativeBoundsValid;
+ fRequiresAA = src.fRequiresAA;
return *this;
}
@@ -45,6 +47,7 @@
fList.reset();
fConservativeBounds.setEmpty();
fConservativeBoundsValid = true;
+ fRequiresAA = false;
}
void GrClip::setFromRect(const GrRect& r) {
@@ -57,6 +60,7 @@
fList.back().fRect = r;
fList.back().fType = kRect_ClipType;
fList.back().fOp = kReplace_SetOp;
+ fList.back().fDoAA = false;
fConservativeBounds = r;
fConservativeBoundsValid = true;
}
@@ -72,6 +76,7 @@
fList.back().fRect.set(r);
fList.back().fType = kRect_ClipType;
fList.back().fOp = kReplace_SetOp;
+ fList.back().fDoAA = false;
fConservativeBounds.set(r);
fConservativeBoundsValid = true;
}
@@ -86,6 +91,7 @@
void GrClip::setFromIterator(GrClipIterator* iter, GrScalar tx, GrScalar ty,
const GrRect* conservativeBounds) {
fList.reset();
+ fRequiresAA = false;
int rectCount = 0;
@@ -97,6 +103,10 @@
Element& e = fList.push_back();
e.fType = iter->getType();
e.fOp = iter->getOp();
+ e.fDoAA = iter->getDoAA();
+ if (e.fDoAA) {
+ fRequiresAA = true;
+ }
// iterators should not emit replace
GrAssert(kReplace_SetOp != e.fOp);
switch (e.fType) {
diff --git a/src/gpu/SkGr.cpp b/src/gpu/SkGr.cpp
index ba98e06..c832b20 100644
--- a/src/gpu/SkGr.cpp
+++ b/src/gpu/SkGr.cpp
@@ -181,6 +181,10 @@
return skToGrOps[fCurr->fOp];
}
+bool SkGrClipIterator::getDoAA() const {
+ return fCurr->fDoAA;
+}
+
GrPathFill SkGrClipIterator::getPathFill() const {
switch (fCurr->fPath->getFillType()) {
case SkPath::kWinding_FillType: