Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(183)

Side by Side Diff: tests/ImageFilterTest.cpp

Issue 1861843002: Update DropShadowImageFilter to sk_sp (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Address code review issues Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/effects/SkDropShadowImageFilter.cpp ('k') | tests/RecordDrawTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
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
OLDNEW
« no previous file with comments | « src/effects/SkDropShadowImageFilter.cpp ('k') | tests/RecordDrawTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698