| 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 #include "Test.h" | 8 #include "Test.h" |
| 9 #include "TestClassDef.h" | 9 #include "TestClassDef.h" |
| 10 #include "SkDiscardableMemory.h" | 10 #include "SkDiscardableMemory.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 static void test_cache(skiatest::Reporter* reporter, SkScaledImageCache& cache, | 21 static void test_cache(skiatest::Reporter* reporter, SkScaledImageCache& cache, |
| 22 bool testPurge) { | 22 bool testPurge) { |
| 23 SkScaledImageCache::ID* id; | 23 SkScaledImageCache::ID* id; |
| 24 | 24 |
| 25 SkBitmap bm[COUNT]; | 25 SkBitmap bm[COUNT]; |
| 26 | 26 |
| 27 const SkScalar scale = 2; | 27 const SkScalar scale = 2; |
| 28 for (int i = 0; i < COUNT; ++i) { | 28 for (int i = 0; i < COUNT; ++i) { |
| 29 make_bm(&bm[i], DIM, DIM); | 29 make_bm(&bm[i], DIM, DIM); |
| 30 } | 30 } |
| 31 | 31 |
| 32 for (int i = 0; i < COUNT; ++i) { | 32 for (int i = 0; i < COUNT; ++i) { |
| 33 SkBitmap tmp; | 33 SkBitmap tmp; |
| 34 | 34 |
| 35 SkScaledImageCache::ID* id = cache.findAndLock(bm[i], scale, scale, &tmp
); | 35 SkScaledImageCache::ID* id = cache.findAndLock(bm[i], scale, scale, &tmp
); |
| 36 REPORTER_ASSERT(reporter, NULL == id); | 36 REPORTER_ASSERT(reporter, NULL == id); |
| 37 | 37 |
| 38 make_bm(&tmp, DIM, DIM); | 38 make_bm(&tmp, DIM, DIM); |
| 39 id = cache.addAndLock(bm[i], scale, scale, tmp); | 39 id = cache.addAndLock(bm[i], scale, scale, tmp); |
| 40 REPORTER_ASSERT(reporter, NULL != id); | 40 REPORTER_ASSERT(reporter, NULL != id); |
| 41 | 41 |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 SkBitmap scaled; | 116 SkBitmap scaled; |
| 117 scaled.setConfig(SkBitmap::kARGB_8888_Config, 20, 20); | 117 scaled.setConfig(SkBitmap::kARGB_8888_Config, 20, 20); |
| 118 scaled.allocPixels(); | 118 scaled.allocPixels(); |
| 119 | 119 |
| 120 SkScaledImageCache::ID* id1 = cache.addAndLock(original, 0.5f, 0.5f, scaled)
; | 120 SkScaledImageCache::ID* id1 = cache.addAndLock(original, 0.5f, 0.5f, scaled)
; |
| 121 SkScaledImageCache::ID* id2 = cache.addAndLock(original, 0.5f, 0.5f, scaled)
; | 121 SkScaledImageCache::ID* id2 = cache.addAndLock(original, 0.5f, 0.5f, scaled)
; |
| 122 // We don't really care if id1 == id2 as long as unlocking both works. | 122 // We don't really care if id1 == id2 as long as unlocking both works. |
| 123 cache.unlock(id1); | 123 cache.unlock(id1); |
| 124 cache.unlock(id2); | 124 cache.unlock(id2); |
| 125 } | 125 } |
| OLD | NEW |