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

Side by Side Diff: tests/ResourceCacheTest.cpp

Issue 703303003: Add GrGpuResource::CacheAccess (Closed) Base URL: https://skia.googlesource.com/skia.git@nohash
Patch Set: fix warning Created 6 years, 1 month 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 unified diff | Download patch
« no previous file with comments | « src/gpu/GrStencilBuffer.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2013 Google Inc. 2 * Copyright 2013 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #if SK_SUPPORT_GPU 8 #if SK_SUPPORT_GPU
9 9
10 #include "GrContext.h" 10 #include "GrContext.h"
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 this->setScratchKey(scratchKey); 82 this->setScratchKey(scratchKey);
83 ++fNumAlive; 83 ++fNumAlive;
84 this->registerWithCache(); 84 this->registerWithCache();
85 } 85 }
86 86
87 ~TestResource() { 87 ~TestResource() {
88 --fNumAlive; 88 --fNumAlive;
89 if (fToDelete) { 89 if (fToDelete) {
90 // Breaks our little 2-element cycle below. 90 // Breaks our little 2-element cycle below.
91 fToDelete->setDeleteWhenDestroyed(NULL, NULL); 91 fToDelete->setDeleteWhenDestroyed(NULL, NULL);
92 fCache->deleteResource(fToDelete->getCacheEntry()); 92 fCache->deleteResource(fToDelete->cacheAccess().getCacheEntry());
93 } 93 }
94 this->release(); 94 this->release();
95 } 95 }
96 96
97 void setSize(size_t size) { 97 void setSize(size_t size) {
98 fSize = size; 98 fSize = size;
99 this->didChangeGpuMemorySize(); 99 this->didChangeGpuMemorySize();
100 } 100 }
101 101
102 size_t gpuMemorySize() const SK_OVERRIDE { return fSize; } 102 size_t gpuMemorySize() const SK_OVERRIDE { return fSize; }
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 TestResource* b = new TestResource(context->getGpu()); 338 TestResource* b = new TestResource(context->getGpu());
339 cache->addResource(key1, a); 339 cache->addResource(key1, a);
340 cache->addResource(key2, b); 340 cache->addResource(key2, b);
341 341
342 a->setDeleteWhenDestroyed(cache, b); 342 a->setDeleteWhenDestroyed(cache, b);
343 b->setDeleteWhenDestroyed(cache, a); 343 b->setDeleteWhenDestroyed(cache, a);
344 344
345 a->unref(); 345 a->unref();
346 b->unref(); 346 b->unref();
347 347
348 cache->deleteResource(a->getCacheEntry()); 348 cache->deleteResource(a->cacheAccess().getCacheEntry());
349 REPORTER_ASSERT(reporter, 0 == TestResource::NumAlive()); 349 REPORTER_ASSERT(reporter, 0 == TestResource::NumAlive());
350 } 350 }
351 } 351 }
352 352
353 static void test_resource_size_changed(skiatest::Reporter* reporter) { 353 static void test_resource_size_changed(skiatest::Reporter* reporter) {
354 SkAutoTUnref<GrContext> context(GrContext::CreateMockContext()); 354 SkAutoTUnref<GrContext> context(GrContext::CreateMockContext());
355 REPORTER_ASSERT(reporter, SkToBool(context)); 355 REPORTER_ASSERT(reporter, SkToBool(context));
356 if (NULL == context) { 356 if (NULL == context) {
357 return; 357 return;
358 } 358 }
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 456
457 // The below tests create their own mock contexts. 457 // The below tests create their own mock contexts.
458 test_duplicate_content_key(reporter); 458 test_duplicate_content_key(reporter);
459 test_duplicate_scratch_key(reporter); 459 test_duplicate_scratch_key(reporter);
460 test_purge_invalidated(reporter); 460 test_purge_invalidated(reporter);
461 test_cache_delete_on_destruction(reporter); 461 test_cache_delete_on_destruction(reporter);
462 test_resource_size_changed(reporter); 462 test_resource_size_changed(reporter);
463 } 463 }
464 464
465 #endif 465 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrStencilBuffer.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698