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

Side by Side Diff: gm/localmatriximagefilter.cpp

Issue 1842793002: Switch SkLocalMatrixImageFilter and SkPaintImageFilter over to sk_sp (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Ooops 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/imagefiltersscaled.cpp ('k') | include/core/SkImageFilter.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 "gm.h" 8 #include "gm.h"
9 #include "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkBlurImageFilter.h" 10 #include "SkBlurImageFilter.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 42
43 protected: 43 protected:
44 SkString onShortName() override { 44 SkString onShortName() override {
45 return SkString("localmatriximagefilter"); 45 return SkString("localmatriximagefilter");
46 } 46 }
47 47
48 SkISize onISize() override { 48 SkISize onISize() override {
49 return SkISize::Make(640, 640); 49 return SkISize::Make(640, 640);
50 } 50 }
51 51
52 static void show_image(SkCanvas* canvas, SkImage* image, SkImageFilter* filt er) { 52 static void show_image(SkCanvas* canvas, SkImage* image, sk_sp<SkImageFilter > filter) {
53 SkPaint paint; 53 SkPaint paint;
54 paint.setStyle(SkPaint::kStroke_Style); 54 paint.setStyle(SkPaint::kStroke_Style);
55 SkRect r = SkRect::MakeIWH(image->width(), image->height()).makeOutset(S K_ScalarHalf, 55 SkRect r = SkRect::MakeIWH(image->width(), image->height()).makeOutset(S K_ScalarHalf,
56 S K_ScalarHalf); 56 S K_ScalarHalf);
57 canvas->drawRect(r, paint); 57 canvas->drawRect(r, paint);
58 58
59 paint.setStyle(SkPaint::kFill_Style); 59 paint.setStyle(SkPaint::kFill_Style);
60 paint.setImageFilter(filter); 60 paint.setImageFilter(filter);
61 canvas->drawImage(image, 0, 0, &paint); 61 canvas->drawImage(image, 0, 0, &paint);
62 } 62 }
(...skipping 11 matching lines...) Expand all
74 const SkMatrix matrices[] = { 74 const SkMatrix matrices[] = {
75 SkMatrix::MakeScale(SK_ScalarHalf, SK_ScalarHalf), 75 SkMatrix::MakeScale(SK_ScalarHalf, SK_ScalarHalf),
76 SkMatrix::MakeScale(2, 2), 76 SkMatrix::MakeScale(2, 2),
77 SkMatrix::MakeTrans(10, 10) 77 SkMatrix::MakeTrans(10, 10)
78 }; 78 };
79 79
80 const SkScalar spacer = image0->width() * 3.0f / 2; 80 const SkScalar spacer = image0->width() * 3.0f / 2;
81 81
82 canvas->translate(40, 40); 82 canvas->translate(40, 40);
83 for (auto&& factory : factories) { 83 for (auto&& factory : factories) {
84 SkAutoTUnref<SkImageFilter> filter(factory()); 84 sk_sp<SkImageFilter> filter(factory());
85 85
86 canvas->save(); 86 canvas->save();
87 show_image(canvas, image0.get(), filter); 87 show_image(canvas, image0.get(), filter);
88 for (const auto& matrix : matrices) { 88 for (const auto& matrix : matrices) {
89 SkAutoTUnref<SkImageFilter> localFilter(filter->newWithLocalMatr ix(matrix)); 89 sk_sp<SkImageFilter> localFilter(filter->makeWithLocalMatrix(mat rix));
90 canvas->translate(spacer, 0); 90 canvas->translate(spacer, 0);
91 show_image(canvas, image0.get(), localFilter); 91 show_image(canvas, image0.get(), std::move(localFilter));
92 } 92 }
93 canvas->restore(); 93 canvas->restore();
94 canvas->translate(0, spacer); 94 canvas->translate(0, spacer);
95 } 95 }
96 } 96 }
97 97
98 private: 98 private:
99 typedef GM INHERITED; 99 typedef GM INHERITED;
100 }; 100 };
101 DEF_GM( return new LocalMatrixImageFilterGM; ) 101 DEF_GM( return new LocalMatrixImageFilterGM; )
OLDNEW
« no previous file with comments | « gm/imagefiltersscaled.cpp ('k') | include/core/SkImageFilter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698