aboutsummaryrefslogtreecommitdiffhomepage
path: root/gpu/include
diff options
context:
space:
mode:
authorGravatar bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-08-03 15:18:33 +0000
committerGravatar bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-08-03 15:18:33 +0000
commit81c3f8de1cbb93a8b99d730a75ab16d864612e95 (patch)
treed9bb1c0b461e7ab605e22e802267202ab4049ca6 /gpu/include
parentc49d66b04e0014f6b3be8346e4e4906d6807eb2d (diff)
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
Diffstat (limited to 'gpu/include')
-rw-r--r--gpu/include/GrGpu.h19
-rw-r--r--gpu/include/GrRenderTarget.h26
2 files changed, 28 insertions, 17 deletions
diff --git a/gpu/include/GrGpu.h b/gpu/include/GrGpu.h
index ef03bdbe3e..fff40fb147 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 @@ public:
/**
* 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 @@ protected:
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 @@ private:
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,
diff --git a/gpu/include/GrRenderTarget.h b/gpu/include/GrRenderTarget.h
index a5616b9895..06d62a40be 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 @@ public:
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 @@ public:
};
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 @@ protected:
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;
};