Cleanup resource flags
Converts GrResourceProvider::Flags and GrResourceCache::ScratchFlags
to "enum class" and fixes a case where we were accidentally using the
wrong type of flag. Makes sure to allocate GrSWMaskHelper proxies with
kNoPendingIO.
Bug: skia:8351
Change-Id: Ibcaa26314a53d0cb31ae22915ab94ab0fc07e76d
Reviewed-on: https://skia-review.googlesource.com/157280
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Chris Dalton <csmartdalton@google.com>
diff --git a/tests/ResourceCacheTest.cpp b/tests/ResourceCacheTest.cpp
index 3dcf194..fa09db3 100644
--- a/tests/ResourceCacheTest.cpp
+++ b/tests/ResourceCacheTest.cpp
@@ -671,7 +671,7 @@
REPORTER_ASSERT(reporter, resource->resourcePriv().getScratchKey() == key);
REPORTER_ASSERT(reporter, !resource->cacheAccess().isScratch());
REPORTER_ASSERT(reporter, SkBudgeted::kNo == resource->resourcePriv().isBudgeted());
- REPORTER_ASSERT(reporter, nullptr == cache->findAndRefScratchResource(key, TestResource::kDefaultSize, 0));
+ REPORTER_ASSERT(reporter, nullptr == cache->findAndRefScratchResource(key, TestResource::kDefaultSize, GrResourceCache::ScratchFlags::kNone));
REPORTER_ASSERT(reporter, 1 == cache->getResourceCount());
REPORTER_ASSERT(reporter, size == cache->getResourceBytes());
REPORTER_ASSERT(reporter, 0 == cache->getBudgetedResourceCount());
@@ -685,7 +685,7 @@
REPORTER_ASSERT(reporter, 1 == cache->getBudgetedResourceCount());
REPORTER_ASSERT(reporter, size == cache->getBudgetedResourceBytes());
REPORTER_ASSERT(reporter, size == cache->getPurgeableBytes());
- resource = static_cast<TestResource*>(cache->findAndRefScratchResource(key, TestResource::kDefaultSize, 0));
+ resource = static_cast<TestResource*>(cache->findAndRefScratchResource(key, TestResource::kDefaultSize, GrResourceCache::ScratchFlags::kNone));
REPORTER_ASSERT(reporter, resource);
REPORTER_ASSERT(reporter, resource->resourcePriv().getScratchKey() == key);
REPORTER_ASSERT(reporter, resource->cacheAccess().isScratch());
@@ -734,7 +734,7 @@
GrScratchKey scratchKey1;
TestResource::ComputeScratchKey(TestResource::kA_SimulatedProperty, &scratchKey1);
// Check for negative case consistency. (leaks upon test failure.)
- REPORTER_ASSERT(reporter, nullptr == cache->findAndRefScratchResource(scratchKey1, TestResource::kDefaultSize, 0));
+ REPORTER_ASSERT(reporter, nullptr == cache->findAndRefScratchResource(scratchKey1, TestResource::kDefaultSize, GrResourceCache::ScratchFlags::kNone));
GrScratchKey scratchKey;
TestResource::ComputeScratchKey(TestResource::kB_SimulatedProperty, &scratchKey);
@@ -782,7 +782,7 @@
// Ensure that scratch key lookup is correct for negative case.
TestResource::ComputeScratchKey(TestResource::kA_SimulatedProperty, &scratchKey);
// (following leaks upon test failure).
- REPORTER_ASSERT(reporter, cache->findAndRefScratchResource(scratchKey, TestResource::kDefaultSize, 0) == nullptr);
+ REPORTER_ASSERT(reporter, cache->findAndRefScratchResource(scratchKey, TestResource::kDefaultSize, GrResourceCache::ScratchFlags::kNone) == nullptr);
// Scratch resources are registered with GrResourceCache just by existing. There are 2.
TestResource::ComputeScratchKey(TestResource::kB_SimulatedProperty, &scratchKey);
@@ -792,7 +792,7 @@
// Find the first resource and remove its scratch key
GrGpuResource* find;
- find = cache->findAndRefScratchResource(scratchKey, TestResource::kDefaultSize, 0);
+ find = cache->findAndRefScratchResource(scratchKey, TestResource::kDefaultSize, GrResourceCache::ScratchFlags::kNone);
find->resourcePriv().removeScratchKey();
// It's still alive, but not cached by scratch key anymore
REPORTER_ASSERT(reporter, 2 == TestResource::NumAlive());
@@ -806,7 +806,7 @@
REPORTER_ASSERT(reporter, 1 == cache->getResourceCount());
// Repeat for the second resource.
- find = cache->findAndRefScratchResource(scratchKey, TestResource::kDefaultSize, 0);
+ find = cache->findAndRefScratchResource(scratchKey, TestResource::kDefaultSize, GrResourceCache::ScratchFlags::kNone);
find->resourcePriv().removeScratchKey();
REPORTER_ASSERT(reporter, 1 == TestResource::NumAlive());
SkDEBUGCODE(REPORTER_ASSERT(reporter, 0 == cache->countScratchEntriesForKey(scratchKey));)
@@ -863,20 +863,20 @@
// Ensure that scratch key lookup is correct for negative case.
TestResource::ComputeScratchKey(TestResource::kA_SimulatedProperty, &scratchKey);
// (following leaks upon test failure).
- REPORTER_ASSERT(reporter, cache->findAndRefScratchResource(scratchKey, TestResource::kDefaultSize, 0) == nullptr);
+ REPORTER_ASSERT(reporter, cache->findAndRefScratchResource(scratchKey, TestResource::kDefaultSize, GrResourceCache::ScratchFlags::kNone) == nullptr);
// Find the first resource with a scratch key and a copy of a scratch key.
TestResource::ComputeScratchKey(TestResource::kB_SimulatedProperty, &scratchKey);
- GrGpuResource* find = cache->findAndRefScratchResource(scratchKey, TestResource::kDefaultSize, 0);
+ GrGpuResource* find = cache->findAndRefScratchResource(scratchKey, TestResource::kDefaultSize, GrResourceCache::ScratchFlags::kNone);
REPORTER_ASSERT(reporter, find != nullptr);
find->unref();
scratchKey2 = scratchKey;
- find = cache->findAndRefScratchResource(scratchKey2, TestResource::kDefaultSize, 0);
+ find = cache->findAndRefScratchResource(scratchKey2, TestResource::kDefaultSize, GrResourceCache::ScratchFlags::kNone);
REPORTER_ASSERT(reporter, find != nullptr);
REPORTER_ASSERT(reporter, find == a || find == b);
- GrGpuResource* find2 = cache->findAndRefScratchResource(scratchKey2, TestResource::kDefaultSize, 0);
+ GrGpuResource* find2 = cache->findAndRefScratchResource(scratchKey2, TestResource::kDefaultSize, GrResourceCache::ScratchFlags::kNone);
REPORTER_ASSERT(reporter, find2 != nullptr);
REPORTER_ASSERT(reporter, find2 == a || find2 == b);
REPORTER_ASSERT(reporter, find2 != find);
@@ -1032,13 +1032,13 @@
// Make sure we actually get to c via it's scratch key, before we say goodbye.
GrScratchKey scratchKey;
TestResource::ComputeScratchKey(TestResource::kA_SimulatedProperty, &scratchKey);
- GrGpuResource* scratch = cache->findAndRefScratchResource(scratchKey, TestResource::kDefaultSize, 0);
+ GrGpuResource* scratch = cache->findAndRefScratchResource(scratchKey, TestResource::kDefaultSize, GrResourceCache::ScratchFlags::kNone);
REPORTER_ASSERT(reporter, scratch == c);
SkSafeUnref(scratch);
// Get rid of c.
cache->purgeAllUnlocked();
- scratch = cache->findAndRefScratchResource(scratchKey, TestResource::kDefaultSize, 0);
+ scratch = cache->findAndRefScratchResource(scratchKey, TestResource::kDefaultSize, GrResourceCache::ScratchFlags::kNone);
REPORTER_ASSERT(reporter, 0 == TestResource::NumAlive());
REPORTER_ASSERT(reporter, 0 == cache->getResourceCount());
REPORTER_ASSERT(reporter, 0 == cache->getResourceBytes());