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

Side by Side Diff: gm/imagefilterstransformed.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 | « gm/imagefiltersstroked.cpp ('k') | include/effects/SkDropShadowImageFilter.h » ('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 2015 Google Inc. 2 * Copyright 2015 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 "sk_tool_utils.h" 8 #include "sk_tool_utils.h"
9 #include "SkBlurImageFilter.h" 9 #include "SkBlurImageFilter.h"
10 #include "SkColor.h" 10 #include "SkColor.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 58
59 void onOnceBeforeDraw() override { 59 void onOnceBeforeDraw() override {
60 fCheckerboard = SkImage::MakeFromBitmap( 60 fCheckerboard = SkImage::MakeFromBitmap(
61 sk_tool_utils::create_checkerboard_bitmap(64, 64, 0xFFA0A0A0, 0xFF40 4040, 8)); 61 sk_tool_utils::create_checkerboard_bitmap(64, 64, 0xFFA0A0A0, 0xFF40 4040, 8));
62 fGradientCircle = make_gradient_circle(64, 64); 62 fGradientCircle = make_gradient_circle(64, 64);
63 } 63 }
64 64
65 void onDraw(SkCanvas* canvas) override { 65 void onDraw(SkCanvas* canvas) override {
66 sk_sp<SkImageFilter> gradient(SkImageSource::Make(fGradientCircle)); 66 sk_sp<SkImageFilter> gradient(SkImageSource::Make(fGradientCircle));
67 sk_sp<SkImageFilter> checkerboard(SkImageSource::Make(fCheckerboard)); 67 sk_sp<SkImageFilter> checkerboard(SkImageSource::Make(fCheckerboard));
68 SkImageFilter* filters[] = { 68 sk_sp<SkImageFilter> filters[] = {
69 SkBlurImageFilter::Make(12, 0, nullptr).release(), 69 SkBlurImageFilter::Make(12, 0, nullptr),
70 SkDropShadowImageFilter::Create(0, 15, 8, 0, SK_ColorGREEN, 70 SkDropShadowImageFilter::Make(0, 15, 8, 0, SK_ColorGREEN,
71 SkDropShadowImageFilter::kDrawShadowAndForeground_ShadowMode), 71 SkDropShadowImageFilter::kDrawShadowAndForeground_ShadowMode, nu llptr),
72 SkDisplacementMapEffect::Create(SkDisplacementMapEffect::kR_ChannelS electorType, 72 sk_sp<SkImageFilter>(SkDisplacementMapEffect::Create(
73 SkDisplacementMapEffect::kR_ChannelS electorType,
73 SkDisplacementMapEffect::kR_ChannelS electorType, 74 SkDisplacementMapEffect::kR_ChannelS electorType,
74 12, 75 12,
75 gradient.get(), 76 gradient.get(),
76 checkerboard.get()), 77 checkerboard.get())),
77 SkDilateImageFilter::Make(2, 2, checkerboard).release(), 78 SkDilateImageFilter::Make(2, 2, checkerboard),
78 SkErodeImageFilter::Make(2, 2, checkerboard).release(), 79 SkErodeImageFilter::Make(2, 2, checkerboard),
79 }; 80 };
80 81
81 const SkScalar margin = SkIntToScalar(20); 82 const SkScalar margin = SkIntToScalar(20);
82 const SkScalar size = SkIntToScalar(60); 83 const SkScalar size = SkIntToScalar(60);
83 84
84 for (size_t j = 0; j < 3; j++) { 85 for (size_t j = 0; j < 3; j++) {
85 canvas->save(); 86 canvas->save();
86 canvas->translate(margin, 0); 87 canvas->translate(margin, 0);
87 for (size_t i = 0; i < SK_ARRAY_COUNT(filters); ++i) { 88 for (size_t i = 0; i < SK_ARRAY_COUNT(filters); ++i) {
88 SkPaint paint; 89 SkPaint paint;
(...skipping 10 matching lines...) Expand all
99 } 100 }
100 canvas->translate(-size * SK_ScalarHalf, -size * SK_ScalarHalf); 101 canvas->translate(-size * SK_ScalarHalf, -size * SK_ScalarHalf);
101 canvas->drawOval(SkRect::MakeXYWH(0, size * SkDoubleToScalar(0.1 ), 102 canvas->drawOval(SkRect::MakeXYWH(0, size * SkDoubleToScalar(0.1 ),
102 size, size * SkDoubleToScalar( 0.6)), paint); 103 size, size * SkDoubleToScalar( 0.6)), paint);
103 canvas->restore(); 104 canvas->restore();
104 canvas->translate(size + margin, 0); 105 canvas->translate(size + margin, 0);
105 } 106 }
106 canvas->restore(); 107 canvas->restore();
107 canvas->translate(0, size + margin); 108 canvas->translate(0, size + margin);
108 } 109 }
109
110 for (size_t i = 0; i < SK_ARRAY_COUNT(filters); ++i) {
111 SkSafeUnref(filters[i]);
112 }
113 } 110 }
114 111
115 private: 112 private:
116 sk_sp<SkImage> fCheckerboard; 113 sk_sp<SkImage> fCheckerboard;
117 sk_sp<SkImage> fGradientCircle; 114 sk_sp<SkImage> fGradientCircle;
118 typedef GM INHERITED; 115 typedef GM INHERITED;
119 }; 116 };
120 117
121 ////////////////////////////////////////////////////////////////////////////// 118 //////////////////////////////////////////////////////////////////////////////
122 119
123 DEF_GM( return new ImageFiltersTransformedGM; ) 120 DEF_GM( return new ImageFiltersTransformedGM; )
124 121
125 } 122 }
OLDNEW
« no previous file with comments | « gm/imagefiltersstroked.cpp ('k') | include/effects/SkDropShadowImageFilter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698