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

Side by Side Diff: tests/ImageCacheTest.cpp

Issue 223403012: SkDiscardableMemoryPool to abstract class (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: AnotherPatchSet Created 6 years, 8 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/DrawBitmapRectTest.cpp ('k') | tools/bench_pictures_main.cpp » ('j') | 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 2013 Google Inc. 2 * Copyright 2013 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 7
8 #include "SkDiscardableMemory.h" 8 #include "SkDiscardableMemory.h"
9 #include "SkScaledImageCache.h" 9 #include "SkScaledImageCache.h"
10 #include "Test.h" 10 #include "Test.h"
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 } 74 }
75 } 75 }
76 76
77 cache.setByteLimit(0); 77 cache.setByteLimit(0);
78 } 78 }
79 79
80 #include "SkDiscardableMemoryPool.h" 80 #include "SkDiscardableMemoryPool.h"
81 81
82 static SkDiscardableMemoryPool* gPool; 82 static SkDiscardableMemoryPool* gPool;
83 static SkDiscardableMemory* pool_factory(size_t bytes) { 83 static SkDiscardableMemory* pool_factory(size_t bytes) {
84 SkASSERT(gPool);
84 return gPool->create(bytes); 85 return gPool->create(bytes);
85 } 86 }
86 87
87 DEF_TEST(ImageCache, reporter) { 88 DEF_TEST(ImageCache, reporter) {
88 static const size_t defLimit = DIM * DIM * 4 * COUNT + 1024; // 1K slop 89 static const size_t defLimit = DIM * DIM * 4 * COUNT + 1024; // 1K slop
89 90
90 { 91 {
91 SkScaledImageCache cache(defLimit); 92 SkScaledImageCache cache(defLimit);
92 test_cache(reporter, cache, true); 93 test_cache(reporter, cache, true);
93 } 94 }
94 { 95 {
95 SkDiscardableMemoryPool pool(defLimit); 96 SkAutoTUnref<SkDiscardableMemoryPool> pool(
96 gPool = &pool; 97 SkDiscardableMemoryPool::Create(defLimit, NULL));
98 gPool = pool.get();
97 SkScaledImageCache cache(pool_factory); 99 SkScaledImageCache cache(pool_factory);
98 test_cache(reporter, cache, true); 100 test_cache(reporter, cache, true);
99 } 101 }
100 { 102 {
101 SkScaledImageCache cache(SkDiscardableMemory::Create); 103 SkScaledImageCache cache(SkDiscardableMemory::Create);
102 test_cache(reporter, cache, false); 104 test_cache(reporter, cache, false);
103 } 105 }
104 } 106 }
105 107
106 DEF_TEST(ImageCache_doubleAdd, r) { 108 DEF_TEST(ImageCache_doubleAdd, r) {
(...skipping 15 matching lines...) Expand all
122 cache.unlock(id1); 124 cache.unlock(id1);
123 cache.unlock(id2); 125 cache.unlock(id2);
124 126
125 SkBitmap tmp; 127 SkBitmap tmp;
126 // Lookup should return the value that was added last. 128 // Lookup should return the value that was added last.
127 SkScaledImageCache::ID* id = cache.findAndLock(original, 0.5f, 0.5f, &tmp); 129 SkScaledImageCache::ID* id = cache.findAndLock(original, 0.5f, 0.5f, &tmp);
128 REPORTER_ASSERT(r, NULL != id); 130 REPORTER_ASSERT(r, NULL != id);
129 REPORTER_ASSERT(r, tmp.getGenerationID() == scaled2.getGenerationID()); 131 REPORTER_ASSERT(r, tmp.getGenerationID() == scaled2.getGenerationID());
130 cache.unlock(id); 132 cache.unlock(id);
131 } 133 }
OLDNEW
« no previous file with comments | « tests/DrawBitmapRectTest.cpp ('k') | tools/bench_pictures_main.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698