Plumbing to propagate save & restore from SkCanvas down to GrContext & lower

http://codereview.appspot.com/6203067/



git-svn-id: http://skia.googlecode.com/svn/trunk@4034 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/include/gpu/GrContext.h b/include/gpu/GrContext.h
index 8a18331..e05c48a 100644
--- a/include/gpu/GrContext.h
+++ b/include/gpu/GrContext.h
@@ -680,6 +680,18 @@
     void unlockStencilBuffer(GrResourceEntry* sbEntry);
     GrStencilBuffer* findStencilBuffer(int width, int height, int sampleCnt);
 
+    /*
+     * postClipPush acts as a hint to this and lower-level classes (e.g.,
+     * GrGpu) that the clip stack has changed.
+     */
+    virtual void postClipPush();
+
+    /*
+     * preClipPop acts as a hint that the clip stack has been restored to an
+     * earlier state.
+     */
+    virtual void preClipPop();
+
     GrPathRenderer* getPathRenderer(const SkPath& path,
                                     GrPathFill fill,
                                     const GrDrawTarget* target,
diff --git a/include/gpu/SkGpuDevice.h b/include/gpu/SkGpuDevice.h
index ffc24a8..ee4d791 100644
--- a/include/gpu/SkGpuDevice.h
+++ b/include/gpu/SkGpuDevice.h
@@ -146,11 +146,18 @@
     // used by createCompatibleDevice
     SkGpuDevice(GrContext*, GrTexture* texture, TexCache, bool needClear);
 
-    // override from SkDevice
+    // overrides from SkDevice
+    virtual void postSave() SK_OVERRIDE {
+        fContext->postClipPush();
+    }
+    virtual void preRestore() SK_OVERRIDE {
+        fContext->preClipPop();
+    }
+
     virtual SkDevice* onCreateCompatibleDevice(SkBitmap::Config config,
                                                int width, int height,
                                                bool isOpaque,
-                                               Usage usage);
+                                               Usage usage) SK_OVERRIDE;
 
     SkDrawProcs* initDrawForText(GrTextContext*);
     bool bindDeviceAsTexture(GrPaint* paint);