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

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: update SkGraphics for the rename, add guard for chrome 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.
mtklein 2014/08/28 16:30:19 Let's follow up with renaming this file too?
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"
11 11
12 static const int kCanvasSize = 1; 12 static const int kCanvasSize = 1;
(...skipping 23 matching lines...) Expand all
36 paint.setFilterLevel(SkPaint::kHigh_FilterLevel); 36 paint.setFilterLevel(SkPaint::kHigh_FilterLevel);
37 37
38 canvas->drawBitmapRect(bitmap, 38 canvas->drawBitmapRect(bitmap,
39 SkRect::MakeLTRB(0, 0, scaledSize, scaledSize), 39 SkRect::MakeLTRB(0, 0, scaledSize, scaledSize),
40 &paint); 40 &paint);
41 41
42 return is_in_scaled_image_cache(bitmap, scale, scale); 42 return is_in_scaled_image_cache(bitmap, scale, scale);
43 } 43 }
44 44
45 // http://crbug.com/389439 45 // http://crbug.com/389439
46 DEF_TEST(ScaledImageCache_SingleAllocationByteLimit, reporter) { 46 DEF_TEST(ResourceCache_SingleAllocationByteLimit, reporter) {
47 size_t originalByteLimit = SkGraphics::GetImageCacheTotalByteLimit(); 47 size_t originalByteLimit = SkGraphics::GetResourceCacheTotalByteLimit();
48 size_t originalAllocationLimit = 48 size_t originalAllocationLimit =
49 SkGraphics::GetImageCacheSingleAllocationByteLimit(); 49 SkGraphics::GetResourceCacheSingleAllocationByteLimit();
50 50
51 size_t size = kBitmapSize * kScale * kBitmapSize * kScale 51 size_t size = kBitmapSize * kScale * kBitmapSize * kScale
52 * SkColorTypeBytesPerPixel(kN32_SkColorType); 52 * SkColorTypeBytesPerPixel(kN32_SkColorType);
53 53
54 SkGraphics::SetImageCacheTotalByteLimit(0); // clear cache 54 SkGraphics::SetResourceCacheTotalByteLimit(0); // clear cache
55 SkGraphics::SetImageCacheTotalByteLimit(2 * size); 55 SkGraphics::SetResourceCacheTotalByteLimit(2 * size);
56 SkGraphics::SetImageCacheSingleAllocationByteLimit(0); // No limit 56 SkGraphics::SetResourceCacheSingleAllocationByteLimit(0); // No limit
57 57
58 REPORTER_ASSERT(reporter, test_scaled_image_cache_useage()); 58 REPORTER_ASSERT(reporter, test_scaled_image_cache_useage());
59 59
60 SkGraphics::SetImageCacheTotalByteLimit(0); // clear cache 60 SkGraphics::SetResourceCacheTotalByteLimit(0); // clear cache
61 SkGraphics::SetImageCacheTotalByteLimit(2 * size); 61 SkGraphics::SetResourceCacheTotalByteLimit(2 * size);
62 SkGraphics::SetImageCacheSingleAllocationByteLimit(size * 2); // big enough 62 SkGraphics::SetResourceCacheSingleAllocationByteLimit(size * 2); // big eno ugh
63 63
64 REPORTER_ASSERT(reporter, test_scaled_image_cache_useage()); 64 REPORTER_ASSERT(reporter, test_scaled_image_cache_useage());
65 65
66 SkGraphics::SetImageCacheTotalByteLimit(0); // clear cache 66 SkGraphics::SetResourceCacheTotalByteLimit(0); // clear cache
67 SkGraphics::SetImageCacheTotalByteLimit(2 * size); 67 SkGraphics::SetResourceCacheTotalByteLimit(2 * size);
68 SkGraphics::SetImageCacheSingleAllocationByteLimit(size / 2); // too small 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::SetImageCacheSingleAllocationByteLimit(originalAllocationLimit); 72 SkGraphics::SetResourceCacheSingleAllocationByteLimit(originalAllocationLimi t);
73 SkGraphics::SetImageCacheTotalByteLimit(originalByteLimit); 73 SkGraphics::SetResourceCacheTotalByteLimit(originalByteLimit);
74 } 74 }
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