OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 #include "Test.h" | 7 #include "Test.h" |
8 #include "SkCanvas.h" | 8 #include "SkCanvas.h" |
9 #include "SkGraphics.h" | 9 #include "SkGraphics.h" |
10 #include "SkBitmapCache.h" | 10 #include "SkBitmapCache.h" |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 | 65 |
66 SkGraphics::SetResourceCacheTotalByteLimit(0); // clear cache | 66 SkGraphics::SetResourceCacheTotalByteLimit(0); // clear cache |
67 SkGraphics::SetResourceCacheTotalByteLimit(2 * size); | 67 SkGraphics::SetResourceCacheTotalByteLimit(2 * size); |
68 SkGraphics::SetResourceCacheSingleAllocationByteLimit(size / 2); // too sma
ll | 68 SkGraphics::SetResourceCacheSingleAllocationByteLimit(size / 2); // too sma
ll |
69 | 69 |
70 REPORTER_ASSERT(reporter, !test_scaled_image_cache_useage()); | 70 REPORTER_ASSERT(reporter, !test_scaled_image_cache_useage()); |
71 | 71 |
72 SkGraphics::SetResourceCacheSingleAllocationByteLimit(originalAllocationLimi
t); | 72 SkGraphics::SetResourceCacheSingleAllocationByteLimit(originalAllocationLimi
t); |
73 SkGraphics::SetResourceCacheTotalByteLimit(originalByteLimit); | 73 SkGraphics::SetResourceCacheTotalByteLimit(originalByteLimit); |
74 } | 74 } |
| 75 |
| 76 // http://skbug.com/2894 |
| 77 DEF_TEST(BitmapCache_add_rect, reporter) { |
| 78 SkBitmap bm; |
| 79 SkIRect rect = SkIRect::MakeWH(5, 5); |
| 80 |
| 81 SkBitmap cachedBitmap; |
| 82 cachedBitmap.setInfo(SkImageInfo::MakeN32Premul(5, 5)); |
| 83 SkBitmap::Allocator* allocator = SkBitmapCache::GetAllocator(); |
| 84 if (NULL != allocator) |
| 85 allocator->allocPixelRef(&cachedBitmap, 0); |
| 86 else |
| 87 cachedBitmap.allocPixels(); |
| 88 |
| 89 // Should not be in the cache |
| 90 REPORTER_ASSERT(reporter, !SkBitmapCache::Find(cachedBitmap.getGenerationID(
), rect, &bm)); |
| 91 |
| 92 SkBitmapCache::Add(cachedBitmap.getGenerationID(), rect, cachedBitmap); |
| 93 // Should be in the cache, we just added it |
| 94 REPORTER_ASSERT(reporter, SkBitmapCache::Find(cachedBitmap.getGenerationID()
, rect, &bm)); |
| 95 } |
OLD | NEW |