OLD | NEW |
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 "SkBicubicImageFilter.h" | 8 #include "SkBicubicImageFilter.h" |
9 #include "SkBitmap.h" | 9 #include "SkBitmap.h" |
10 #include "SkBitmapDevice.h" | 10 #include "SkBitmapDevice.h" |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 { | 184 { |
185 // This tests for scale bringing width to 0 | 185 // This tests for scale bringing width to 0 |
186 SkSize scale = SkSize::Make(-0.001f, SK_Scalar1); | 186 SkSize scale = SkSize::Make(-0.001f, SK_Scalar1); |
187 SkAutoTUnref<SkImageFilter> bmSrc(SkBitmapSource::Create(bitmap)); | 187 SkAutoTUnref<SkImageFilter> bmSrc(SkBitmapSource::Create(bitmap)); |
188 SkAutoTUnref<SkBicubicImageFilter> bicubic( | 188 SkAutoTUnref<SkBicubicImageFilter> bicubic( |
189 SkBicubicImageFilter::CreateMitchell(scale, bmSrc)); | 189 SkBicubicImageFilter::CreateMitchell(scale, bmSrc)); |
190 SkBitmapDevice device(bitmap); | 190 SkBitmapDevice device(bitmap); |
191 SkDeviceImageFilterProxy proxy(&device); | 191 SkDeviceImageFilterProxy proxy(&device); |
192 SkIPoint loc = SkIPoint::Make(0, 0); | 192 SkIPoint loc = SkIPoint::Make(0, 0); |
193 // An empty input should early return and return false | 193 // An empty input should early return and return false |
194 SkImageFilter::Context ctx(SkMatrix::I(), SkIRect::MakeEmpty()); | 194 SkAutoTUnref<SkImageFilter::Cache> cache(SkImageFilter::Cache::Creat
e(2)); |
| 195 SkImageFilter::Context ctx(SkMatrix::I(), SkIRect::MakeEmpty(), cach
e.get()); |
195 REPORTER_ASSERT(reporter, | 196 REPORTER_ASSERT(reporter, |
196 !bicubic->filterImage(&proxy, bitmap, ctx, &result,
&loc)); | 197 !bicubic->filterImage(&proxy, bitmap, ctx, &result,
&loc)); |
197 } | 198 } |
198 } | 199 } |
199 } | 200 } |
200 | 201 |
201 static void test_crop_rects(SkBaseDevice* device, skiatest::Reporter* reporter)
{ | 202 static void test_crop_rects(SkBaseDevice* device, skiatest::Reporter* reporter)
{ |
202 // Check that all filters offset to their absolute crop rect, | 203 // Check that all filters offset to their absolute crop rect, |
203 // unaffected by the input crop rect. | 204 // unaffected by the input crop rect. |
204 // Tests pass by not asserting. | 205 // Tests pass by not asserting. |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 SkTileImageFilter::Create(inputCropRect.rect(), cropRect.rect(), input.g
et()), | 241 SkTileImageFilter::Create(inputCropRect.rect(), cropRect.rect(), input.g
et()), |
241 SkXfermodeImageFilter::Create(SkXfermode::Create(SkXfermode::kSrcOver_Mo
de), input.get(), input.get(), &cropRect), | 242 SkXfermodeImageFilter::Create(SkXfermode::Create(SkXfermode::kSrcOver_Mo
de), input.get(), input.get(), &cropRect), |
242 }; | 243 }; |
243 | 244 |
244 for (size_t i = 0; i < SK_ARRAY_COUNT(filters); ++i) { | 245 for (size_t i = 0; i < SK_ARRAY_COUNT(filters); ++i) { |
245 SkImageFilter* filter = filters[i]; | 246 SkImageFilter* filter = filters[i]; |
246 SkBitmap result; | 247 SkBitmap result; |
247 SkIPoint offset; | 248 SkIPoint offset; |
248 SkString str; | 249 SkString str; |
249 str.printf("filter %d", static_cast<int>(i)); | 250 str.printf("filter %d", static_cast<int>(i)); |
250 SkImageFilter::Context ctx(SkMatrix::I(), SkIRect::MakeLargest()); | 251 SkAutoTUnref<SkImageFilter::Cache> cache(SkImageFilter::Cache::Create(2)
); |
251 REPORTER_ASSERT_MESSAGE(reporter, filter->filterImage(&proxy, bitmap, ct
x, &result, &offset), str.c_str()); | 252 SkImageFilter::Context ctx(SkMatrix::I(), SkIRect::MakeLargest(), cache.
get()); |
| 253 REPORTER_ASSERT_MESSAGE(reporter, filter->filterImage(&proxy, bitmap, ct
x, |
| 254 &result, &offset), str.c_str()); |
252 REPORTER_ASSERT_MESSAGE(reporter, offset.fX == 20 && offset.fY == 30, st
r.c_str()); | 255 REPORTER_ASSERT_MESSAGE(reporter, offset.fX == 20 && offset.fY == 30, st
r.c_str()); |
253 } | 256 } |
254 | 257 |
255 for (size_t i = 0; i < SK_ARRAY_COUNT(filters); ++i) { | 258 for (size_t i = 0; i < SK_ARRAY_COUNT(filters); ++i) { |
256 SkSafeUnref(filters[i]); | 259 SkSafeUnref(filters[i]); |
257 } | 260 } |
258 } | 261 } |
259 | 262 |
260 DEF_TEST(ImageFilterCropRect, reporter) { | 263 DEF_TEST(ImageFilterCropRect, reporter) { |
261 SkBitmap temp; | 264 SkBitmap temp; |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
440 } | 443 } |
441 | 444 |
442 DEF_GPUTEST(XfermodeImageFilterCroppedInputGPU, reporter, factory) { | 445 DEF_GPUTEST(XfermodeImageFilterCroppedInputGPU, reporter, factory) { |
443 GrContext* context = factory->get(static_cast<GrContextFactory::GLContextTyp
e>(0)); | 446 GrContext* context = factory->get(static_cast<GrContextFactory::GLContextTyp
e>(0)); |
444 SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(context, | 447 SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(context, |
445 SkImageInfo::MakeN32Pre
mul(1, 1), | 448 SkImageInfo::MakeN32Pre
mul(1, 1), |
446 0)); | 449 0)); |
447 test_xfermode_cropped_input(device, reporter); | 450 test_xfermode_cropped_input(device, reporter); |
448 } | 451 } |
449 #endif | 452 #endif |
OLD | NEW |