OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2013 Google Inc. | 3 * Copyright 2013 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 #include "SkBitmap.h" | 9 #include "SkBitmap.h" |
10 #include "SkBitmapDevice.h" | 10 #include "SkBitmapDevice.h" |
(...skipping 738 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
749 SK_ColorBLUE, SkDropShadowImageFilter::kDrawShadowAndForeground_ShadowMo
de, | 749 SK_ColorBLUE, SkDropShadowImageFilter::kDrawShadowAndForeground_ShadowMo
de, |
750 input, nullptr); | 750 input, nullptr); |
751 } | 751 } |
752 | 752 |
753 DEF_TEST(ImageFilterBlurThenShadowBounds, reporter) { | 753 DEF_TEST(ImageFilterBlurThenShadowBounds, reporter) { |
754 SkAutoTUnref<SkImageFilter> filter1(makeBlur()); | 754 SkAutoTUnref<SkImageFilter> filter1(makeBlur()); |
755 SkAutoTUnref<SkImageFilter> filter2(makeDropShadow(filter1.get())); | 755 SkAutoTUnref<SkImageFilter> filter2(makeDropShadow(filter1.get())); |
756 | 756 |
757 SkIRect bounds = SkIRect::MakeXYWH(0, 0, 100, 100); | 757 SkIRect bounds = SkIRect::MakeXYWH(0, 0, 100, 100); |
758 SkIRect expectedBounds = SkIRect::MakeXYWH(-133, -133, 236, 236); | 758 SkIRect expectedBounds = SkIRect::MakeXYWH(-133, -133, 236, 236); |
759 filter2->filterBounds(bounds, SkMatrix::I(), &bounds); | 759 bounds = filter2->filterBounds(bounds, SkMatrix::I()); |
760 | 760 |
761 REPORTER_ASSERT(reporter, bounds == expectedBounds); | 761 REPORTER_ASSERT(reporter, bounds == expectedBounds); |
762 } | 762 } |
763 | 763 |
764 DEF_TEST(ImageFilterShadowThenBlurBounds, reporter) { | 764 DEF_TEST(ImageFilterShadowThenBlurBounds, reporter) { |
765 SkAutoTUnref<SkImageFilter> filter1(makeDropShadow()); | 765 SkAutoTUnref<SkImageFilter> filter1(makeDropShadow()); |
766 SkAutoTUnref<SkImageFilter> filter2(makeBlur(filter1.get())); | 766 SkAutoTUnref<SkImageFilter> filter2(makeBlur(filter1.get())); |
767 | 767 |
768 SkIRect bounds = SkIRect::MakeXYWH(0, 0, 100, 100); | 768 SkIRect bounds = SkIRect::MakeXYWH(0, 0, 100, 100); |
769 SkIRect expectedBounds = SkIRect::MakeXYWH(-133, -133, 236, 236); | 769 SkIRect expectedBounds = SkIRect::MakeXYWH(-133, -133, 236, 236); |
770 filter2->filterBounds(bounds, SkMatrix::I(), &bounds); | 770 bounds = filter2->filterBounds(bounds, SkMatrix::I()); |
771 | 771 |
772 REPORTER_ASSERT(reporter, bounds == expectedBounds); | 772 REPORTER_ASSERT(reporter, bounds == expectedBounds); |
773 } | 773 } |
774 | 774 |
775 DEF_TEST(ImageFilterDilateThenBlurBounds, reporter) { | 775 DEF_TEST(ImageFilterDilateThenBlurBounds, reporter) { |
776 SkAutoTUnref<SkImageFilter> filter1(SkDilateImageFilter::Create(2, 2)); | 776 SkAutoTUnref<SkImageFilter> filter1(SkDilateImageFilter::Create(2, 2)); |
777 SkAutoTUnref<SkImageFilter> filter2(makeDropShadow(filter1.get())); | 777 SkAutoTUnref<SkImageFilter> filter2(makeDropShadow(filter1.get())); |
778 | 778 |
779 SkIRect bounds = SkIRect::MakeXYWH(0, 0, 100, 100); | 779 SkIRect bounds = SkIRect::MakeXYWH(0, 0, 100, 100); |
780 SkIRect expectedBounds = SkIRect::MakeXYWH(-132, -132, 234, 234); | 780 SkIRect expectedBounds = SkIRect::MakeXYWH(-132, -132, 234, 234); |
781 filter2->filterBounds(bounds, SkMatrix::I(), &bounds); | 781 bounds = filter2->filterBounds(bounds, SkMatrix::I()); |
782 | 782 |
783 REPORTER_ASSERT(reporter, bounds == expectedBounds); | 783 REPORTER_ASSERT(reporter, bounds == expectedBounds); |
784 } | 784 } |
785 | 785 |
786 DEF_TEST(ImageFilterComposedBlurFastBounds, reporter) { | 786 DEF_TEST(ImageFilterComposedBlurFastBounds, reporter) { |
787 SkAutoTUnref<SkImageFilter> filter1(makeBlur()); | 787 SkAutoTUnref<SkImageFilter> filter1(makeBlur()); |
788 SkAutoTUnref<SkImageFilter> filter2(makeBlur()); | 788 SkAutoTUnref<SkImageFilter> filter2(makeBlur()); |
789 SkAutoTUnref<SkImageFilter> composedFilter(SkComposeImageFilter::Create(filt
er1.get(), filter2.get())); | 789 SkAutoTUnref<SkImageFilter> composedFilter(SkComposeImageFilter::Create(filt
er1.get(), filter2.get())); |
790 | 790 |
791 SkRect boundsSrc = SkRect::MakeWH(SkIntToScalar(100), SkIntToScalar(100)); | 791 SkRect boundsSrc = SkRect::MakeWH(SkIntToScalar(100), SkIntToScalar(100)); |
792 SkRect expectedBounds = SkRect::MakeXYWH( | 792 SkRect expectedBounds = SkRect::MakeXYWH( |
793 SkIntToScalar(-6), SkIntToScalar(-6), SkIntToScalar(112), SkIntToScalar(
112)); | 793 SkIntToScalar(-6), SkIntToScalar(-6), SkIntToScalar(112), SkIntToScalar(
112)); |
794 SkRect boundsDst = SkRect::MakeEmpty(); | 794 SkRect boundsDst = composedFilter->computeFastBounds(boundsSrc); |
795 composedFilter->computeFastBounds(boundsSrc, &boundsDst); | |
796 | 795 |
797 REPORTER_ASSERT(reporter, boundsDst == expectedBounds); | 796 REPORTER_ASSERT(reporter, boundsDst == expectedBounds); |
798 } | 797 } |
799 | 798 |
800 DEF_TEST(ImageFilterUnionBounds, reporter) { | 799 DEF_TEST(ImageFilterUnionBounds, reporter) { |
801 SkAutoTUnref<SkImageFilter> offset(SkOffsetImageFilter::Create(50, 0)); | 800 SkAutoTUnref<SkImageFilter> offset(SkOffsetImageFilter::Create(50, 0)); |
802 // Regardless of which order they appear in, the image filter bounds should | 801 // Regardless of which order they appear in, the image filter bounds should |
803 // be combined correctly. | 802 // be combined correctly. |
804 { | 803 { |
805 SkAutoTUnref<SkImageFilter> composite(SkXfermodeImageFilter::Create( | 804 SkAutoTUnref<SkImageFilter> composite(SkXfermodeImageFilter::Create( |
806 nullptr, offset.get(), nullptr)); | 805 nullptr, offset.get(), nullptr)); |
807 SkRect bounds = SkRect::MakeWH(100, 100); | 806 SkRect bounds = SkRect::MakeWH(100, 100); |
808 // Intentionally aliasing here, as that's what the real callers do. | 807 // Intentionally aliasing here, as that's what the real callers do. |
809 composite->computeFastBounds(bounds, &bounds); | 808 bounds = composite->computeFastBounds(bounds); |
810 REPORTER_ASSERT(reporter, bounds == SkRect::MakeWH(150, 100)); | 809 REPORTER_ASSERT(reporter, bounds == SkRect::MakeWH(150, 100)); |
811 } | 810 } |
812 { | 811 { |
813 SkAutoTUnref<SkImageFilter> composite(SkXfermodeImageFilter::Create( | 812 SkAutoTUnref<SkImageFilter> composite(SkXfermodeImageFilter::Create( |
814 nullptr, nullptr, offset.get())); | 813 nullptr, nullptr, offset.get())); |
815 SkRect bounds = SkRect::MakeWH(100, 100); | 814 SkRect bounds = SkRect::MakeWH(100, 100); |
816 // Intentionally aliasing here, as that's what the real callers do. | 815 // Intentionally aliasing here, as that's what the real callers do. |
817 composite->computeFastBounds(bounds, &bounds); | 816 bounds = composite->computeFastBounds(bounds); |
818 REPORTER_ASSERT(reporter, bounds == SkRect::MakeWH(150, 100)); | 817 REPORTER_ASSERT(reporter, bounds == SkRect::MakeWH(150, 100)); |
819 } | 818 } |
820 } | 819 } |
821 | 820 |
822 static void test_imagefilter_merge_result_size(SkImageFilter::Proxy* proxy, | 821 static void test_imagefilter_merge_result_size(SkImageFilter::Proxy* proxy, |
823 skiatest::Reporter* reporter, | 822 skiatest::Reporter* reporter, |
824 GrContext* context) { | 823 GrContext* context) { |
825 SkBitmap greenBM; | 824 SkBitmap greenBM; |
826 greenBM.allocN32Pixels(20, 20); | 825 greenBM.allocN32Pixels(20, 20); |
827 greenBM.eraseColor(SK_ColorGREEN); | 826 greenBM.eraseColor(SK_ColorGREEN); |
(...skipping 771 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1599 test_xfermode_cropped_input(&canvas, reporter); | 1598 test_xfermode_cropped_input(&canvas, reporter); |
1600 } | 1599 } |
1601 | 1600 |
1602 DEF_GPUTEST_FOR_ALL_CONTEXTS(BlurLargeImage_Gpu, reporter, context) { | 1601 DEF_GPUTEST_FOR_ALL_CONTEXTS(BlurLargeImage_Gpu, reporter, context) { |
1603 SkAutoTUnref<SkSurface> surface( | 1602 SkAutoTUnref<SkSurface> surface( |
1604 SkSurface::NewRenderTarget(context, SkBudgeted::kYes, | 1603 SkSurface::NewRenderTarget(context, SkBudgeted::kYes, |
1605 SkImageInfo::MakeN32Premul(100, 100))); | 1604 SkImageInfo::MakeN32Premul(100, 100))); |
1606 test_large_blur_input(reporter, surface->getCanvas()); | 1605 test_large_blur_input(reporter, surface->getCanvas()); |
1607 } | 1606 } |
1608 #endif | 1607 #endif |
OLD | NEW |