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/GrGpu.h b/gpu/include/GrGpu.h
index ef03bdb..fff40fb 100644
--- a/gpu/include/GrGpu.h
+++ b/gpu/include/GrGpu.h
@@ -19,6 +19,7 @@
class GrContext;
class GrIndexBufferAllocPool;
class GrResource;
+class GrStencilBuffer;
class GrVertexBufferAllocPool;
/**
@@ -313,12 +314,13 @@
/**
* Called to tell Gpu object that all GrResources have been lost and should
- * be abandoned.
+ * be abandoned. Overrides must call INHERITED::abandonResources().
*/
virtual void abandonResources();
/**
- * Called to tell Gpu object to release all GrResources.
+ * Called to tell Gpu object to release all GrResources. Overrides must call
+ * INHERITED::releaseResources().
*/
void releaseResources();
@@ -469,6 +471,16 @@
int vertexCount,
int indexCount) = 0;
+ // width and height may be larger than rt (if underlying API allows it).
+ // Should attach the SB to the RT. Returns false if compatible sb could
+ // not be created.
+ virtual bool createStencilBufferForRenderTarget(GrRenderTarget* rt,
+ int width,
+ int height) = 0;
+
+ // attaches an existing SB to an existing RT.
+ virtual bool attachStencilBufferToRenderTarget(GrStencilBuffer* sb,
+ GrRenderTarget* rt) = 0;
// The GrGpu typically records the clients requested state and then flushes
// deltas from previous state at draw time. This function does the
@@ -513,6 +525,9 @@
GrResource* fResourceHead;
+ // Given a rt, find or create a stencil buffer and attach it
+ bool attachStencilBufferToRenderTarget(GrRenderTarget* target);
+
// GrDrawTarget overrides
virtual void onDrawIndexed(GrPrimitiveType type,
int startVertex,