diff options
author | 2011-08-08 17:01:14 +0000 | |
---|---|---|
committer | 2011-08-08 17:01:14 +0000 | |
commit | 558a75bcb323c03dd7482555c7214062a363276f (patch) | |
tree | 97f1d503a021a607f9d0776315b584b9e1b4cd1b /gpu/include | |
parent | f121b0525485fb18e96c4b9dbc57594c430e42f4 (diff) |
Use a single stencil buffer for a given width,height,samplecount
Review URL: http://codereview.appspot.com/4854044/
git-svn-id: http://skia.googlecode.com/svn/trunk@2061 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'gpu/include')
-rw-r--r-- | gpu/include/GrContext.h | 12 | ||||
-rw-r--r-- | gpu/include/GrRenderTarget.h | 24 | ||||
-rw-r--r-- | gpu/include/GrTexture.h | 4 |
3 files changed, 26 insertions, 14 deletions
diff --git a/gpu/include/GrContext.h b/gpu/include/GrContext.h index cb354f853b..b2928f8af2 100644 --- a/gpu/include/GrContext.h +++ b/gpu/include/GrContext.h @@ -21,6 +21,7 @@ class GrIndexBufferAllocPool; class GrInOrderDrawBuffer; class GrResourceEntry; class GrResourceCache; +class GrStencilBuffer; class GrVertexBufferAllocPool; @@ -580,6 +581,17 @@ public: void resetStats(); const GrGpuStats& getStats() const; void printStats() const; + /** + * Stencil buffers add themselves to the cache using + * addAndLockStencilBuffer. When a SB's RT-attachment count + * reaches zero the SB unlocks itself using unlockStencilBuffer and is + * eligible for purging. findStencilBuffer is called to check the cache for + * a SB that matching an RT's criteria. If a match is found that has been + * unlocked (its attachment count has reached 0) then it will be relocked. + */ + GrResourceEntry* addAndLockStencilBuffer(GrStencilBuffer* sb); + void unlockStencilBuffer(GrResourceEntry* sbEntry); + GrStencilBuffer* findStencilBuffer(int width, int height, int sampleCnt); private: // used to keep track of when we need to flush the draw buffer diff --git a/gpu/include/GrRenderTarget.h b/gpu/include/GrRenderTarget.h index 13b1a3acf1..6fa9f0f263 100644 --- a/gpu/include/GrRenderTarget.h +++ b/gpu/include/GrRenderTarget.h @@ -32,8 +32,8 @@ class GrTexture; * that wrap externally created render targets. */ class GrRenderTarget : public GrResource { - public: + /** * @return the width of the rendertarget */ @@ -177,8 +177,7 @@ protected: , fAllocatedWidth(allocatedWidth) , fAllocatedHeight(allocatedHeight) , fConfig(config) - , fSampleCnt(sampleCnt) - { + , fSampleCnt(sampleCnt) { fResolveRect.setLargestInverted(); } @@ -193,17 +192,16 @@ protected: fTexture = NULL; } - GrStencilBuffer* fStencilBuffer; - private: - GrTexture* fTexture; // not ref'ed - int fWidth; - int fHeight; - int fAllocatedWidth; - int fAllocatedHeight; - GrPixelConfig fConfig; - int fSampleCnt; - GrIRect fResolveRect; + GrStencilBuffer* fStencilBuffer; + GrTexture* fTexture; // not ref'ed + int fWidth; + int fHeight; + int fAllocatedWidth; + int fAllocatedHeight; + GrPixelConfig fConfig; + int fSampleCnt; + GrIRect fResolveRect; typedef GrResource INHERITED; }; diff --git a/gpu/include/GrTexture.h b/gpu/include/GrTexture.h index 77f88fa110..5a86b0881b 100644 --- a/gpu/include/GrTexture.h +++ b/gpu/include/GrTexture.h @@ -64,7 +64,9 @@ public: * Approximate number of bytes used by the texture */ virtual size_t sizeInBytes() const { - return fAllocatedWidth * fAllocatedHeight * GrBytesPerPixel(fConfig); + return (size_t) fAllocatedWidth * + fAllocatedHeight * + GrBytesPerPixel(fConfig); } /** |