Added method of getting top genID from SkClipStack
authorrobertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Thu, 9 Aug 2012 18:10:49 +0000 (18:10 +0000)
committerrobertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Thu, 9 Aug 2012 18:10:49 +0000 (18:10 +0000)
http://codereview.appspot.com/6446108/

git-svn-id: http://skia.googlecode.com/svn/trunk@5034 2bbb7eff-a529-9590-31e7-b0007b416f81

include/core/SkClipStack.h
src/core/SkClipStack.cpp

index 077c4b7..7ebd492 100644 (file)
@@ -100,6 +100,8 @@ public:
     static const int32_t kEmptyGenID = 1;       // no pixels writeable
     static const int32_t kWideOpenGenID = 2;    // all pixels writeable
 
+    int32_t getTopmostGenID() const;
+
 private:
     struct Rec;
 
@@ -127,6 +129,7 @@ public:
             const SkPath*   fPath;  // if non-null, this is a path clip
             SkRegion::Op    fOp;
             bool            fDoAA;
+            int32_t         fGenID;
         };
 
         /**
index 25e8ced..ff771c1 100644 (file)
@@ -690,6 +690,7 @@ const SkClipStack::Iter::Clip* SkClipStack::Iter::updateClip(
     }
     fClip.fOp = rec->fOp;
     fClip.fDoAA = rec->fDoAA;
+    fClip.fGenID = rec->fGenID;
     return &fClip;
 }
 
@@ -812,3 +813,13 @@ void SkClipStack::purgeClip(Rec* rec) {
 int32_t SkClipStack::GetNextGenID() {
     return sk_atomic_inc(&gGenID);
 }
+
+int32_t SkClipStack::getTopmostGenID() const {
+
+    if (fDeque.empty()) {
+        return kInvalidGenID;
+    }
+
+    Rec* rec = (Rec*)fDeque.back();
+    return rec->fGenID;
+}