Add GrStencilBuffer as a separate resource type from render target

This is a resubmission of the changes in r2026 with fixes for FBO completeness issues.

Review URL: http://codereview.appspot.com/4837046/


git-svn-id: http://skia.googlecode.com/svn/trunk@2035 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/gpu/include/GrRenderTarget.h b/gpu/include/GrRenderTarget.h
index a5616b9..06d62a4 100644
--- a/gpu/include/GrRenderTarget.h
+++ b/gpu/include/GrRenderTarget.h
@@ -18,10 +18,10 @@
 #ifndef GrRenderTarget_DEFINED
 #define GrRenderTarget_DEFINED
 
-#include "GrClip.h"
 #include "GrRect.h"
 #include "GrResource.h"
 
+class GrStencilBuffer;
 class GrTexture;
 
 /**
@@ -51,11 +51,6 @@
     int config() const { return fConfig; }
 
     /**
-     * @return the number of stencil bits in the rendertarget
-     */
-    int stencilBits() const { return fStencilBits; }
-
-    /**
      * @return the texture associated with the rendertarget, may be NULL.
      */
     GrTexture* asTexture() {return fTexture;}
@@ -145,20 +140,25 @@
     };
     virtual ResolveType getResolveType() const = 0;
 
+    /**
+     * GrStencilBuffer is not part of the public API.
+     */
+    GrStencilBuffer* getStencilBuffer() const { return fStencilBuffer; }
+    void setStencilBuffer(GrStencilBuffer* stencilBuffer);
+
 protected:
     GrRenderTarget(GrGpu* gpu,
                    GrTexture* texture,
                    int width,
                    int height,
                    GrPixelConfig config,
-                   int stencilBits,
                    int sampleCnt)
         : INHERITED(gpu)
+        , fStencilBuffer(NULL)
         , fTexture(texture)
         , fWidth(width)
         , fHeight(height)
         , fConfig(config)
-        , fStencilBits(stencilBits)
         , fSampleCnt(sampleCnt)
     {
         fResolveRect.setLargestInverted();
@@ -175,20 +175,16 @@
         fTexture = NULL;
     }
 
+    GrStencilBuffer*  fStencilBuffer;
+
 private:
-    GrTexture* fTexture; // not ref'ed
+    GrTexture*      fTexture; // not ref'ed
     int             fWidth;
     int             fHeight;
     GrPixelConfig   fConfig;
-    int             fStencilBits;
     int             fSampleCnt;
     GrIRect         fResolveRect;
 
-    // GrGpu keeps a cached clip in the render target to avoid redundantly
-    // rendering the clip into the same stencil buffer.
-    friend class GrGpu;
-    GrClip     fLastStencilClip;
-
     typedef GrResource INHERITED;
 };