| OLD | NEW |
| 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 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 | 262 |
| 263 // Make sure sizes are as we expect | 263 // Make sure sizes are as we expect |
| 264 REPORTER_ASSERT(reporter, 4 == cache2->getResourceCount()); | 264 REPORTER_ASSERT(reporter, 4 == cache2->getResourceCount()); |
| 265 REPORTER_ASSERT(reporter, scratch->gpuMemorySize() + content->gpuMemorySize(
) + | 265 REPORTER_ASSERT(reporter, scratch->gpuMemorySize() + content->gpuMemorySize(
) + |
| 266 wrapped->gpuMemorySize() + unbudgeted->gpuMemorySi
ze() == | 266 wrapped->gpuMemorySize() + unbudgeted->gpuMemorySi
ze() == |
| 267 cache2->getResourceBytes()); | 267 cache2->getResourceBytes()); |
| 268 REPORTER_ASSERT(reporter, 2 == cache2->getBudgetedResourceCount()); | 268 REPORTER_ASSERT(reporter, 2 == cache2->getBudgetedResourceCount()); |
| 269 REPORTER_ASSERT(reporter, scratch->gpuMemorySize() + content->gpuMemorySize(
) == | 269 REPORTER_ASSERT(reporter, scratch->gpuMemorySize() + content->gpuMemorySize(
) == |
| 270 cache2->getBudgetedResourceBytes()); | 270 cache2->getBudgetedResourceBytes()); |
| 271 | 271 |
| 272 // Our refs mean that the resources are non purgable. | 272 // Our refs mean that the resources are non purgeable. |
| 273 cache2->purgeAllUnlocked(); | 273 cache2->purgeAllUnlocked(); |
| 274 REPORTER_ASSERT(reporter, 4 == cache2->getResourceCount()); | 274 REPORTER_ASSERT(reporter, 4 == cache2->getResourceCount()); |
| 275 REPORTER_ASSERT(reporter, scratch->gpuMemorySize() + content->gpuMemorySize(
) + | 275 REPORTER_ASSERT(reporter, scratch->gpuMemorySize() + content->gpuMemorySize(
) + |
| 276 wrapped->gpuMemorySize() + unbudgeted->gpuMemorySi
ze() == | 276 wrapped->gpuMemorySize() + unbudgeted->gpuMemorySi
ze() == |
| 277 cache2->getResourceBytes()); | 277 cache2->getResourceBytes()); |
| 278 REPORTER_ASSERT(reporter, 2 == cache2->getBudgetedResourceCount()); | 278 REPORTER_ASSERT(reporter, 2 == cache2->getBudgetedResourceCount()); |
| 279 REPORTER_ASSERT(reporter, scratch->gpuMemorySize() + content->gpuMemorySize(
) == | 279 REPORTER_ASSERT(reporter, scratch->gpuMemorySize() + content->gpuMemorySize(
) == |
| 280 cache2->getBudgetedResourceBytes()); | 280 cache2->getBudgetedResourceBytes()); |
| 281 | 281 |
| 282 // Unreffing the wrapped resource should free it right away. | 282 // Unreffing the wrapped resource should free it right away. |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 465 GrScratchKey scratchKey; | 465 GrScratchKey scratchKey; |
| 466 TestResource::ComputeScratchKey(TestResource::kProperty2_SimulatedProperty,
&scratchKey); | 466 TestResource::ComputeScratchKey(TestResource::kProperty2_SimulatedProperty,
&scratchKey); |
| 467 | 467 |
| 468 // Scratch resources are registered with GrResourceCache2 just by existing.
There are 2. | 468 // Scratch resources are registered with GrResourceCache2 just by existing.
There are 2. |
| 469 REPORTER_ASSERT(reporter, 2 == TestResource::NumAlive()); | 469 REPORTER_ASSERT(reporter, 2 == TestResource::NumAlive()); |
| 470 SkDEBUGCODE(REPORTER_ASSERT(reporter, 2 == cache2->countScratchEntriesForKey
(scratchKey));) | 470 SkDEBUGCODE(REPORTER_ASSERT(reporter, 2 == cache2->countScratchEntriesForKey
(scratchKey));) |
| 471 REPORTER_ASSERT(reporter, 2 == cache2->getResourceCount()); | 471 REPORTER_ASSERT(reporter, 2 == cache2->getResourceCount()); |
| 472 REPORTER_ASSERT(reporter, a->gpuMemorySize() + b->gpuMemorySize() == | 472 REPORTER_ASSERT(reporter, a->gpuMemorySize() + b->gpuMemorySize() == |
| 473 cache2->getResourceBytes()); | 473 cache2->getResourceBytes()); |
| 474 | 474 |
| 475 // Our refs mean that the resources are non purgable. | 475 // Our refs mean that the resources are non purgeable. |
| 476 cache2->purgeAllUnlocked(); | 476 cache2->purgeAllUnlocked(); |
| 477 REPORTER_ASSERT(reporter, 2 == TestResource::NumAlive()); | 477 REPORTER_ASSERT(reporter, 2 == TestResource::NumAlive()); |
| 478 REPORTER_ASSERT(reporter, 2 == cache2->getResourceCount()); | 478 REPORTER_ASSERT(reporter, 2 == cache2->getResourceCount()); |
| 479 | 479 |
| 480 // Unref but don't purge | 480 // Unref but don't purge |
| 481 a->unref(); | 481 a->unref(); |
| 482 b->unref(); | 482 b->unref(); |
| 483 REPORTER_ASSERT(reporter, 2 == TestResource::NumAlive()); | 483 REPORTER_ASSERT(reporter, 2 == TestResource::NumAlive()); |
| 484 SkDEBUGCODE(REPORTER_ASSERT(reporter, 2 == cache2->countScratchEntriesForKey
(scratchKey));) | 484 SkDEBUGCODE(REPORTER_ASSERT(reporter, 2 == cache2->countScratchEntriesForKey
(scratchKey));) |
| 485 | 485 |
| 486 // Purge again. This time resources should be purgable. | 486 // Purge again. This time resources should be purgeable. |
| 487 cache2->purgeAllUnlocked(); | 487 cache2->purgeAllUnlocked(); |
| 488 REPORTER_ASSERT(reporter, 0 == TestResource::NumAlive()); | 488 REPORTER_ASSERT(reporter, 0 == TestResource::NumAlive()); |
| 489 REPORTER_ASSERT(reporter, 0 == cache2->getResourceCount()); | 489 REPORTER_ASSERT(reporter, 0 == cache2->getResourceCount()); |
| 490 SkDEBUGCODE(REPORTER_ASSERT(reporter, 0 == cache2->countScratchEntriesForKey
(scratchKey));) | 490 SkDEBUGCODE(REPORTER_ASSERT(reporter, 0 == cache2->countScratchEntriesForKey
(scratchKey));) |
| 491 } | 491 } |
| 492 | 492 |
| 493 static void test_remove_scratch_key(skiatest::Reporter* reporter) { | 493 static void test_remove_scratch_key(skiatest::Reporter* reporter) { |
| 494 Mock mock(5, 30000); | 494 Mock mock(5, 30000); |
| 495 GrContext* context = mock.context(); | 495 GrContext* context = mock.context(); |
| 496 GrResourceCache2* cache2 = mock.cache(); | 496 GrResourceCache2* cache2 = mock.cache(); |
| (...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 904 test_duplicate_scratch_key(reporter); | 904 test_duplicate_scratch_key(reporter); |
| 905 test_remove_scratch_key(reporter); | 905 test_remove_scratch_key(reporter); |
| 906 test_scratch_key_consistency(reporter); | 906 test_scratch_key_consistency(reporter); |
| 907 test_purge_invalidated(reporter); | 907 test_purge_invalidated(reporter); |
| 908 test_cache_chained_purge(reporter); | 908 test_cache_chained_purge(reporter); |
| 909 test_resource_size_changed(reporter); | 909 test_resource_size_changed(reporter); |
| 910 test_large_resource_count(reporter); | 910 test_large_resource_count(reporter); |
| 911 } | 911 } |
| 912 | 912 |
| 913 #endif | 913 #endif |
| OLD | NEW |