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

Side by Side Diff: gm/imagefiltersbase.cpp

Issue 1822623002: switch colorfilters to sk_sp (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase Created 4 years, 9 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/imagefilters.cpp ('k') | gm/imagefilterscropexpand.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 2011 Google Inc. 2 * Copyright 2011 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 #include "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkColorFilter.h" 10 #include "SkColorFilter.h"
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 canvas->drawRect(r, paint); 185 canvas->drawRect(r, paint);
186 } 186 }
187 187
188 void onDraw(SkCanvas* canvas) override { 188 void onDraw(SkCanvas* canvas) override {
189 void (*drawProc[])(SkCanvas*, const SkRect&, SkImageFilter*) = { 189 void (*drawProc[])(SkCanvas*, const SkRect&, SkImageFilter*) = {
190 draw_paint, 190 draw_paint,
191 draw_line, draw_rect, draw_path, draw_text, 191 draw_line, draw_rect, draw_path, draw_text,
192 draw_bitmap, 192 draw_bitmap,
193 }; 193 };
194 194
195 SkColorFilter* cf = SkColorFilter::CreateModeFilter(SK_ColorRED, 195 auto cf = SkColorFilter::MakeModeFilter(SK_ColorRED, SkXfermode::kSrcIn_ Mode);
196 SkXfermode::kSrcIn_Mode);
197 SkImageFilter* filters[] = { 196 SkImageFilter* filters[] = {
198 nullptr, 197 nullptr,
199 IdentityImageFilter::Create(), 198 IdentityImageFilter::Create(),
200 FailImageFilter::Create(), 199 FailImageFilter::Create(),
201 SkColorFilterImageFilter::Create(cf), 200 SkColorFilterImageFilter::Create(cf.get()),
202 SkBlurImageFilter::Create(12.0f, 0.0f), 201 SkBlurImageFilter::Create(12.0f, 0.0f),
203 SkDropShadowImageFilter::Create(10.0f, 5.0f, 3.0f, 3.0f, SK_ColorBLU E, 202 SkDropShadowImageFilter::Create(10.0f, 5.0f, 3.0f, 3.0f, SK_ColorBLU E,
204 SkDropShadowImageFilter::kDrawShadowAndForeground_ShadowMode), 203 SkDropShadowImageFilter::kDrawShadowAndForeground_ShadowMode),
205 }; 204 };
206 cf->unref();
207 205
208 SkRect r = SkRect::MakeWH(SkIntToScalar(64), SkIntToScalar(64)); 206 SkRect r = SkRect::MakeWH(SkIntToScalar(64), SkIntToScalar(64));
209 SkScalar MARGIN = SkIntToScalar(16); 207 SkScalar MARGIN = SkIntToScalar(16);
210 SkScalar DX = r.width() + MARGIN; 208 SkScalar DX = r.width() + MARGIN;
211 SkScalar DY = r.height() + MARGIN; 209 SkScalar DY = r.height() + MARGIN;
212 210
213 canvas->translate(MARGIN, MARGIN); 211 canvas->translate(MARGIN, MARGIN);
214 for (size_t i = 0; i < SK_ARRAY_COUNT(drawProc); ++i) { 212 for (size_t i = 0; i < SK_ARRAY_COUNT(drawProc); ++i) {
215 canvas->save(); 213 canvas->save();
216 for (size_t j = 0; j < SK_ARRAY_COUNT(filters); ++j) { 214 for (size_t j = 0; j < SK_ARRAY_COUNT(filters); ++j) {
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 paint->setImageFilter(SkBlurImageFilter::Create(1.5f, 1.5f))->unref(); 311 paint->setImageFilter(SkBlurImageFilter::Create(1.5f, 1.5f))->unref();
314 } 312 }
315 }; 313 };
316 DEF_GM( return new ImageFiltersText_IF; ) 314 DEF_GM( return new ImageFiltersText_IF; )
317 315
318 class ImageFiltersText_CF : public ImageFiltersTextBaseGM { 316 class ImageFiltersText_CF : public ImageFiltersTextBaseGM {
319 public: 317 public:
320 ImageFiltersText_CF() : ImageFiltersTextBaseGM("color") {} 318 ImageFiltersText_CF() : ImageFiltersTextBaseGM("color") {}
321 319
322 void installFilter(SkPaint* paint) override { 320 void installFilter(SkPaint* paint) override {
323 paint->setColorFilter(SkColorFilter::CreateModeFilter(SK_ColorBLUE, SkXf ermode::kSrcIn_Mode))->unref(); 321 paint->setColorFilter(SkColorFilter::MakeModeFilter(SK_ColorBLUE, SkXfer mode::kSrcIn_Mode));
324 } 322 }
325 }; 323 };
326 DEF_GM( return new ImageFiltersText_CF; ) 324 DEF_GM( return new ImageFiltersText_CF; )
327 325
OLDNEW
« no previous file with comments | « gm/imagefilters.cpp ('k') | gm/imagefilterscropexpand.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698