OLD | NEW |
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 Loading... |
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 Loading... |
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 |
OLD | NEW |