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

Unified Diff: gm/imagefiltersclipped.cpp

Issue 1869763002: Update LightingImageFilter to sk_sp (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Address code review comments 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « fuzz/FilterFuzz.cpp ('k') | gm/imagefilterscropexpand.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/imagefiltersclipped.cpp
diff --git a/gm/imagefiltersclipped.cpp b/gm/imagefiltersclipped.cpp
index b24ca5af727a6493b8c4472685712a64fa226424..f2434112fa0a752785ed3ffe1665f95e0ec113d0 100644
--- a/gm/imagefiltersclipped.cpp
+++ b/gm/imagefiltersclipped.cpp
@@ -43,11 +43,11 @@ static sk_sp<SkImage> make_gradient_circle(int width, int height) {
return surface->makeImageSnapshot();
}
-static void draw_clipped_filter(SkCanvas* canvas, SkImageFilter* filter, size_t i,
+static void draw_clipped_filter(SkCanvas* canvas, sk_sp<SkImageFilter> filter, size_t i,
const SkRect& primBounds, const SkRect& clipBounds) {
SkPaint paint;
paint.setColor(SK_ColorWHITE);
- paint.setImageFilter(filter);
+ paint.setImageFilter(std::move(filter));
paint.setAntiAlias(true);
canvas->save();
canvas->clipRect(clipBounds);
@@ -93,23 +93,25 @@ protected:
resizeMatrix.setScale(RESIZE_FACTOR_X, RESIZE_FACTOR_Y);
SkPoint3 pointLocation = SkPoint3::Make(32, 32, SkIntToScalar(10));
- SkImageFilter* filters[] = {
- SkBlurImageFilter::Make(SkIntToScalar(12), SkIntToScalar(12), nullptr).release(),
- SkDropShadowImageFilter::Make(SkIntToScalar(10), SkIntToScalar(10),
- SkIntToScalar(3), SkIntToScalar(3), SK_ColorGREEN,
- SkDropShadowImageFilter::kDrawShadowAndForeground_ShadowMode,
- nullptr).release(),
- SkDisplacementMapEffect::Create(SkDisplacementMapEffect::kR_ChannelSelectorType,
+ sk_sp<SkImageFilter> filters[] = {
+ SkBlurImageFilter::Make(SkIntToScalar(12), SkIntToScalar(12), nullptr),
+ SkDropShadowImageFilter::Make(
+ SkIntToScalar(10), SkIntToScalar(10),
+ SkIntToScalar(3), SkIntToScalar(3), SK_ColorGREEN,
+ SkDropShadowImageFilter::kDrawShadowAndForeground_ShadowMode,
+ nullptr),
+ sk_sp<SkImageFilter>(SkDisplacementMapEffect::Create(
+ SkDisplacementMapEffect::kR_ChannelSelectorType,
SkDisplacementMapEffect::kR_ChannelSelectorType,
SkIntToScalar(12),
gradient.get(),
- checkerboard.get()),
- SkDilateImageFilter::Make(2, 2, checkerboard).release(),
- SkErodeImageFilter::Make(2, 2, checkerboard).release(),
- SkOffsetImageFilter::Make(SkIntToScalar(-16), SkIntToScalar(32), nullptr).release(),
- SkImageFilter::MakeMatrixFilter(resizeMatrix, kNone_SkFilterQuality, nullptr).release(),
- SkLightingImageFilter::CreatePointLitDiffuse(pointLocation, SK_ColorWHITE, SK_Scalar1,
- SkIntToScalar(2), checkerboard.get()),
+ checkerboard.get())),
+ SkDilateImageFilter::Make(2, 2, checkerboard),
+ SkErodeImageFilter::Make(2, 2, checkerboard),
+ SkOffsetImageFilter::Make(SkIntToScalar(-16), SkIntToScalar(32), nullptr),
+ SkImageFilter::MakeMatrixFilter(resizeMatrix, kNone_SkFilterQuality, nullptr),
+ SkLightingImageFilter::MakePointLitDiffuse(pointLocation, SK_ColorWHITE, SK_Scalar1,
+ SkIntToScalar(2), checkerboard),
};
@@ -131,10 +133,6 @@ protected:
}
canvas->restore();
- for (size_t i = 0; i < SK_ARRAY_COUNT(filters); ++i) {
- SkSafeUnref(filters[i]);
- }
-
SkPaint noisePaint;
noisePaint.setShader(SkPerlinNoiseShader::MakeFractalNoise(0.1f, 0.05f, 1, 0));
@@ -142,7 +140,7 @@ protected:
canvas->translate(SK_ARRAY_COUNT(filters)*(r.width() + margin), 0);
for (int xOffset = 0; xOffset < 80; xOffset += 16) {
bounds.fLeft = SkIntToScalar(xOffset);
- draw_clipped_filter(canvas, rectFilter.get(), 0, r, bounds);
+ draw_clipped_filter(canvas, rectFilter, 0, r, bounds);
canvas->translate(0, r.height() + margin);
}
}
« no previous file with comments | « fuzz/FilterFuzz.cpp ('k') | gm/imagefilterscropexpand.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698