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

Side by Side Diff: bench/ImageFilterDAGBench.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 | « bench/BlurImageFilterBench.cpp ('k') | gm/coloremoji.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 2014 Google Inc. 2 * Copyright 2014 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 "Benchmark.h" 8 #include "Benchmark.h"
9 #include "SkBlurImageFilter.h" 9 #include "SkBlurImageFilter.h"
10 #include "SkDisplacementMapEffect.h" 10 #include "SkDisplacementMapEffect.h"
(...skipping 10 matching lines...) Expand all
21 21
22 protected: 22 protected:
23 const char* onGetName() override { 23 const char* onGetName() override {
24 return "image_filter_dag"; 24 return "image_filter_dag";
25 } 25 }
26 26
27 void onDraw(int loops, SkCanvas* canvas) override { 27 void onDraw(int loops, SkCanvas* canvas) override {
28 const SkRect rect = SkRect::Make(SkIRect::MakeWH(400, 400)); 28 const SkRect rect = SkRect::Make(SkIRect::MakeWH(400, 400));
29 29
30 for (int j = 0; j < loops; j++) { 30 for (int j = 0; j < loops; j++) {
31 sk_sp<SkImageFilter> blur(SkBlurImageFilter::Create(20.0f, 20.0f)); 31 sk_sp<SkImageFilter> blur(SkBlurImageFilter::Make(20.0f, 20.0f, null ptr));
32 sk_sp<SkImageFilter> inputs[kNumInputs]; 32 sk_sp<SkImageFilter> inputs[kNumInputs];
33 for (int i = 0; i < kNumInputs; ++i) { 33 for (int i = 0; i < kNumInputs; ++i) {
34 inputs[i] = blur; 34 inputs[i] = blur;
35 } 35 }
36 SkPaint paint; 36 SkPaint paint;
37 paint.setImageFilter(SkMergeImageFilter::Make(inputs, kNumInputs)); 37 paint.setImageFilter(SkMergeImageFilter::Make(inputs, kNumInputs));
38 canvas->drawRect(rect, paint); 38 canvas->drawRect(rect, paint);
39 } 39 }
40 } 40 }
41 41
42 private: 42 private:
43 static const int kNumInputs = 5; 43 static const int kNumInputs = 5;
44 44
45 typedef Benchmark INHERITED; 45 typedef Benchmark INHERITED;
46 }; 46 };
47 47
48 // Exercise a blur filter connected to both inputs of an SkDisplacementMapEffect . 48 // Exercise a blur filter connected to both inputs of an SkDisplacementMapEffect .
49 49
50 class ImageFilterDisplacedBlur : public Benchmark { 50 class ImageFilterDisplacedBlur : public Benchmark {
51 public: 51 public:
52 ImageFilterDisplacedBlur() {} 52 ImageFilterDisplacedBlur() {}
53 53
54 protected: 54 protected:
55 const char* onGetName() override { 55 const char* onGetName() override {
56 return "image_filter_displaced_blur"; 56 return "image_filter_displaced_blur";
57 } 57 }
58 58
59 void onDraw(int loops, SkCanvas* canvas) override { 59 void onDraw(int loops, SkCanvas* canvas) override {
60 for (int j = 0; j < loops; j++) { 60 for (int j = 0; j < loops; j++) {
61 SkAutoTUnref<SkImageFilter> blur(SkBlurImageFilter::Create(4.0f, 4.0 f)); 61 sk_sp<SkImageFilter> blur(SkBlurImageFilter::Make(4.0f, 4.0f, nullpt r));
62 SkDisplacementMapEffect::ChannelSelectorType xSelector = SkDisplacem entMapEffect::kR_ChannelSelectorType; 62 auto xSelector = SkDisplacementMapEffect::kR_ChannelSelectorType;
63 SkDisplacementMapEffect::ChannelSelectorType ySelector = SkDisplacem entMapEffect::kB_ChannelSelectorType; 63 auto ySelector = SkDisplacementMapEffect::kB_ChannelSelectorType;
64 SkScalar scale = 2; 64 SkScalar scale = 2;
65 SkAutoTUnref<SkImageFilter> displ(SkDisplacementMapEffect::Create(xS elector, ySelector, scale, 65 sk_sp<SkImageFilter> displ(SkDisplacementMapEffect::Create(xSelector , ySelector, scale,
66 bl ur.get(), blur.get())); 66 blur.get( ), blur.get()));
67 SkPaint paint; 67 SkPaint paint;
68 paint.setImageFilter(displ); 68 paint.setImageFilter(std::move(displ));
69 SkRect rect = SkRect::Make(SkIRect::MakeWH(400, 400)); 69 SkRect rect = SkRect::Make(SkIRect::MakeWH(400, 400));
70 canvas->drawRect(rect, paint); 70 canvas->drawRect(rect, paint);
71 } 71 }
72 } 72 }
73 73
74 private: 74 private:
75 typedef Benchmark INHERITED; 75 typedef Benchmark INHERITED;
76 }; 76 };
77 77
78 DEF_BENCH(return new ImageFilterDAGBench;) 78 DEF_BENCH(return new ImageFilterDAGBench;)
79 DEF_BENCH(return new ImageFilterDisplacedBlur;) 79 DEF_BENCH(return new ImageFilterDisplacedBlur;)
OLDNEW
« no previous file with comments | « bench/BlurImageFilterBench.cpp ('k') | gm/coloremoji.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698