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 "SkScaledImageCache.h" | 9 #include "SkScaledImageCache.h" |
10 | 10 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 make_bm(&tmp, DIM, DIM); | 55 make_bm(&tmp, DIM, DIM); |
56 id = cache.addAndLock(bm[0], scale, scale, tmp); | 56 id = cache.addAndLock(bm[0], scale, scale, tmp); |
57 REPORTER_ASSERT(reporter, NULL != id); | 57 REPORTER_ASSERT(reporter, NULL != id); |
58 cache.unlock(id); | 58 cache.unlock(id); |
59 } | 59 } |
60 | 60 |
61 cache.setByteLimit(0); | 61 cache.setByteLimit(0); |
62 } | 62 } |
63 | 63 |
64 #include "TestClassDef.h" | 64 #include "TestClassDef.h" |
65 DEFINE_TESTCLASS("ImageCache", TestImageCacheClass, TestImageCache) | 65 DEFINE_TESTCLASS_SHORT(TestImageCache) |
66 | 66 |
67 DEF_TEST(ImageCache_doubleAdd, r) { | 67 DEF_TEST(ImageCache_doubleAdd, r) { |
68 // Adding the same key twice should be safe. | 68 // Adding the same key twice should be safe. |
69 SkScaledImageCache cache(1024); | 69 SkScaledImageCache cache(1024); |
70 | 70 |
71 SkBitmap original; | 71 SkBitmap original; |
72 original.setConfig(SkBitmap::kARGB_8888_Config, 40, 40); | 72 original.setConfig(SkBitmap::kARGB_8888_Config, 40, 40); |
73 original.allocPixels(); | 73 original.allocPixels(); |
74 | 74 |
75 SkBitmap scaled; | 75 SkBitmap scaled; |
76 scaled.setConfig(SkBitmap::kARGB_8888_Config, 20, 20); | 76 scaled.setConfig(SkBitmap::kARGB_8888_Config, 20, 20); |
77 scaled.allocPixels(); | 77 scaled.allocPixels(); |
78 | 78 |
79 SkScaledImageCache::ID* id1 = cache.addAndLock(original, 0.5f, 0.5f, scaled)
; | 79 SkScaledImageCache::ID* id1 = cache.addAndLock(original, 0.5f, 0.5f, scaled)
; |
80 SkScaledImageCache::ID* id2 = cache.addAndLock(original, 0.5f, 0.5f, scaled)
; | 80 SkScaledImageCache::ID* id2 = cache.addAndLock(original, 0.5f, 0.5f, scaled)
; |
81 // We don't really care if id1 == id2 as long as unlocking both works. | 81 // We don't really care if id1 == id2 as long as unlocking both works. |
82 cache.unlock(id1); | 82 cache.unlock(id1); |
83 cache.unlock(id2); | 83 cache.unlock(id2); |
84 } | 84 } |
OLD | NEW |