Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(342)

Unified Diff: bench/GrResourceCacheBench.cpp

Issue 715333003: Revert of Replace GrResourceCache with GrResourceCache2. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | gyp/gpu.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: bench/GrResourceCacheBench.cpp
diff --git a/bench/GrResourceCacheBench.cpp b/bench/GrResourceCacheBench.cpp
index ef97ed89711c9472c2c06b9cec5dfb4f47ad8224..6d631ddb2c4b62f74420a8c32f5c9816f7012403 100644
--- a/bench/GrResourceCacheBench.cpp
+++ b/bench/GrResourceCacheBench.cpp
@@ -13,6 +13,7 @@
#include "GrGpuResource.h"
#include "GrContext.h"
#include "GrGpu.h"
+#include "GrResourceCache.h"
#include "GrResourceCache2.h"
#include "GrStencilBuffer.h"
#include "GrTexture.h"
@@ -88,20 +89,22 @@
}
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 % 2) == 0) ? 0 : 4;
-}
-
-static void populate_cache(GrGpu* gpu, int resourceCount) {
+ desc->fSampleCnt = i % 1 == 0 ? 0 : 4;
+}
+
+static void populate_cache(GrResourceCache* 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));
- resource->cacheAccess().setContentKey(key);
+ cache->purgeAsNeeded(1, resource->gpuMemorySize());
+ cache->addResource(key, resource);
resource->unref();
}
@@ -110,7 +113,8 @@
get_texture_desc(i, &desc);
GrResourceKey key = TextureResource::ComputeKey(desc);
GrGpuResource* resource = SkNEW_ARGS(TextureResource, (gpu, i));
- resource->cacheAccess().setContentKey(key);
+ cache->purgeAsNeeded(1, resource->gpuMemorySize());
+ cache->addResource(key, resource);
resource->unref();
}
}
@@ -194,24 +198,25 @@
// 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.
- cache2->purgeAllUnlocked();
- SkASSERT(0 == cache2->getResourceCount() && 0 == cache2->getResourceBytes());
+ cache->purgeAllUnlocked();
+ SkASSERT(0 == cache->getCachedResourceCount() && 0 == cache->getCachedResourceBytes());
GrGpu* gpu = context->getGpu();
for (int i = 0; i < loops; ++i) {
- SkASSERT(0 == cache2->getResourceCount() && 0 == cache2->getResourceBytes());
-
- populate_cache(gpu, RESOURCE_COUNT);
+ SkASSERT(0 == cache->getCachedResourceCount() && 0 == cache->getCachedResourceBytes());
+
+ populate_cache(cache, gpu, RESOURCE_COUNT);
// Check that cache works.
for (int k = 0; k < RESOURCE_COUNT; k += 33) {
check_cache_contents_or_die(cache2, k);
}
- cache2->purgeAllUnlocked();
+ cache->purgeAllUnlocked();
}
}
@@ -242,15 +247,16 @@
// 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.
- cache2->purgeAllUnlocked();
- SkASSERT(0 == cache2->getResourceCount() && 0 == cache2->getResourceBytes());
+ cache->purgeAllUnlocked();
+ SkASSERT(0 == cache->getCachedResourceCount() && 0 == cache->getCachedResourceBytes());
GrGpu* gpu = context->getGpu();
- populate_cache(gpu, RESOURCE_COUNT);
+ populate_cache(cache, gpu, RESOURCE_COUNT);
for (int i = 0; i < loops; ++i) {
for (int k = 0; k < RESOURCE_COUNT; ++k) {
« no previous file with comments | « no previous file | gyp/gpu.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698