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 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 | 131 |
132 REPORTER_ASSERT(reporter, !cache->get(key1, &foundOffset)); | 132 REPORTER_ASSERT(reporter, !cache->get(key1, &foundOffset)); |
133 REPORTER_ASSERT(reporter, !cache->get(key2, &foundOffset)); | 133 REPORTER_ASSERT(reporter, !cache->get(key2, &foundOffset)); |
134 } | 134 } |
135 | 135 |
136 DEF_TEST(ImageFilterCache_RasterBacked, reporter) { | 136 DEF_TEST(ImageFilterCache_RasterBacked, reporter) { |
137 SkBitmap srcBM = create_bm(); | 137 SkBitmap srcBM = create_bm(); |
138 | 138 |
139 const SkIRect& full = SkIRect::MakeWH(kFullSize, kFullSize); | 139 const SkIRect& full = SkIRect::MakeWH(kFullSize, kFullSize); |
140 | 140 |
141 sk_sp<SkSpecialImage> fullImg(SkSpecialImage::MakeFromRaster(nullptr, full,
srcBM)); | 141 sk_sp<SkSpecialImage> fullImg(SkSpecialImage::MakeFromRaster(full, srcBM)); |
142 | 142 |
143 const SkIRect& subset = SkIRect::MakeXYWH(kPad, kPad, kSmallerSize, kSmaller
Size); | 143 const SkIRect& subset = SkIRect::MakeXYWH(kPad, kPad, kSmallerSize, kSmaller
Size); |
144 | 144 |
145 sk_sp<SkSpecialImage> subsetImg(SkSpecialImage::MakeFromRaster(nullptr, subs
et, srcBM)); | 145 sk_sp<SkSpecialImage> subsetImg(SkSpecialImage::MakeFromRaster(subset, srcBM
)); |
146 | 146 |
147 test_find_existing(reporter, fullImg, subsetImg); | 147 test_find_existing(reporter, fullImg, subsetImg); |
148 test_dont_find_if_diff_key(reporter, fullImg, subsetImg); | 148 test_dont_find_if_diff_key(reporter, fullImg, subsetImg); |
149 test_internal_purge(reporter, fullImg); | 149 test_internal_purge(reporter, fullImg); |
150 test_explicit_purging(reporter, fullImg, subsetImg); | 150 test_explicit_purging(reporter, fullImg, subsetImg); |
151 } | 151 } |
152 | 152 |
153 | 153 |
154 // Shared test code for both the raster and gpu-backed image cases | 154 // Shared test code for both the raster and gpu-backed image cases |
155 static void test_image_backed(skiatest::Reporter* reporter, const sk_sp<SkImage>
& srcImage) { | 155 static void test_image_backed(skiatest::Reporter* reporter, const sk_sp<SkImage>
& srcImage) { |
156 const SkIRect& full = SkIRect::MakeWH(kFullSize, kFullSize); | 156 const SkIRect& full = SkIRect::MakeWH(kFullSize, kFullSize); |
157 | 157 |
158 sk_sp<SkSpecialImage> fullImg(SkSpecialImage::MakeFromImage(nullptr, full, s
rcImage)); | 158 sk_sp<SkSpecialImage> fullImg(SkSpecialImage::MakeFromImage(full, srcImage))
; |
159 | 159 |
160 const SkIRect& subset = SkIRect::MakeXYWH(kPad, kPad, kSmallerSize, kSmaller
Size); | 160 const SkIRect& subset = SkIRect::MakeXYWH(kPad, kPad, kSmallerSize, kSmaller
Size); |
161 | 161 |
162 sk_sp<SkSpecialImage> subsetImg(SkSpecialImage::MakeFromImage(nullptr, subse
t, srcImage)); | 162 sk_sp<SkSpecialImage> subsetImg(SkSpecialImage::MakeFromImage(subset, srcIma
ge)); |
163 | 163 |
164 test_find_existing(reporter, fullImg, subsetImg); | 164 test_find_existing(reporter, fullImg, subsetImg); |
165 test_dont_find_if_diff_key(reporter, fullImg, subsetImg); | 165 test_dont_find_if_diff_key(reporter, fullImg, subsetImg); |
166 test_internal_purge(reporter, fullImg); | 166 test_internal_purge(reporter, fullImg); |
167 test_explicit_purging(reporter, fullImg, subsetImg); | 167 test_explicit_purging(reporter, fullImg, subsetImg); |
168 } | 168 } |
169 | 169 |
170 DEF_TEST(ImageFilterCache_ImageBackedRaster, reporter) { | 170 DEF_TEST(ImageFilterCache_ImageBackedRaster, reporter) { |
171 SkBitmap srcBM = create_bm(); | 171 SkBitmap srcBM = create_bm(); |
172 | 172 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 | 213 |
214 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ImageFilterCache_GPUBacked, reporter, ctxInfo
) { | 214 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ImageFilterCache_GPUBacked, reporter, ctxInfo
) { |
215 | 215 |
216 SkAutoTUnref<GrTexture> srcTexture(create_texture(ctxInfo.fGrContext)); | 216 SkAutoTUnref<GrTexture> srcTexture(create_texture(ctxInfo.fGrContext)); |
217 if (!srcTexture) { | 217 if (!srcTexture) { |
218 return; | 218 return; |
219 } | 219 } |
220 | 220 |
221 const SkIRect& full = SkIRect::MakeWH(kFullSize, kFullSize); | 221 const SkIRect& full = SkIRect::MakeWH(kFullSize, kFullSize); |
222 | 222 |
223 sk_sp<SkSpecialImage> fullImg(SkSpecialImage::MakeFromGpu(nullptr, full, | 223 sk_sp<SkSpecialImage> fullImg(SkSpecialImage::MakeFromGpu(full, |
224 kNeedNewImageUniqu
eID_SpecialImage, | 224 kNeedNewImageUniqu
eID_SpecialImage, |
225 srcTexture)); | 225 srcTexture)); |
226 | 226 |
227 const SkIRect& subset = SkIRect::MakeXYWH(kPad, kPad, kSmallerSize, kSmaller
Size); | 227 const SkIRect& subset = SkIRect::MakeXYWH(kPad, kPad, kSmallerSize, kSmaller
Size); |
228 | 228 |
229 sk_sp<SkSpecialImage> subsetImg(SkSpecialImage::MakeFromGpu(nullptr, subset, | 229 sk_sp<SkSpecialImage> subsetImg(SkSpecialImage::MakeFromGpu(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 |
OLD | NEW |