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 "SkBlurImageFilter.h" | 10 #include "SkBlurImageFilter.h" |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 this->addFilter("displacement map", SkDisplacementMapEffect::Create( | 174 this->addFilter("displacement map", SkDisplacementMapEffect::Create( |
175 SkDisplacementMapEffect::kR_ChannelSelectorType, | 175 SkDisplacementMapEffect::kR_ChannelSelectorType, |
176 SkDisplacementMapEffect::kB_ChannelSelectorType, | 176 SkDisplacementMapEffect::kB_ChannelSelectorType, |
177 20.0f, gradientSource.get(), input.get(), cropRect)); | 177 20.0f, gradientSource.get(), input.get(), cropRect)); |
178 } | 178 } |
179 | 179 |
180 this->addFilter("blur", SkBlurImageFilter::Make(SK_Scalar1, | 180 this->addFilter("blur", SkBlurImageFilter::Make(SK_Scalar1, |
181 SK_Scalar1, | 181 SK_Scalar1, |
182 input, | 182 input, |
183 cropRect).release()); | 183 cropRect).release()); |
184 this->addFilter("drop shadow", SkDropShadowImageFilter::Create( | 184 this->addFilter("drop shadow", SkDropShadowImageFilter::Make( |
185 SK_Scalar1, SK_Scalar1, SK_Scalar1, SK_Scalar1, SK_ColorGREEN, | 185 SK_Scalar1, SK_Scalar1, SK_Scalar1, SK_Scalar1, SK_ColorGREEN, |
186 SkDropShadowImageFilter::kDrawShadowAndForeground_ShadowMode, | 186 SkDropShadowImageFilter::kDrawShadowAndForeground_ShadowMode, |
187 input.get(), cropRect)); | 187 input, cropRect).release()); |
188 this->addFilter("diffuse lighting", SkLightingImageFilter::CreatePointLi
tDiffuse( | 188 this->addFilter("diffuse lighting", SkLightingImageFilter::CreatePointLi
tDiffuse( |
189 location, SK_ColorGREEN, 0, 0, input.get(), cropRect)); | 189 location, SK_ColorGREEN, 0, 0, input.get(), cropRect)); |
190 this->addFilter("specular lighting", | 190 this->addFilter("specular lighting", |
191 SkLightingImageFilter::CreatePointLitSpecular(location, SK_Col
orGREEN, 0, 0, 0, | 191 SkLightingImageFilter::CreatePointLitSpecular(location, SK_Col
orGREEN, 0, 0, 0, |
192 input.get(), cro
pRect)); | 192 input.get(), cro
pRect)); |
193 this->addFilter("matrix convolution", | 193 this->addFilter("matrix convolution", |
194 SkMatrixConvolutionImageFilter::Create( | 194 SkMatrixConvolutionImageFilter::Create( |
195 kernelSize, kernel, gain, bias, SkIPoint::Make(1, 1), | 195 kernelSize, kernel, gain, bias, SkIPoint::Make(1, 1), |
196 SkMatrixConvolutionImageFilter::kRepeat_TileMode, false, | 196 SkMatrixConvolutionImageFilter::kRepeat_TileMode, false, |
197 input.get(), cropRect)); | 197 input.get(), cropRect)); |
(...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
844 break; | 844 break; |
845 } | 845 } |
846 } | 846 } |
847 } | 847 } |
848 | 848 |
849 static sk_sp<SkImageFilter> make_blur(sk_sp<SkImageFilter> input) { | 849 static sk_sp<SkImageFilter> make_blur(sk_sp<SkImageFilter> input) { |
850 return SkBlurImageFilter::Make(SK_Scalar1, SK_Scalar1, std::move(input)); | 850 return SkBlurImageFilter::Make(SK_Scalar1, SK_Scalar1, std::move(input)); |
851 } | 851 } |
852 | 852 |
853 static sk_sp<SkImageFilter> make_drop_shadow(sk_sp<SkImageFilter> input) { | 853 static sk_sp<SkImageFilter> make_drop_shadow(sk_sp<SkImageFilter> input) { |
854 return sk_sp<SkImageFilter>(SkDropShadowImageFilter::Create( | 854 return SkDropShadowImageFilter::Make( |
855 SkIntToScalar(100), SkIntToScalar(100), | 855 SkIntToScalar(100), SkIntToScalar(100), |
856 SkIntToScalar(10), SkIntToScalar(10), | 856 SkIntToScalar(10), SkIntToScalar(10), |
857 SK_ColorBLUE, SkDropShadowImageFilter::kDrawShadowAndForeground_ShadowMo
de, | 857 SK_ColorBLUE, SkDropShadowImageFilter::kDrawShadowAndForeground_ShadowMo
de, |
858 input.get(), nullptr)); | 858 std::move(input)); |
859 } | 859 } |
860 | 860 |
861 DEF_TEST(ImageFilterBlurThenShadowBounds, reporter) { | 861 DEF_TEST(ImageFilterBlurThenShadowBounds, reporter) { |
862 sk_sp<SkImageFilter> filter1(make_blur(nullptr)); | 862 sk_sp<SkImageFilter> filter1(make_blur(nullptr)); |
863 sk_sp<SkImageFilter> filter2(make_drop_shadow(std::move(filter1))); | 863 sk_sp<SkImageFilter> filter2(make_drop_shadow(std::move(filter1))); |
864 | 864 |
865 SkIRect bounds = SkIRect::MakeXYWH(0, 0, 100, 100); | 865 SkIRect bounds = SkIRect::MakeXYWH(0, 0, 100, 100); |
866 SkIRect expectedBounds = SkIRect::MakeXYWH(-133, -133, 236, 236); | 866 SkIRect expectedBounds = SkIRect::MakeXYWH(-133, -133, 236, 236); |
867 bounds = filter2->filterBounds(bounds, SkMatrix::I()); | 867 bounds = filter2->filterBounds(bounds, SkMatrix::I()); |
868 | 868 |
(...skipping 835 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1704 | 1704 |
1705 test_xfermode_cropped_input(&canvas, reporter); | 1705 test_xfermode_cropped_input(&canvas, reporter); |
1706 } | 1706 } |
1707 | 1707 |
1708 DEF_GPUTEST_FOR_ALL_CONTEXTS(BlurLargeImage_Gpu, reporter, ctxInfo) { | 1708 DEF_GPUTEST_FOR_ALL_CONTEXTS(BlurLargeImage_Gpu, reporter, ctxInfo) { |
1709 auto surface(SkSurface::MakeRenderTarget(ctxInfo.fGrContext, SkBudgeted::kYe
s, | 1709 auto surface(SkSurface::MakeRenderTarget(ctxInfo.fGrContext, SkBudgeted::kYe
s, |
1710 SkImageInfo::MakeN32Premul(100, 100
))); | 1710 SkImageInfo::MakeN32Premul(100, 100
))); |
1711 test_large_blur_input(reporter, surface->getCanvas()); | 1711 test_large_blur_input(reporter, surface->getCanvas()); |
1712 } | 1712 } |
1713 #endif | 1713 #endif |
OLD | NEW |