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

Side by Side Diff: gm/imagefiltersgraph.cpp

Issue 1852743002: Update SkBlurImageFilter to sk_sp (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Update to ToT & 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 unified diff | Download patch
« no previous file with comments | « gm/imagefilterscropped.cpp ('k') | gm/imagefiltersscaled.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 2012 Google Inc. 2 * Copyright 2012 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 "gm.h" 8 #include "gm.h"
9 9
10 #include "SkArithmeticMode.h" 10 #include "SkArithmeticMode.h"
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 fImage = SkImage::MakeFromBitmap( 114 fImage = SkImage::MakeFromBitmap(
115 sk_tool_utils::create_string_bitmap(100, 100, SK_ColorWHITE, 20, 70, 96, "e")); 115 sk_tool_utils::create_string_bitmap(100, 100, SK_ColorWHITE, 20, 70, 96, "e"));
116 } 116 }
117 117
118 void onDraw(SkCanvas* canvas) override { 118 void onDraw(SkCanvas* canvas) override {
119 canvas->clear(SK_ColorBLACK); 119 canvas->clear(SK_ColorBLACK);
120 { 120 {
121 sk_sp<SkImageFilter> bitmapSource(SkImageSource::Make(fImage)); 121 sk_sp<SkImageFilter> bitmapSource(SkImageSource::Make(fImage));
122 sk_sp<SkColorFilter> cf(SkColorFilter::MakeModeFilter(SK_ColorRED, 122 sk_sp<SkColorFilter> cf(SkColorFilter::MakeModeFilter(SK_ColorRED,
123 SkXfermode::kS rcIn_Mode)); 123 SkXfermode::kS rcIn_Mode));
124 sk_sp<SkImageFilter> blur(SkBlurImageFilter::Create(4.0f, 4.0f, bitm apSource.get())); 124 sk_sp<SkImageFilter> blur(SkBlurImageFilter::Make(4.0f, 4.0f, std::m ove(bitmapSource)));
125 sk_sp<SkImageFilter> erode(SkErodeImageFilter::Create(4, 4, blur.get ())); 125 sk_sp<SkImageFilter> erode(SkErodeImageFilter::Create(4, 4, blur.get ()));
126 sk_sp<SkImageFilter> color(SkColorFilterImageFilter::Create(cf.get() , erode.get())); 126 sk_sp<SkImageFilter> color(SkColorFilterImageFilter::Create(cf.get() , erode.get()));
127 sk_sp<SkImageFilter> merge(SkMergeImageFilter::Make(blur, color)); 127 sk_sp<SkImageFilter> merge(SkMergeImageFilter::Make(blur, color));
128 128
129 SkPaint paint; 129 SkPaint paint;
130 paint.setImageFilter(std::move(merge)); 130 paint.setImageFilter(std::move(merge));
131 canvas->drawPaint(paint); 131 canvas->drawPaint(paint);
132 canvas->translate(SkIntToScalar(100), 0); 132 canvas->translate(SkIntToScalar(100), 0);
133 } 133 }
134 { 134 {
(...skipping 25 matching lines...) Expand all
160 160
161 SkPaint paint; 161 SkPaint paint;
162 paint.setImageFilter( 162 paint.setImageFilter(
163 SkXfermodeImageFilter::Make(SkArithmeticMode::Make(0, SK_Scalar1 , SK_Scalar1, 0), 163 SkXfermodeImageFilter::Make(SkArithmeticMode::Make(0, SK_Scalar1 , SK_Scalar1, 0),
164 matrixFilter, offsetFilter, nullptr) ); 164 matrixFilter, offsetFilter, nullptr) );
165 165
166 DrawClippedImage(canvas, fImage.get(), paint); 166 DrawClippedImage(canvas, fImage.get(), paint);
167 canvas->translate(SkIntToScalar(100), 0); 167 canvas->translate(SkIntToScalar(100), 0);
168 } 168 }
169 { 169 {
170 SkAutoTUnref<SkImageFilter> blur(SkBlurImageFilter::Create( 170 sk_sp<SkImageFilter> blur(SkBlurImageFilter::Make(SkIntToScalar(10),
171 SkIntToScalar(10), SkIntToScalar(10))); 171 SkIntToScalar(10),
172 nullptr));
172 173
173 SkImageFilter::CropRect cropRect(SkRect::MakeWH(SkIntToScalar(95), S kIntToScalar(100))); 174 SkImageFilter::CropRect cropRect(SkRect::MakeWH(SkIntToScalar(95), S kIntToScalar(100)));
174 SkPaint paint; 175 SkPaint paint;
175 paint.setImageFilter( 176 paint.setImageFilter(
176 SkXfermodeImageFilter::Make(SkXfermode::Make(SkXfermode::kSrcIn_ Mode), blur, 177 SkXfermodeImageFilter::Make(SkXfermode::Make(SkXfermode::kSrcIn_ Mode), blur.get(),
177 nullptr, &cropRect)); 178 nullptr, &cropRect));
178 DrawClippedImage(canvas, fImage.get(), paint); 179 DrawClippedImage(canvas, fImage.get(), paint);
179 canvas->translate(SkIntToScalar(100), 0); 180 canvas->translate(SkIntToScalar(100), 0);
180 } 181 }
181 { 182 {
182 // Dilate -> matrix convolution. 183 // Dilate -> matrix convolution.
183 // This tests that a filter using asFragmentProcessor (matrix 184 // This tests that a filter using asFragmentProcessor (matrix
184 // convolution) correctly handles a non-zero source offset 185 // convolution) correctly handles a non-zero source offset
185 // (supplied by the dilate). 186 // (supplied by the dilate).
186 SkAutoTUnref<SkImageFilter> dilate(SkDilateImageFilter::Create(5, 5) ); 187 SkAutoTUnref<SkImageFilter> dilate(SkDilateImageFilter::Create(5, 5) );
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 } 239 }
239 240
240 sk_sp<SkImage> fImage; 241 sk_sp<SkImage> fImage;
241 242
242 typedef GM INHERITED; 243 typedef GM INHERITED;
243 }; 244 };
244 245
245 /////////////////////////////////////////////////////////////////////////////// 246 ///////////////////////////////////////////////////////////////////////////////
246 247
247 DEF_GM(return new ImageFiltersGraphGM;) 248 DEF_GM(return new ImageFiltersGraphGM;)
OLDNEW
« no previous file with comments | « gm/imagefilterscropped.cpp ('k') | gm/imagefiltersscaled.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698