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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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("ImageCache", TestImageCacheClass, TestImageCache) |
| 66 |
| 67 DEF_TEST(ImageCache_doubleAdd, r) { |
| 68 // Adding the same key twice should be safe. |
| 69 SkScaledImageCache cache(1024); |
| 70 |
| 71 SkBitmap original; |
| 72 original.setConfig(SkBitmap::kARGB_8888_Config, 40, 40); |
| 73 original.allocPixels(); |
| 74 |
| 75 SkBitmap scaled; |
| 76 scaled.setConfig(SkBitmap::kARGB_8888_Config, 20, 20); |
| 77 scaled.allocPixels(); |
| 78 |
| 79 SkScaledImageCache::ID* id1 = 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. |
| 82 cache.unlock(id1); |
| 83 cache.unlock(id2); |
| 84 } |
OLD | NEW |