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 "SkBitmap.h" | 8 #include "SkBitmap.h" |
9 #include "SkBitmapDevice.h" | 9 #include "SkBitmapDevice.h" |
10 #include "SkBitmapSource.h" | 10 #include "SkBitmapSource.h" |
(...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
560 recordingCanvas->save(); | 560 recordingCanvas->save(); |
561 recordingCanvas->scale(SkIntToScalar(10), SkIntToScalar(10)); | 561 recordingCanvas->scale(SkIntToScalar(10), SkIntToScalar(10)); |
562 recordingCanvas->drawRect(SkRect::Make(SkIRect::MakeWH(100, 100)), solidPain
t); | 562 recordingCanvas->drawRect(SkRect::Make(SkIRect::MakeWH(100, 100)), solidPain
t); |
563 recordingCanvas->restore(); // scale | 563 recordingCanvas->restore(); // scale |
564 recordingCanvas->restore(); // saveLayer | 564 recordingCanvas->restore(); // saveLayer |
565 SkAutoTUnref<SkPicture> picture(recorder.endRecording()); | 565 SkAutoTUnref<SkPicture> picture(recorder.endRecording()); |
566 | 566 |
567 canvas.drawPicture(picture); | 567 canvas.drawPicture(picture); |
568 } | 568 } |
569 | 569 |
570 DEF_TEST(ImageFilterPictureImageFilter, reporter) { | 570 DEF_TEST(ImageFilterCrossProcessPictureImageFilter, reporter) { |
571 SkRTreeFactory factory; | 571 SkRTreeFactory factory; |
572 SkPictureRecorder recorder; | 572 SkPictureRecorder recorder; |
573 SkCanvas* recordingCanvas = recorder.beginRecording(1, 1, &factory, 0); | 573 SkCanvas* recordingCanvas = recorder.beginRecording(1, 1, &factory, 0); |
574 | 574 |
575 // Create an SkPicture which simply draws a green 1x1 rectangle. | 575 // Create an SkPicture which simply draws a green 1x1 rectangle. |
576 SkPaint greenPaint; | 576 SkPaint greenPaint; |
577 greenPaint.setColor(SK_ColorGREEN); | 577 greenPaint.setColor(SK_ColorGREEN); |
578 recordingCanvas->drawRect(SkRect::Make(SkIRect::MakeWH(1, 1)), greenPaint); | 578 recordingCanvas->drawRect(SkRect::Make(SkIRect::MakeWH(1, 1)), greenPaint); |
579 SkAutoTUnref<SkPicture> picture(recorder.endRecording()); | 579 SkAutoTUnref<SkPicture> picture(recorder.endRecording()); |
580 | 580 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
619 crossProcessCanvas->drawRect(SkRect::Make(SkIRect::MakeWH(1, 1)), redPaintWi
thFilter); | 619 crossProcessCanvas->drawRect(SkRect::Make(SkIRect::MakeWH(1, 1)), redPaintWi
thFilter); |
620 SkAutoTUnref<SkPicture> crossProcessPicture(crossProcessRecorder.endRecordin
g()); | 620 SkAutoTUnref<SkPicture> crossProcessPicture(crossProcessRecorder.endRecordin
g()); |
621 | 621 |
622 canvas.clear(0x0); | 622 canvas.clear(0x0); |
623 canvas.drawPicture(crossProcessPicture); | 623 canvas.drawPicture(crossProcessPicture); |
624 pixel = *bitmap.getAddr32(0, 0); | 624 pixel = *bitmap.getAddr32(0, 0); |
625 // The result here should not be green, since the filter draws nothing. | 625 // The result here should not be green, since the filter draws nothing. |
626 REPORTER_ASSERT(reporter, pixel != SK_ColorGREEN); | 626 REPORTER_ASSERT(reporter, pixel != SK_ColorGREEN); |
627 } | 627 } |
628 | 628 |
| 629 DEF_TEST(ImageFilterClippedPictureImageFilter, reporter) { |
| 630 SkRTreeFactory factory; |
| 631 SkPictureRecorder recorder; |
| 632 SkCanvas* recordingCanvas = recorder.beginRecording(1, 1, &factory, 0); |
| 633 |
| 634 // Create an SkPicture which simply draws a green 1x1 rectangle. |
| 635 SkPaint greenPaint; |
| 636 greenPaint.setColor(SK_ColorGREEN); |
| 637 recordingCanvas->drawRect(SkRect::Make(SkIRect::MakeWH(1, 1)), greenPaint); |
| 638 SkAutoTUnref<SkPicture> picture(recorder.endRecording()); |
| 639 |
| 640 SkAutoTUnref<SkImageFilter> imageFilter( |
| 641 SkPictureImageFilter::Create(picture.get())); |
| 642 |
| 643 SkBitmap result; |
| 644 SkIPoint offset; |
| 645 SkImageFilter::Context ctx(SkMatrix::I(), SkIRect::MakeXYWH(1, 1, 1, 1), NUL
L); |
| 646 SkBitmap bitmap; |
| 647 bitmap.allocN32Pixels(2, 2); |
| 648 SkBitmapDevice device(bitmap); |
| 649 SkDeviceImageFilterProxy proxy(&device); |
| 650 REPORTER_ASSERT(reporter, !imageFilter->filterImage(&proxy, bitmap, ctx, &re
sult, &offset)); |
| 651 } |
| 652 |
629 DEF_TEST(ImageFilterEmptySaveLayer, reporter) { | 653 DEF_TEST(ImageFilterEmptySaveLayer, reporter) { |
630 // Even when there's an empty saveLayer()/restore(), ensure that an image | 654 // Even when there's an empty saveLayer()/restore(), ensure that an image |
631 // filter or color filter which affects transparent black still draws. | 655 // filter or color filter which affects transparent black still draws. |
632 | 656 |
633 SkBitmap bitmap; | 657 SkBitmap bitmap; |
634 bitmap.allocN32Pixels(10, 10); | 658 bitmap.allocN32Pixels(10, 10); |
635 SkBitmapDevice device(bitmap); | 659 SkBitmapDevice device(bitmap); |
636 SkCanvas canvas(&device); | 660 SkCanvas canvas(&device); |
637 | 661 |
638 SkRTreeFactory factory; | 662 SkRTreeFactory factory; |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
824 } | 848 } |
825 | 849 |
826 DEF_GPUTEST(XfermodeImageFilterCroppedInputGPU, reporter, factory) { | 850 DEF_GPUTEST(XfermodeImageFilterCroppedInputGPU, reporter, factory) { |
827 GrContext* context = factory->get(static_cast<GrContextFactory::GLContextTyp
e>(0)); | 851 GrContext* context = factory->get(static_cast<GrContextFactory::GLContextTyp
e>(0)); |
828 SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(context, | 852 SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(context, |
829 SkImageInfo::MakeN32Pre
mul(1, 1), | 853 SkImageInfo::MakeN32Pre
mul(1, 1), |
830 0)); | 854 0)); |
831 test_xfermode_cropped_input(device, reporter); | 855 test_xfermode_cropped_input(device, reporter); |
832 } | 856 } |
833 #endif | 857 #endif |
OLD | NEW |