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

Unified Diff: tests/ResourceCacheTest.cpp

Issue 91453002: Speed up GrResourceCache add and lookup by using TDynamicHash (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 years, 11 months 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 | « src/gpu/GrTMultiMap.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/ResourceCacheTest.cpp
diff --git a/tests/ResourceCacheTest.cpp b/tests/ResourceCacheTest.cpp
index c912ae07f4cda5315532ed0c28cc60b08d7c1a79..b60cde97bace54607109dd2be74e0e36f3cbe9d6 100644
--- a/tests/ResourceCacheTest.cpp
+++ b/tests/ResourceCacheTest.cpp
@@ -130,6 +130,52 @@ static void test_purge_invalidated(skiatest::Reporter* reporter, GrContext* cont
REPORTER_ASSERT(reporter, 0 == TestResource::alive());
}
+static void test_cache_delete_on_destruction(skiatest::Reporter* reporter,
+ GrContext* context) {
+ GrCacheID::Domain domain = GrCacheID::GenerateDomain();
+ GrCacheID::Key keyData;
+ keyData.fData64[0] = 5;
+ keyData.fData64[1] = 0;
+ GrResourceKey::ResourceType t = GrResourceKey::GenerateResourceType();
+
+ GrResourceKey key(GrCacheID(domain, keyData), t, 0);
+
+ {
+ {
+ GrResourceCache cache(3, 30000);
+ TestResource* a = new TestResource(context->getGpu());
+ TestResource* b = new TestResource(context->getGpu());
+ cache.addResource(key, a);
+ cache.addResource(key, b);
+
+ a->setDeleteWhenDestroyed(&cache, b);
+ b->setDeleteWhenDestroyed(&cache, a);
+
+ a->unref();
+ b->unref();
+ REPORTER_ASSERT(reporter, 2 == TestResource::alive());
+ }
+ REPORTER_ASSERT(reporter, 0 == TestResource::alive());
+ }
+ {
+ GrResourceCache cache(3, 30000);
+ TestResource* a = new TestResource(context->getGpu());
+ TestResource* b = new TestResource(context->getGpu());
+ cache.addResource(key, a);
+ cache.addResource(key, b);
+
+ a->setDeleteWhenDestroyed(&cache, b);
+ b->setDeleteWhenDestroyed(&cache, a);
+
+ a->unref();
+ b->unref();
+
+ cache.deleteResource(a->getCacheEntry());
+
+ REPORTER_ASSERT(reporter, 0 == TestResource::alive());
+ }
+}
+
////////////////////////////////////////////////////////////////////////////////
DEF_GPUTEST(ResourceCache, reporter, factory) {
for (int type = 0; type < GrContextFactory::kLastGLContextType; ++type) {
@@ -154,6 +200,7 @@ DEF_GPUTEST(ResourceCache, reporter, factory) {
test_cache(reporter, context, &canvas);
test_purge_invalidated(reporter, context);
+ test_cache_delete_on_destruction(reporter, context);
}
}
« no previous file with comments | « src/gpu/GrTMultiMap.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698