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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 SkIPoint foundOffset; | 71 SkIPoint foundOffset; |
72 REPORTER_ASSERT(reporter, !cache->get(key1, &foundOffset)); | 72 REPORTER_ASSERT(reporter, !cache->get(key1, &foundOffset)); |
73 REPORTER_ASSERT(reporter, !cache->get(key2, &foundOffset)); | 73 REPORTER_ASSERT(reporter, !cache->get(key2, &foundOffset)); |
74 REPORTER_ASSERT(reporter, !cache->get(key3, &foundOffset)); | 74 REPORTER_ASSERT(reporter, !cache->get(key3, &foundOffset)); |
75 REPORTER_ASSERT(reporter, !cache->get(key4, &foundOffset)); | 75 REPORTER_ASSERT(reporter, !cache->get(key4, &foundOffset)); |
76 } | 76 } |
77 | 77 |
78 // Test purging when the max cache size is exceeded | 78 // Test purging when the max cache size is exceeded |
79 static void test_internal_purge(skiatest::Reporter* reporter, SkSpecialImage* im
age) { | 79 static void test_internal_purge(skiatest::Reporter* reporter, SkSpecialImage* im
age) { |
80 SkASSERT(image->getSize()); | 80 SkASSERT(image->getSize()); |
81 static const size_t kCacheSize = image->getSize() + 10; | 81 const size_t kCacheSize = image->getSize() + 10; |
82 SkAutoTUnref<SkImageFilter::Cache> cache(SkImageFilter::Cache::Create(kCache
Size)); | 82 SkAutoTUnref<SkImageFilter::Cache> cache(SkImageFilter::Cache::Create(kCache
Size)); |
83 | 83 |
84 SkIRect clip = SkIRect::MakeWH(100, 100); | 84 SkIRect clip = SkIRect::MakeWH(100, 100); |
85 SkImageFilter::Cache::Key key1(0, SkMatrix::I(), clip, image->uniqueID(), im
age->subset()); | 85 SkImageFilter::Cache::Key key1(0, SkMatrix::I(), clip, image->uniqueID(), im
age->subset()); |
86 SkImageFilter::Cache::Key key2(1, SkMatrix::I(), clip, image->uniqueID(), im
age->subset()); | 86 SkImageFilter::Cache::Key key2(1, SkMatrix::I(), clip, image->uniqueID(), im
age->subset()); |
87 | 87 |
88 SkIPoint offset = SkIPoint::Make(3, 4); | 88 SkIPoint offset = SkIPoint::Make(3, 4); |
89 cache->set(key1, image, offset); | 89 cache->set(key1, image, offset); |
90 | 90 |
91 SkIPoint foundOffset; | 91 SkIPoint foundOffset; |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ImageFilterCache_GPUBacked, reporter, context
) { | 212 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ImageFilterCache_GPUBacked, reporter, context
) { |
213 | 213 |
214 SkAutoTUnref<GrTexture> srcTexture(create_texture(context)); | 214 SkAutoTUnref<GrTexture> srcTexture(create_texture(context)); |
215 if (!srcTexture) { | 215 if (!srcTexture) { |
216 return; | 216 return; |
217 } | 217 } |
218 | 218 |
219 const SkIRect& full = SkIRect::MakeWH(kFullSize, kFullSize); | 219 const SkIRect& full = SkIRect::MakeWH(kFullSize, kFullSize); |
220 | 220 |
221 SkAutoTUnref<SkSpecialImage> fullImg(SkSpecialImage::NewFromGpu( | 221 SkAutoTUnref<SkSpecialImage> fullImg(SkSpecialImage::NewFromGpu( |
222 nullptr, full, | 222 nullptr, full, |
223 kNeedNewImageUni
queID_SpecialImage, | 223 kNeedNewImageUni
queID_SpecialImage, |
224 srcTexture)); | 224 srcTexture)); |
225 | 225 |
226 const SkIRect& subset = SkIRect::MakeXYWH(kPad, kPad, kSmallerSize, kSmaller
Size); | 226 const SkIRect& subset = SkIRect::MakeXYWH(kPad, kPad, kSmallerSize, kSmaller
Size); |
227 | 227 |
228 SkAutoTUnref<SkSpecialImage> subsetImg(SkSpecialImage::NewFromGpu( | 228 SkAutoTUnref<SkSpecialImage> subsetImg(SkSpecialImage::NewFromGpu( |
229 nullptr, subset,
| 229 nullptr, subset, |
230 kNeedNewImageUni
queID_SpecialImage, | 230 kNeedNewImageUni
queID_SpecialImage, |
231 srcTexture)); | 231 srcTexture)); |
232 | 232 |
233 test_find_existing(reporter, fullImg, subsetImg); | 233 test_find_existing(reporter, fullImg, subsetImg); |
234 test_dont_find_if_diff_key(reporter, fullImg, subsetImg); | 234 test_dont_find_if_diff_key(reporter, fullImg, subsetImg); |
235 test_internal_purge(reporter, fullImg); | 235 test_internal_purge(reporter, fullImg); |
236 test_explicit_purging(reporter, fullImg, subsetImg); | 236 test_explicit_purging(reporter, fullImg, subsetImg); |
237 } | 237 } |
238 #endif | 238 #endif |
239 | 239 |
OLD | NEW |