aboutsummaryrefslogtreecommitdiffhomepage
path: root/bench
diff options
context:
space:
mode:
authorGravatar bsalomon <bsalomon@google.com>2014-11-14 06:29:40 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2014-11-14 06:29:40 -0800
commit407aa584d183c1bf314f5defd1cf0202e8a96c89 (patch)
tree9d2ba6989a9e0c86281337c5243c060ad4544e8d /bench
parent5ae776504fce25d320054390556526403068f103 (diff)
Replace GrResourceCache with GrResourceCache2.
Diffstat (limited to 'bench')
-rw-r--r--bench/GrResourceCacheBench.cpp32
1 files changed, 13 insertions, 19 deletions
diff --git a/bench/GrResourceCacheBench.cpp b/bench/GrResourceCacheBench.cpp
index 6d631ddb2c..ef97ed8971 100644
--- a/bench/GrResourceCacheBench.cpp
+++ b/bench/GrResourceCacheBench.cpp
@@ -13,7 +13,6 @@
#include "GrGpuResource.h"
#include "GrContext.h"
#include "GrGpu.h"
-#include "GrResourceCache.h"
#include "GrResourceCache2.h"
#include "GrStencilBuffer.h"
#include "GrTexture.h"
@@ -89,22 +88,20 @@ static void get_stencil(int i, int* w, int* h, int* s) {
}
static void get_texture_desc(int i, GrSurfaceDesc* desc) {
- desc->fFlags = kRenderTarget_GrSurfaceFlag |
- kNoStencil_GrSurfaceFlag;
+ desc->fFlags = kRenderTarget_GrSurfaceFlag | kNoStencil_GrSurfaceFlag;
desc->fWidth = i % 1024;
desc->fHeight = i * 2 % 1024;
desc->fConfig = static_cast<GrPixelConfig>(i % (kLast_GrPixelConfig + 1));
- desc->fSampleCnt = i % 1 == 0 ? 0 : 4;
+ desc->fSampleCnt = ((i % 2) == 0) ? 0 : 4;
}
-static void populate_cache(GrResourceCache* cache, GrGpu* gpu, int resourceCount) {
+static void populate_cache(GrGpu* gpu, int resourceCount) {
for (int i = 0; i < resourceCount; ++i) {
int w, h, s;
get_stencil(i, &w, &h, &s);
GrResourceKey key = GrStencilBuffer::ComputeKey(w, h, s);
GrGpuResource* resource = SkNEW_ARGS(StencilResource, (gpu, i));
- cache->purgeAsNeeded(1, resource->gpuMemorySize());
- cache->addResource(key, resource);
+ resource->cacheAccess().setContentKey(key);
resource->unref();
}
@@ -113,8 +110,7 @@ static void populate_cache(GrResourceCache* cache, GrGpu* gpu, int resourceCount
get_texture_desc(i, &desc);
GrResourceKey key = TextureResource::ComputeKey(desc);
GrGpuResource* resource = SkNEW_ARGS(TextureResource, (gpu, i));
- cache->purgeAsNeeded(1, resource->gpuMemorySize());
- cache->addResource(key, resource);
+ resource->cacheAccess().setContentKey(key);
resource->unref();
}
}
@@ -198,25 +194,24 @@ protected:
// Set the cache budget to be very large so no purging occurs.
context->setResourceCacheLimits(2 * RESOURCE_COUNT, 1 << 30);
- GrResourceCache* cache = context->getResourceCache();
GrResourceCache2* cache2 = context->getResourceCache2();
// Make sure the cache is empty.
- cache->purgeAllUnlocked();
- SkASSERT(0 == cache->getCachedResourceCount() && 0 == cache->getCachedResourceBytes());
+ cache2->purgeAllUnlocked();
+ SkASSERT(0 == cache2->getResourceCount() && 0 == cache2->getResourceBytes());
GrGpu* gpu = context->getGpu();
for (int i = 0; i < loops; ++i) {
- SkASSERT(0 == cache->getCachedResourceCount() && 0 == cache->getCachedResourceBytes());
+ SkASSERT(0 == cache2->getResourceCount() && 0 == cache2->getResourceBytes());
- populate_cache(cache, gpu, RESOURCE_COUNT);
+ populate_cache(gpu, RESOURCE_COUNT);
// Check that cache works.
for (int k = 0; k < RESOURCE_COUNT; k += 33) {
check_cache_contents_or_die(cache2, k);
}
- cache->purgeAllUnlocked();
+ cache2->purgeAllUnlocked();
}
}
@@ -247,16 +242,15 @@ protected:
// Set the cache budget to be very large so no purging occurs.
context->setResourceCacheLimits(2 * RESOURCE_COUNT, 1 << 30);
- GrResourceCache* cache = context->getResourceCache();
GrResourceCache2* cache2 = context->getResourceCache2();
// Make sure the cache is empty.
- cache->purgeAllUnlocked();
- SkASSERT(0 == cache->getCachedResourceCount() && 0 == cache->getCachedResourceBytes());
+ cache2->purgeAllUnlocked();
+ SkASSERT(0 == cache2->getResourceCount() && 0 == cache2->getResourceBytes());
GrGpu* gpu = context->getGpu();
- populate_cache(cache, gpu, RESOURCE_COUNT);
+ populate_cache(gpu, RESOURCE_COUNT);
for (int i = 0; i < loops; ++i) {
for (int k = 0; k < RESOURCE_COUNT; ++k) {