| 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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 | 75 |
| 76 #if 0 // skia:2912 |
| 77 |
| 76 static SkBitmap createAllocatedBitmap(const SkImageInfo& info) { | 78 static SkBitmap createAllocatedBitmap(const SkImageInfo& info) { |
| 77 SkBitmap cachedBitmap; | 79 SkBitmap cachedBitmap; |
| 78 cachedBitmap.setInfo(info); | 80 cachedBitmap.setInfo(info); |
| 79 SkBitmap::Allocator* allocator = SkBitmapCache::GetAllocator(); | 81 SkBitmap::Allocator* allocator = SkBitmapCache::GetAllocator(); |
| 80 if (NULL != allocator) { | 82 if (NULL != allocator) { |
| 81 allocator->allocPixelRef(&cachedBitmap, 0); | 83 allocator->allocPixelRef(&cachedBitmap, 0); |
| 82 } else { | 84 } else { |
| 83 cachedBitmap.allocPixels(); | 85 cachedBitmap.allocPixels(); |
| 84 } | 86 } |
| 85 | 87 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 100 REPORTER_ASSERT(reporter, ! SkBitmapCache::Add(cachedBitmap.getGenerationID(
), SkIRect::MakeXYWH(-1, 0, 5, 5), cachedBitmap)); | 102 REPORTER_ASSERT(reporter, ! SkBitmapCache::Add(cachedBitmap.getGenerationID(
), SkIRect::MakeXYWH(-1, 0, 5, 5), cachedBitmap)); |
| 101 REPORTER_ASSERT(reporter, ! SkBitmapCache::Find(cachedBitmap.getGenerationID
(), rect, &bm)); | 103 REPORTER_ASSERT(reporter, ! SkBitmapCache::Find(cachedBitmap.getGenerationID
(), rect, &bm)); |
| 102 | 104 |
| 103 // Should not be in the cache | 105 // Should not be in the cache |
| 104 REPORTER_ASSERT(reporter, !SkBitmapCache::Find(cachedBitmap.getGenerationID(
), rect, &bm)); | 106 REPORTER_ASSERT(reporter, !SkBitmapCache::Find(cachedBitmap.getGenerationID(
), rect, &bm)); |
| 105 | 107 |
| 106 REPORTER_ASSERT(reporter, SkBitmapCache::Add(cachedBitmap.getGenerationID(),
rect, cachedBitmap)); | 108 REPORTER_ASSERT(reporter, SkBitmapCache::Add(cachedBitmap.getGenerationID(),
rect, cachedBitmap)); |
| 107 // Should be in the cache, we just added it | 109 // Should be in the cache, we just added it |
| 108 REPORTER_ASSERT(reporter, SkBitmapCache::Find(cachedBitmap.getGenerationID()
, rect, &bm)); | 110 REPORTER_ASSERT(reporter, SkBitmapCache::Find(cachedBitmap.getGenerationID()
, rect, &bm)); |
| 109 } | 111 } |
| 112 #endif |
| OLD | NEW |