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 "SkScaledImageCache.h" | 10 #include "SkBitmapCache.h" |
11 | 11 |
12 static const int kCanvasSize = 1; | 12 static const int kCanvasSize = 1; |
13 static const int kBitmapSize = 16; | 13 static const int kBitmapSize = 16; |
14 static const int kScale = 8; | 14 static const int kScale = 8; |
15 | 15 |
16 static bool is_in_scaled_image_cache(const SkBitmap& orig, | 16 static bool is_in_scaled_image_cache(const SkBitmap& orig, |
17 SkScalar xScale, | 17 SkScalar xScale, |
18 SkScalar yScale) { | 18 SkScalar yScale) { |
19 SkBitmap scaled; | 19 SkBitmap scaled; |
20 SkScaledImageCache::ID* id = SkScaledImageCache::FindAndLock( | 20 SkScaledImageCache::ID* id = SkBitmapCache::FindAndLock( |
21 orig, SkScalarInvert(xScale), SkScalarInvert(yScale), &scaled); | 21 orig, SkScalarInvert(xScale), SkScalarInvert(yScale), &scaled); |
22 if (id) { | 22 if (id) { |
23 SkScaledImageCache::Unlock(id); | 23 SkScaledImageCache::Unlock(id); |
24 } | 24 } |
25 return id != NULL; | 25 return id != NULL; |
26 } | 26 } |
27 | 27 |
28 // Draw a scaled bitmap, then return true iff it has been cached. | 28 // Draw a scaled bitmap, then return true iff it has been cached. |
29 static bool test_scaled_image_cache_useage() { | 29 static bool test_scaled_image_cache_useage() { |
30 SkAutoTUnref<SkCanvas> canvas( | 30 SkAutoTUnref<SkCanvas> canvas( |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 | 68 |
69 SkGraphics::SetImageCacheTotalByteLimit(0); // clear cache | 69 SkGraphics::SetImageCacheTotalByteLimit(0); // clear cache |
70 SkGraphics::SetImageCacheTotalByteLimit(2 * size); | 70 SkGraphics::SetImageCacheTotalByteLimit(2 * size); |
71 SkGraphics::SetImageCacheSingleAllocationByteLimit(size / 2); // too small | 71 SkGraphics::SetImageCacheSingleAllocationByteLimit(size / 2); // too small |
72 | 72 |
73 REPORTER_ASSERT(reporter, !test_scaled_image_cache_useage()); | 73 REPORTER_ASSERT(reporter, !test_scaled_image_cache_useage()); |
74 | 74 |
75 SkGraphics::SetImageCacheSingleAllocationByteLimit(originalAllocationLimit); | 75 SkGraphics::SetImageCacheSingleAllocationByteLimit(originalAllocationLimit); |
76 SkGraphics::SetImageCacheTotalByteLimit(originalByteLimit); | 76 SkGraphics::SetImageCacheTotalByteLimit(originalByteLimit); |
77 } | 77 } |
OLD | NEW |