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

Unified Diff: tests/ResourceCacheTest.cpp

Issue 611383003: Revert of GrResourceCache2 manages scratch texture. (Closed) Base URL: https://skia.googlesource.com/skia.git@surfimpl
Patch Set: Created 6 years, 3 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/image/SkSurface_Gpu.cpp ('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 d62d09d9335749fee24486ca30baceb5dd164c0e..f9f94d1b274322eb35acd4806850855d4f44a7fc 100644
--- a/tests/ResourceCacheTest.cpp
+++ b/tests/ResourceCacheTest.cpp
@@ -246,6 +246,37 @@
REPORTER_ASSERT(reporter, 201 == cache.getCachedResourceBytes());
REPORTER_ASSERT(reporter, 1 == cache.getCachedResourceCount());
+ }
+
+ // Test changing the size of an exclusively-held resource.
+ {
+ GrResourceCache cache(2, 300);
+
+ TestResource* a = new TestResource(context->getGpu(), 100);
+ cache.addResource(key1, a);
+ cache.makeExclusive(a->getCacheEntry());
+
+ TestResource* b = new TestResource(context->getGpu(), 100);
+ cache.addResource(key2, b);
+ b->unref();
+
+ REPORTER_ASSERT(reporter, 200 == cache.getCachedResourceBytes());
+ REPORTER_ASSERT(reporter, 2 == cache.getCachedResourceCount());
+ REPORTER_ASSERT(reporter, NULL == cache.find(key1));
+
+ a->setSize(200);
+
+ REPORTER_ASSERT(reporter, 300 == cache.getCachedResourceBytes());
+ REPORTER_ASSERT(reporter, 2 == cache.getCachedResourceCount());
+ // Internal resource cache validation will test the detached size (debug mode only).
+
+ cache.makeNonExclusive(a->getCacheEntry());
+ a->unref();
+
+ REPORTER_ASSERT(reporter, 300 == cache.getCachedResourceBytes());
+ REPORTER_ASSERT(reporter, 2 == cache.getCachedResourceCount());
+ REPORTER_ASSERT(reporter, cache.find(key1));
+ // Internal resource cache validation will test the detached size (debug mode only).
}
}
« no previous file with comments | « src/image/SkSurface_Gpu.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698