Let unbudgeted, unique keyed resources stay in gpu ResourceCache.
Also has some fixes to make sure we are allowing unique keys on uninstantiated
proxies and that we then forward those unique keys to resources during lazy
instantiation.
Bug: skia:
Change-Id: Ief33bc38dbe06a081123a86e33c69b239f5a862b
Reviewed-on: https://skia-review.googlesource.com/152980
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
diff --git a/tests/ResourceCacheTest.cpp b/tests/ResourceCacheTest.cpp
index 8d1228d..bd989cd 100644
--- a/tests/ResourceCacheTest.cpp
+++ b/tests/ResourceCacheTest.cpp
@@ -534,17 +534,18 @@
cache->getBudgetedResourceBytes());
REPORTER_ASSERT(reporter, 0 == cache->getPurgeableBytes());
- // Unreffing the wrapped resource should free it right away.
+ // Unreffing the wrapped resource with a unique key shouldn't free it right away.
wrapped->unref();
- REPORTER_ASSERT(reporter, 3 == cache->getResourceCount());
+ REPORTER_ASSERT(reporter, 4 == cache->getResourceCount());
REPORTER_ASSERT(reporter, scratch->gpuMemorySize() + unique->gpuMemorySize() +
- unbudgeted->gpuMemorySize() == cache->getResourceBytes());
- REPORTER_ASSERT(reporter, 0 == cache->getPurgeableBytes());
+ wrapped->gpuMemorySize() + unbudgeted->gpuMemorySize() ==
+ cache->getResourceBytes());
+ REPORTER_ASSERT(reporter, 12 == cache->getPurgeableBytes());
// Now try freeing the budgeted resources first
wrapped = TestResource::CreateWrapped(gpu);
unique->unref();
- REPORTER_ASSERT(reporter, 11 == cache->getPurgeableBytes());
+ REPORTER_ASSERT(reporter, 23 == cache->getPurgeableBytes());
cache->purgeAllUnlocked();
REPORTER_ASSERT(reporter, 3 == cache->getResourceCount());
REPORTER_ASSERT(reporter, scratch->gpuMemorySize() + wrapped->gpuMemorySize() +
@@ -563,6 +564,7 @@
REPORTER_ASSERT(reporter, 0 == cache->getBudgetedResourceBytes());
REPORTER_ASSERT(reporter, 0 == cache->getPurgeableBytes());
+ // Unreffing the wrapped resource (with no unique key) should free it right away.
wrapped->unref();
REPORTER_ASSERT(reporter, 1 == cache->getResourceCount());
REPORTER_ASSERT(reporter, unbudgeted->gpuMemorySize() == cache->getResourceBytes());