aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrStencilBuffer.cpp
diff options
context:
space:
mode:
authorGravatar bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-12-20 15:13:01 +0000
committerGravatar bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-12-20 15:13:01 +0000
commit0797c2cceadd7dfc2e7f9efa30b611d18efcdcdd (patch)
tree2fc86b2f5248e1977e8ffee9190d606947358a4f /src/gpu/GrStencilBuffer.cpp
parent0b6ad2297fbf43466950690102c1c9c150f2a972 (diff)
Reland 6914 w/ fixes.
git-svn-id: http://skia.googlecode.com/svn/trunk@6916 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/gpu/GrStencilBuffer.cpp')
-rw-r--r--src/gpu/GrStencilBuffer.cpp39
1 files changed, 18 insertions, 21 deletions
diff --git a/src/gpu/GrStencilBuffer.cpp b/src/gpu/GrStencilBuffer.cpp
index 180912e02d..623861df8f 100644
--- a/src/gpu/GrStencilBuffer.cpp
+++ b/src/gpu/GrStencilBuffer.cpp
@@ -13,7 +13,6 @@
#include "GrResourceCache.h"
SK_DEFINE_INST_COUNT(GrStencilBuffer)
-GR_DEFINE_RESOURCE_CACHE_TYPE(GrStencilBuffer)
void GrStencilBuffer::transferToCache() {
GrAssert(NULL == this->getCacheEntry());
@@ -22,30 +21,28 @@ void GrStencilBuffer::transferToCache() {
}
namespace {
-// we should never have more than one stencil buffer with same combo of
-// (width,height,samplecount)
-void gen_stencil_key_values(int width,
- int height,
- int sampleCnt,
- GrCacheID* cacheID) {
- cacheID->fPublicID = GrCacheID::kDefaultPublicCacheID;
- cacheID->fResourceSpecific32 = width | (height << 16);
- cacheID->fDomain = GrCacheData::kScratch_ResourceDomain;
-
- GrAssert(sampleCnt >= 0 && sampleCnt < 256);
- cacheID->fResourceSpecific16 = sampleCnt << 8;
-
- // last 8 bits of 'fResourceSpecific16' is free for flags
+// we should never have more than one stencil buffer with same combo of (width,height,samplecount)
+void gen_cache_id(int width, int height, int sampleCnt, GrCacheID* cacheID) {
+ static const GrCacheID::Domain gStencilBufferDomain = GrCacheID::GenerateDomain();
+ GrCacheID::Key key;
+ uint32_t* keyData = key.fData32;
+ keyData[0] = width;
+ keyData[1] = height;
+ keyData[2] = sampleCnt;
+ GR_STATIC_ASSERT(sizeof(key) >= 3 * sizeof(uint32_t));
+ cacheID->reset(gStencilBufferDomain, key);
}
}
GrResourceKey GrStencilBuffer::ComputeKey(int width,
int height,
int sampleCnt) {
- GrCacheID id(GrStencilBuffer::GetResourceType());
- gen_stencil_key_values(width, height, sampleCnt, &id);
-
- uint32_t v[4];
- id.toRaw(v);
- return GrResourceKey(v);
+ // All SBs are created internally to attach to RTs so they all use the same domain.
+ static const GrResourceKey::ResourceType gStencilBufferResourceType =
+ GrResourceKey::GenerateResourceType();
+ GrCacheID id;
+ gen_cache_id(width, height, sampleCnt, &id);
+
+ // we don't use any flags for SBs currently.
+ return GrResourceKey(id, gStencilBufferResourceType, 0);
}