Add specialized content key class for resources.
Review URL: https://codereview.chromium.org/858123002
diff --git a/bench/GrResourceCacheBench.cpp b/bench/GrResourceCacheBench.cpp
index 2a593c5..7469217 100644
--- a/bench/GrResourceCacheBench.cpp
+++ b/bench/GrResourceCacheBench.cpp
@@ -28,15 +28,12 @@
this->registerWithCache();
}
- static GrResourceKey ComputeKey(int i) {
- GrCacheID::Key key;
- memset(&key, 0, sizeof(key));
- key.fData32[0] = i;
- static int gDomain = GrCacheID::GenerateDomain();
- return GrResourceKey(GrCacheID(gDomain, key), 0);
+ static void ComputeKey(int i, GrContentKey* key) {
+ static GrContentKey::Domain kDomain = GrContentKey::GenerateDomain();
+ GrContentKey::Builder builder(key, kDomain, 1);
+ builder[0] = i;
}
-
private:
size_t onGpuMemorySize() const SK_OVERRIDE { return 100; }
@@ -45,7 +42,8 @@
static void populate_cache(GrGpu* gpu, int resourceCount) {
for (int i = 0; i < resourceCount; ++i) {
- GrResourceKey key = BenchResource::ComputeKey(i);
+ GrContentKey key;
+ BenchResource::ComputeKey(i, &key);
GrGpuResource* resource = SkNEW_ARGS(BenchResource, (gpu));
resource->cacheAccess().setContentKey(key);
resource->unref();
@@ -127,7 +125,8 @@
SkASSERT(CACHE_SIZE_COUNT == cache2->getResourceCount());
for (int i = 0; i < loops; ++i) {
for (int k = 0; k < CACHE_SIZE_COUNT; ++k) {
- GrResourceKey key = BenchResource::ComputeKey(k);
+ GrContentKey key;
+ BenchResource::ComputeKey(k, &key);
SkAutoTUnref<GrGpuResource> resource(cache2->findAndRefContentResource(key));
SkASSERT(resource);
}