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 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 recordingCanvas->save(); | 288 recordingCanvas->save(); |
289 recordingCanvas->scale(SkIntToScalar(10), SkIntToScalar(10)); | 289 recordingCanvas->scale(SkIntToScalar(10), SkIntToScalar(10)); |
290 recordingCanvas->drawRect(SkRect::Make(SkIRect::MakeWH(100, 100)), solidPain
t); | 290 recordingCanvas->drawRect(SkRect::Make(SkIRect::MakeWH(100, 100)), solidPain
t); |
291 recordingCanvas->restore(); // scale | 291 recordingCanvas->restore(); // scale |
292 recordingCanvas->restore(); // saveLayer | 292 recordingCanvas->restore(); // saveLayer |
293 picture.endRecording(); | 293 picture.endRecording(); |
294 | 294 |
295 canvas.drawPicture(picture); | 295 canvas.drawPicture(picture); |
296 } | 296 } |
297 | 297 |
| 298 void test_huge_blur(SkBaseDevice* device, skiatest::Reporter* reporter) { |
| 299 SkCanvas canvas(device); |
| 300 |
| 301 SkBitmap bitmap; |
| 302 bitmap.allocN32Pixels(100, 100); |
| 303 bitmap.eraseARGB(0, 0, 0, 0); |
| 304 |
| 305 // Check that a blur with an insane radius does not crash or assert. |
| 306 SkAutoTUnref<SkImageFilter> blur(SkBlurImageFilter::Create(SkIntToScalar(1<<
30), SkIntToScalar(1<<30))); |
| 307 |
| 308 SkPaint paint; |
| 309 paint.setImageFilter(blur); |
| 310 canvas.drawSprite(bitmap, 0, 0, &paint); |
| 311 } |
| 312 |
| 313 DEF_TEST(HugeBlurImageFilter, reporter) { |
| 314 SkBitmap temp; |
| 315 temp.allocN32Pixels(100, 100); |
| 316 SkBitmapDevice device(temp); |
| 317 test_huge_blur(&device, reporter); |
| 318 } |
| 319 |
| 320 |
298 #if SK_SUPPORT_GPU | 321 #if SK_SUPPORT_GPU |
299 DEF_GPUTEST(ImageFilterCropRectGPU, reporter, factory) { | 322 DEF_GPUTEST(ImageFilterCropRectGPU, reporter, factory) { |
300 GrContext* context = factory->get(static_cast<GrContextFactory::GLContextTyp
e>(0)); | 323 GrContext* context = factory->get(static_cast<GrContextFactory::GLContextTyp
e>(0)); |
301 SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(context, | 324 SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(context, |
302 SkImageInfo::MakeN32Pre
mul(100, 100), | 325 SkImageInfo::MakeN32Pre
mul(100, 100), |
303 0)); | 326 0)); |
304 test_crop_rects(device, reporter); | 327 test_crop_rects(device, reporter); |
305 } | 328 } |
| 329 |
| 330 DEF_GPUTEST(HugeBlurImageFilterGPU, reporter, factory) { |
| 331 GrContext* context = factory->get(static_cast<GrContextFactory::GLContextTyp
e>(0)); |
| 332 SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(context, |
| 333 SkImageInfo::MakeN32Pre
mul(100, 100), |
| 334 0)); |
| 335 test_huge_blur(device, reporter); |
| 336 } |
306 #endif | 337 #endif |
OLD | NEW |