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

Side by Side Diff: tests/ImageFilterCacheTest.cpp

Issue 1901883002: Make SkImageFilter::Cache purging methods pure virtual (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 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 | « src/core/SkImageFilter.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 2016 Google Inc. 2 * Copyright 2016 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 "Test.h" 8 #include "Test.h"
9 9
10 #include "SkBitmap.h" 10 #include "SkBitmap.h"
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 static const size_t kCacheSize = 1000000; 106 static const size_t kCacheSize = 1000000;
107 SkAutoTUnref<SkImageFilter::Cache> cache(SkImageFilter::Cache::Create(kCache Size)); 107 SkAutoTUnref<SkImageFilter::Cache> cache(SkImageFilter::Cache::Create(kCache Size));
108 108
109 SkIRect clip = SkIRect::MakeWH(100, 100); 109 SkIRect clip = SkIRect::MakeWH(100, 100);
110 SkImageFilter::Cache::Key key1(0, SkMatrix::I(), clip, image->uniqueID(), im age->subset()); 110 SkImageFilter::Cache::Key key1(0, SkMatrix::I(), clip, image->uniqueID(), im age->subset());
111 SkImageFilter::Cache::Key key2(1, SkMatrix::I(), clip, subset->uniqueID(), i mage->subset()); 111 SkImageFilter::Cache::Key key2(1, SkMatrix::I(), clip, subset->uniqueID(), i mage->subset());
112 112
113 SkIPoint offset = SkIPoint::Make(3, 4); 113 SkIPoint offset = SkIPoint::Make(3, 4);
114 cache->set(key1, image.get(), offset); 114 cache->set(key1, image.get(), offset);
115 cache->set(key2, image.get(), offset); 115 cache->set(key2, image.get(), offset);
116 SkDEBUGCODE(REPORTER_ASSERT(reporter, 2 == cache->count());)
116 117
117 SkIPoint foundOffset; 118 SkIPoint foundOffset;
118 119
119 REPORTER_ASSERT(reporter, cache->get(key1, &foundOffset)); 120 REPORTER_ASSERT(reporter, cache->get(key1, &foundOffset));
120 REPORTER_ASSERT(reporter, cache->get(key2, &foundOffset)); 121 REPORTER_ASSERT(reporter, cache->get(key2, &foundOffset));
121 122
122 cache->purgeByKeys(&key1, 1); 123 cache->purgeByKeys(&key1, 1);
124 SkDEBUGCODE(REPORTER_ASSERT(reporter, 1 == cache->count());)
123 125
124 REPORTER_ASSERT(reporter, !cache->get(key1, &foundOffset)); 126 REPORTER_ASSERT(reporter, !cache->get(key1, &foundOffset));
125 REPORTER_ASSERT(reporter, cache->get(key2, &foundOffset)); 127 REPORTER_ASSERT(reporter, cache->get(key2, &foundOffset));
126 128
127 cache->purge(); 129 cache->purge();
130 SkDEBUGCODE(REPORTER_ASSERT(reporter, 0 == cache->count());)
128 131
129 REPORTER_ASSERT(reporter, !cache->get(key1, &foundOffset)); 132 REPORTER_ASSERT(reporter, !cache->get(key1, &foundOffset));
130 REPORTER_ASSERT(reporter, !cache->get(key2, &foundOffset)); 133 REPORTER_ASSERT(reporter, !cache->get(key2, &foundOffset));
131 } 134 }
132 135
133 DEF_TEST(ImageFilterCache_RasterBacked, reporter) { 136 DEF_TEST(ImageFilterCache_RasterBacked, reporter) {
134 SkBitmap srcBM = create_bm(); 137 SkBitmap srcBM = create_bm();
135 138
136 const SkIRect& full = SkIRect::MakeWH(kFullSize, kFullSize); 139 const SkIRect& full = SkIRect::MakeWH(kFullSize, kFullSize);
137 140
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 sk_sp<SkSpecialImage> subsetImg(SkSpecialImage::MakeFromGpu(nullptr, subset, 229 sk_sp<SkSpecialImage> subsetImg(SkSpecialImage::MakeFromGpu(nullptr, subset,
227 kNeedNewImageUni queID_SpecialImage, 230 kNeedNewImageUni queID_SpecialImage,
228 srcTexture)); 231 srcTexture));
229 232
230 test_find_existing(reporter, fullImg, subsetImg); 233 test_find_existing(reporter, fullImg, subsetImg);
231 test_dont_find_if_diff_key(reporter, fullImg, subsetImg); 234 test_dont_find_if_diff_key(reporter, fullImg, subsetImg);
232 test_internal_purge(reporter, fullImg); 235 test_internal_purge(reporter, fullImg);
233 test_explicit_purging(reporter, fullImg, subsetImg); 236 test_explicit_purging(reporter, fullImg, subsetImg);
234 } 237 }
235 #endif 238 #endif
OLDNEW
« no previous file with comments | « src/core/SkImageFilter.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698