diff options
author | robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-04-16 14:49:14 +0000 |
---|---|---|
committer | robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-04-16 14:49:14 +0000 |
commit | fa1d29112d44d0728cd10e2ff1f8982240303272 (patch) | |
tree | bb1d4b98f1ce03d3b61e1e3e7c930cd3ab97975f | |
parent | d0b95896d66422444f787825cf78d384b8643d4d (diff) |
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
-rw-r--r-- | include/core/SkClipStack.h | 3 | ||||
-rw-r--r-- | include/gpu/GrClip.h | 9 | ||||
-rw-r--r-- | include/gpu/GrClipIterator.h | 5 | ||||
-rw-r--r-- | include/gpu/SkGr.h | 58 | ||||
-rw-r--r-- | src/gpu/GrClip.cpp | 12 | ||||
-rw-r--r-- | src/gpu/SkGr.cpp | 4 |
6 files changed, 40 insertions, 51 deletions
diff --git a/include/core/SkClipStack.h b/include/core/SkClipStack.h index 306ba2a490..5ad118cb20 100644 --- a/include/core/SkClipStack.h +++ b/include/core/SkClipStack.h @@ -49,7 +49,8 @@ public: 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 d86eb978c7..a23f99c1ce 100644 --- a/include/gpu/GrClip.h +++ b/include/gpu/GrClip.h @@ -39,6 +39,8 @@ public: 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 @@ public: 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 @@ private: 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 @@ private: GrRect fConservativeBounds; bool fConservativeBoundsValid; + bool fRequiresAA; + enum { kPreAllocElements = 4, }; diff --git a/include/gpu/GrClipIterator.h b/include/gpu/GrClipIterator.h index 4a5cc7135f..a540bb4251 100644 --- a/include/gpu/GrClipIterator.h +++ b/include/gpu/GrClipIterator.h @@ -61,6 +61,11 @@ public: 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 f4dab532ed..6bc65499a2 100644 --- a/include/gpu/SkGr.h +++ b/include/gpu/SkGr.h @@ -103,14 +103,16 @@ public: 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 @@ public: } } - 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 @@ private: 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 a02d9f4504..87d58c4010 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 @@ GrClip& GrClip::operator=(const GrClip& src) { fList = src.fList; fConservativeBounds = src.fConservativeBounds; fConservativeBoundsValid = src.fConservativeBoundsValid; + fRequiresAA = src.fRequiresAA; return *this; } @@ -45,6 +47,7 @@ void GrClip::setEmpty() { fList.reset(); fConservativeBounds.setEmpty(); fConservativeBoundsValid = true; + fRequiresAA = false; } void GrClip::setFromRect(const GrRect& r) { @@ -57,6 +60,7 @@ void GrClip::setFromRect(const GrRect& r) { 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 @@ void GrClip::setFromIRect(const GrIRect& r) { 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 @@ static void intersectWith(SkRect* dst, const SkRect& src) { void GrClip::setFromIterator(GrClipIterator* iter, GrScalar tx, GrScalar ty, const GrRect* conservativeBounds) { fList.reset(); + fRequiresAA = false; int rectCount = 0; @@ -97,6 +103,10 @@ void GrClip::setFromIterator(GrClipIterator* iter, GrScalar tx, GrScalar ty, 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 ba98e06f8f..c832b20866 100644 --- a/src/gpu/SkGr.cpp +++ b/src/gpu/SkGr.cpp @@ -181,6 +181,10 @@ GrSetOp SkGrClipIterator::getOp() const { return skToGrOps[fCurr->fOp]; } +bool SkGrClipIterator::getDoAA() const { + return fCurr->fDoAA; +} + GrPathFill SkGrClipIterator::getPathFill() const { switch (fCurr->fPath->getFillType()) { case SkPath::kWinding_FillType: |