Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(223)

Side by Side Diff: tests/ScaledImageCache.cpp

Issue 511283002: rename ScaledImageCache to ResourceCache (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tests/ImageCacheTest.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 23 matching lines...) Expand all
34 paint.setFilterLevel(SkPaint::kHigh_FilterLevel); 34 paint.setFilterLevel(SkPaint::kHigh_FilterLevel);
35 35
36 canvas->drawBitmapRect(bitmap, 36 canvas->drawBitmapRect(bitmap,
37 SkRect::MakeLTRB(0, 0, scaledSize, scaledSize), 37 SkRect::MakeLTRB(0, 0, scaledSize, scaledSize),
38 &paint); 38 &paint);
39 39
40 return is_in_scaled_image_cache(bitmap, scale, scale); 40 return is_in_scaled_image_cache(bitmap, scale, scale);
41 } 41 }
42 42
43 // http://crbug.com/389439 43 // http://crbug.com/389439
44 DEF_TEST(ScaledImageCache_SingleAllocationByteLimit, reporter) { 44 DEF_TEST(ResourceCache_SingleAllocationByteLimit, reporter) {
45 size_t originalByteLimit = SkGraphics::GetImageCacheTotalByteLimit(); 45 size_t originalByteLimit = SkGraphics::GetResourceCacheTotalByteLimit();
46 size_t originalAllocationLimit = 46 size_t originalAllocationLimit =
47 SkGraphics::GetImageCacheSingleAllocationByteLimit(); 47 SkGraphics::GetResourceCacheSingleAllocationByteLimit();
48 48
49 size_t size = kBitmapSize * kScale * kBitmapSize * kScale 49 size_t size = kBitmapSize * kScale * kBitmapSize * kScale
50 * SkColorTypeBytesPerPixel(kN32_SkColorType); 50 * SkColorTypeBytesPerPixel(kN32_SkColorType);
51 51
52 SkGraphics::SetImageCacheTotalByteLimit(0); // clear cache 52 SkGraphics::SetResourceCacheTotalByteLimit(0); // clear cache
53 SkGraphics::SetImageCacheTotalByteLimit(2 * size); 53 SkGraphics::SetResourceCacheTotalByteLimit(2 * size);
54 SkGraphics::SetImageCacheSingleAllocationByteLimit(0); // No limit 54 SkGraphics::SetResourceCacheSingleAllocationByteLimit(0); // No limit
55 55
56 REPORTER_ASSERT(reporter, test_scaled_image_cache_useage()); 56 REPORTER_ASSERT(reporter, test_scaled_image_cache_useage());
57 57
58 SkGraphics::SetImageCacheTotalByteLimit(0); // clear cache 58 SkGraphics::SetResourceCacheTotalByteLimit(0); // clear cache
59 SkGraphics::SetImageCacheTotalByteLimit(2 * size); 59 SkGraphics::SetResourceCacheTotalByteLimit(2 * size);
60 SkGraphics::SetImageCacheSingleAllocationByteLimit(size * 2); // big enough 60 SkGraphics::SetResourceCacheSingleAllocationByteLimit(size * 2); // big eno ugh
61 61
62 REPORTER_ASSERT(reporter, test_scaled_image_cache_useage()); 62 REPORTER_ASSERT(reporter, test_scaled_image_cache_useage());
63 63
64 SkGraphics::SetImageCacheTotalByteLimit(0); // clear cache 64 SkGraphics::SetResourceCacheTotalByteLimit(0); // clear cache
65 SkGraphics::SetImageCacheTotalByteLimit(2 * size); 65 SkGraphics::SetResourceCacheTotalByteLimit(2 * size);
66 SkGraphics::SetImageCacheSingleAllocationByteLimit(size / 2); // too small 66 SkGraphics::SetResourceCacheSingleAllocationByteLimit(size / 2); // too sma ll
67 67
68 REPORTER_ASSERT(reporter, !test_scaled_image_cache_useage()); 68 REPORTER_ASSERT(reporter, !test_scaled_image_cache_useage());
69 69
70 SkGraphics::SetImageCacheSingleAllocationByteLimit(originalAllocationLimit); 70 SkGraphics::SetResourceCacheSingleAllocationByteLimit(originalAllocationLimi t);
71 SkGraphics::SetImageCacheTotalByteLimit(originalByteLimit); 71 SkGraphics::SetResourceCacheTotalByteLimit(originalByteLimit);
72 } 72 }
OLDNEW
« no previous file with comments | « tests/ImageCacheTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698