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

Unified Diff: tests/ResourceCacheTest.cpp

Issue 1286203002: Defer flushes if kPreferNoIO is specified (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: use explicit size in test Created 5 years, 4 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/gl/GrGLRenderTarget.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 43f087004fc42b0dc31b77767dde4abaf247dfb5..d5ee8454afd798837d4d5edc6b179ec17ac5a5ef 100644
--- a/tests/ResourceCacheTest.cpp
+++ b/tests/ResourceCacheTest.cpp
@@ -225,9 +225,9 @@ static void test_wrapped_resources(skiatest::Reporter* reporter, GrContext* cont
}
class TestResource : public GrGpuResource {
- static const size_t kDefaultSize = 100;
enum ScratchConstructor { kScratchConstructor };
public:
+ static const size_t kDefaultSize = 100;
/** Property that distinctly categorizes the resource.
* For example, textures have width, height, ... */
@@ -560,7 +560,7 @@ void test_unbudgeted_to_scratch(skiatest::Reporter* reporter);
REPORTER_ASSERT(reporter, resource->resourcePriv().getScratchKey() == key);
REPORTER_ASSERT(reporter, !resource->cacheAccess().isScratch());
REPORTER_ASSERT(reporter, !resource->resourcePriv().isBudgeted());
- REPORTER_ASSERT(reporter, NULL == cache->findAndRefScratchResource(key));
+ REPORTER_ASSERT(reporter, NULL == cache->findAndRefScratchResource(key, TestResource::kDefaultSize, 0));
REPORTER_ASSERT(reporter, 1 == cache->getResourceCount());
REPORTER_ASSERT(reporter, size == cache->getResourceBytes());
REPORTER_ASSERT(reporter, 0 == cache->getBudgetedResourceCount());
@@ -572,7 +572,7 @@ void test_unbudgeted_to_scratch(skiatest::Reporter* reporter);
REPORTER_ASSERT(reporter, size == cache->getResourceBytes());
REPORTER_ASSERT(reporter, 1 == cache->getBudgetedResourceCount());
REPORTER_ASSERT(reporter, size == cache->getBudgetedResourceBytes());
- resource = static_cast<TestResource*>(cache->findAndRefScratchResource(key));
+ resource = static_cast<TestResource*>(cache->findAndRefScratchResource(key, TestResource::kDefaultSize, 0));
REPORTER_ASSERT(reporter, resource);
REPORTER_ASSERT(reporter, resource->resourcePriv().getScratchKey() == key);
REPORTER_ASSERT(reporter, resource->cacheAccess().isScratch());
@@ -618,7 +618,7 @@ static void test_duplicate_scratch_key(skiatest::Reporter* reporter) {
GrScratchKey scratchKey1;
TestResource::ComputeScratchKey(TestResource::kA_SimulatedProperty, &scratchKey1);
// Check for negative case consistency. (leaks upon test failure.)
- REPORTER_ASSERT(reporter, NULL == cache->findAndRefScratchResource(scratchKey1));
+ REPORTER_ASSERT(reporter, NULL == cache->findAndRefScratchResource(scratchKey1, TestResource::kDefaultSize, 0));
GrScratchKey scratchKey;
TestResource::ComputeScratchKey(TestResource::kB_SimulatedProperty, &scratchKey);
@@ -665,7 +665,7 @@ static void test_remove_scratch_key(skiatest::Reporter* reporter) {
// 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) == NULL);
+ REPORTER_ASSERT(reporter, cache->findAndRefScratchResource(scratchKey, TestResource::kDefaultSize, 0) == NULL);
// Scratch resources are registered with GrResourceCache just by existing. There are 2.
TestResource::ComputeScratchKey(TestResource::kB_SimulatedProperty, &scratchKey);
@@ -675,7 +675,7 @@ static void test_remove_scratch_key(skiatest::Reporter* reporter) {
// Find the first resource and remove its scratch key
GrGpuResource* find;
- find = cache->findAndRefScratchResource(scratchKey);
+ find = cache->findAndRefScratchResource(scratchKey, TestResource::kDefaultSize, 0);
find->resourcePriv().removeScratchKey();
// It's still alive, but not cached by scratch key anymore
REPORTER_ASSERT(reporter, 2 == TestResource::NumAlive());
@@ -689,7 +689,7 @@ static void test_remove_scratch_key(skiatest::Reporter* reporter) {
REPORTER_ASSERT(reporter, 1 == cache->getResourceCount());
// Repeat for the second resource.
- find = cache->findAndRefScratchResource(scratchKey);
+ find = cache->findAndRefScratchResource(scratchKey, TestResource::kDefaultSize, 0);
find->resourcePriv().removeScratchKey();
REPORTER_ASSERT(reporter, 1 == TestResource::NumAlive());
SkDEBUGCODE(REPORTER_ASSERT(reporter, 0 == cache->countScratchEntriesForKey(scratchKey));)
@@ -745,20 +745,20 @@ static void test_scratch_key_consistency(skiatest::Reporter* reporter) {
// 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) == NULL);
+ REPORTER_ASSERT(reporter, cache->findAndRefScratchResource(scratchKey, TestResource::kDefaultSize, 0) == NULL);
// 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);
+ GrGpuResource* find = cache->findAndRefScratchResource(scratchKey, TestResource::kDefaultSize, 0);
REPORTER_ASSERT(reporter, find != NULL);
find->unref();
scratchKey2 = scratchKey;
- find = cache->findAndRefScratchResource(scratchKey2);
+ find = cache->findAndRefScratchResource(scratchKey2, TestResource::kDefaultSize, 0);
REPORTER_ASSERT(reporter, find != NULL);
REPORTER_ASSERT(reporter, find == a || find == b);
- GrGpuResource* find2 = cache->findAndRefScratchResource(scratchKey2);
+ GrGpuResource* find2 = cache->findAndRefScratchResource(scratchKey2, TestResource::kDefaultSize, 0);
REPORTER_ASSERT(reporter, find2 != NULL);
REPORTER_ASSERT(reporter, find2 == a || find2 == b);
REPORTER_ASSERT(reporter, find2 != find);
@@ -916,13 +916,13 @@ static void test_purge_invalidated(skiatest::Reporter* reporter) {
// 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);
+ GrGpuResource* scratch = cache->findAndRefScratchResource(scratchKey, TestResource::kDefaultSize, 0);
REPORTER_ASSERT(reporter, scratch == c);
SkSafeUnref(scratch);
// Get rid of c.
cache->purgeAllUnlocked();
- scratch = cache->findAndRefScratchResource(scratchKey);
+ scratch = cache->findAndRefScratchResource(scratchKey, TestResource::kDefaultSize, 0);
REPORTER_ASSERT(reporter, 0 == TestResource::NumAlive());
REPORTER_ASSERT(reporter, 0 == cache->getResourceCount());
REPORTER_ASSERT(reporter, 0 == cache->getResourceBytes());
« no previous file with comments | « src/gpu/gl/GrGLRenderTarget.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698