Add support for clipstack to Gr. GrClip is now a list of rects and paths with set operations to combine them. The stencil buffer is used to perform the set operations to put the clip into the stencil buffer. Building Gr's clip from Skia's clipStack is currently disabled due to the fact that Skia's clipStack is relative to the root layer not the current layer. This will be fixed in a subsequent CL.

git-svn-id: http://skia.googlecode.com/svn/trunk@878 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/include/core/SkCanvas.h b/include/core/SkCanvas.h
index 1e15307..eef3aea 100644
--- a/include/core/SkCanvas.h
+++ b/include/core/SkCanvas.h
@@ -794,7 +794,8 @@
     SkDevice*   fLastDeviceToGainFocus;
     SkDeviceFactory* fDeviceFactory;
 
-    void prepareForDeviceDraw(SkDevice*, const SkMatrix&, const SkRegion&);
+    void prepareForDeviceDraw(SkDevice*, const SkMatrix&, const SkRegion&,
+                              const SkClipStack& clipStack);
 
     bool fDeviceCMDirty;            // cleared by updateDeviceCMCache()
     void updateDeviceCMCache();
diff --git a/include/core/SkClipStack.h b/include/core/SkClipStack.h
index fb94155..db42e4d 100644
--- a/include/core/SkClipStack.h
+++ b/include/core/SkClipStack.h
@@ -29,6 +29,11 @@
 
     class B2FIter {
     public:
+        /**
+         * Creates an uninitialized iterator. Must be reset()
+         */
+        B2FIter();
+
         B2FIter(const SkClipStack& stack);
 
         struct Clip {
@@ -48,6 +53,11 @@
          */
         const Clip* next();
 
+        /**
+         * Restarts the iterator on a clip stack.
+         */
+        void reset(const SkClipStack& stack);
+
     private:
         Clip             fClip;
         SkDeque::F2BIter fIter;
diff --git a/include/core/SkDeque.h b/include/core/SkDeque.h
index 99c8dd4..92d5153 100644
--- a/include/core/SkDeque.h
+++ b/include/core/SkDeque.h
@@ -52,9 +52,16 @@
 public:
     class F2BIter {
     public:
+        /**
+         * Creates an uninitialized iterator. Must be reset()
+         */
+        F2BIter();
+
         F2BIter(const SkDeque& d);
         void* next();
 
+        void reset(const SkDeque& d);
+
     private:
         SkDeque::Head*  fHead;
         char*           fPos;
diff --git a/include/core/SkDevice.h b/include/core/SkDevice.h
index a790399..c0d71c3 100644
--- a/include/core/SkDevice.h
+++ b/include/core/SkDevice.h
@@ -141,7 +141,8 @@
     /** Called when this device gains focus (i.e becomes the current device
         for drawing).
     */
-    virtual void gainFocus(SkCanvas*, const SkMatrix&, const SkRegion&) {}
+    virtual void gainFocus(SkCanvas*, const SkMatrix&, const SkRegion&,
+                           const SkClipStack&) {}
 
     /** Causes any deferred drawing to the device to be completed.
      */
diff --git a/include/core/SkRegion.h b/include/core/SkRegion.h
index 8d9ff01..58f4f3f 100644
--- a/include/core/SkRegion.h
+++ b/include/core/SkRegion.h
@@ -260,7 +260,7 @@
         bool rewind();
         // reset the iterator, using the new region
         void reset(const SkRegion&);
-        bool done() { return fDone; }
+        bool done() const { return fDone; }
         void next();
         const SkIRect& rect() const { return fRect; }
         // may return null