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

Side by Side Diff: bench/DisplacementBench.cpp

Issue 1884253004: Revert of Update DisplacementMapEffect to sk_sp (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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 | « no previous file | bench/ImageFilterDAGBench.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 2013 Google Inc. 2 * Copyright 2013 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 "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkDisplacementMapEffect.h" 10 #include "SkDisplacementMapEffect.h"
11 #include "SkImageSource.h" 11 #include "SkImageSource.h"
12 #include "SkSurface.h" 12 #include "SkSurface.h"
13 13
14 #define FILTER_WIDTH_SMALL 32 14 #define FILTER_WIDTH_SMALL 32
15 #define FILTER_HEIGHT_SMALL 32 15 #define FILTER_HEIGHT_SMALL 32
16 #define FILTER_WIDTH_LARGE 256 16 #define FILTER_WIDTH_LARGE 256
17 #define FILTER_HEIGHT_LARGE 256 17 #define FILTER_HEIGHT_LARGE 256
18 18
19 class DisplacementBaseBench : public Benchmark { 19 class DisplacementBaseBench : public Benchmark {
20 public: 20 public:
21 DisplacementBaseBench(bool small) : fInitialized(false), fIsSmall(small) { } 21 DisplacementBaseBench(bool small) :
22 fInitialized(false), fIsSmall(small) {
23 }
22 24
23 protected: 25 protected:
24 void onDelayedSetup() override { 26 void onDelayedSetup() override {
25 if (!fInitialized) { 27 if (!fInitialized) {
26 this->makeBitmap(); 28 this->makeBitmap();
27 this->makeCheckerboard(); 29 this->makeCheckerboard();
28 fInitialized = true; 30 fInitialized = true;
29 } 31 }
30 } 32 }
31 33
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 sk_sp<SkImage> fCheckerboard; 85 sk_sp<SkImage> fCheckerboard;
84 86
85 private: 87 private:
86 bool fInitialized; 88 bool fInitialized;
87 bool fIsSmall; 89 bool fIsSmall;
88 typedef Benchmark INHERITED; 90 typedef Benchmark INHERITED;
89 }; 91 };
90 92
91 class DisplacementZeroBench : public DisplacementBaseBench { 93 class DisplacementZeroBench : public DisplacementBaseBench {
92 public: 94 public:
93 DisplacementZeroBench(bool small) : INHERITED(small) { } 95 DisplacementZeroBench(bool small) : INHERITED(small) {
96 }
94 97
95 protected: 98 protected:
96 const char* onGetName() override { 99 const char* onGetName() override {
97 return this->isSmall() ? "displacement_zero_small" : "displacement_zero_ large"; 100 return this->isSmall() ? "displacement_zero_small" : "displacement_zero_ large";
98 } 101 }
99 102
100 void onDraw(int loops, SkCanvas* canvas) override { 103 void onDraw(int loops, SkCanvas* canvas) override {
101 SkPaint paint; 104 SkPaint paint;
102 sk_sp<SkImageFilter> displ(SkImageSource::Make(fCheckerboard)); 105 sk_sp<SkImageFilter> displ(SkImageSource::Make(fCheckerboard));
103 // No displacement effect 106 // No displacement effect
104 paint.setImageFilter(SkDisplacementMapEffect::Make( 107 paint.setImageFilter(SkDisplacementMapEffect::Create(
105 SkDisplacementMapEffect::kR_Chan nelSelectorType, 108 SkDisplacementMapEffect::kR_ChannelSelectorType,
106 SkDisplacementMapEffect::kG_Chan nelSelectorType, 109 SkDisplacementMapEffect::kG_ChannelSelectorType, 0.0f, displ.get())) ->unref();
107 0.0f, std::move(displ), nullptr) );
108 110
109 for (int i = 0; i < loops; i++) { 111 for (int i = 0; i < loops; i++) {
110 this->drawClippedBitmap(canvas, 0, 0, paint); 112 this->drawClippedBitmap(canvas, 0, 0, paint);
111 } 113 }
112 } 114 }
113 115
114 private: 116 private:
115 typedef DisplacementBaseBench INHERITED; 117 typedef DisplacementBaseBench INHERITED;
116 }; 118 };
117 119
118 class DisplacementAlphaBench : public DisplacementBaseBench { 120 class DisplacementAlphaBench : public DisplacementBaseBench {
119 public: 121 public:
120 DisplacementAlphaBench(bool small) : INHERITED(small) { } 122 DisplacementAlphaBench(bool small) : INHERITED(small) {
123 }
121 124
122 protected: 125 protected:
123 const char* onGetName() override { 126 const char* onGetName() override {
124 return isSmall() ? "displacement_alpha_small" : "displacement_alpha_larg e"; 127 return isSmall() ? "displacement_alpha_small" : "displacement_alpha_larg e";
125 } 128 }
126 129
127 void onDraw(int loops, SkCanvas* canvas) override { 130 void onDraw(int loops, SkCanvas* canvas) override {
128 SkPaint paint; 131 SkPaint paint;
129 sk_sp<SkImageFilter> displ(SkImageSource::Make(fCheckerboard)); 132 sk_sp<SkImageFilter> displ(SkImageSource::Make(fCheckerboard));
130 // Displacement, with 1 alpha component (which isn't pre-multiplied) 133 // Displacement, with 1 alpha component (which isn't pre-multiplied)
131 paint.setImageFilter(SkDisplacementMapEffect::Make( 134 paint.setImageFilter(SkDisplacementMapEffect::Create(
132 SkDisplacementMapEffect::kB_Chan nelSelectorType, 135 SkDisplacementMapEffect::kB_ChannelSelectorType,
133 SkDisplacementMapEffect::kA_Chan nelSelectorType, 136 SkDisplacementMapEffect::kA_ChannelSelectorType, 16.0f, displ.get()) )->unref();
134 16.0f, std::move(displ), nullptr ));
135 for (int i = 0; i < loops; i++) { 137 for (int i = 0; i < loops; i++) {
136 this->drawClippedBitmap(canvas, 100, 0, paint); 138 drawClippedBitmap(canvas, 100, 0, paint);
137 } 139 }
138 } 140 }
139 141
140 private: 142 private:
141 typedef DisplacementBaseBench INHERITED; 143 typedef DisplacementBaseBench INHERITED;
142 }; 144 };
143 145
144 class DisplacementFullBench : public DisplacementBaseBench { 146 class DisplacementFullBench : public DisplacementBaseBench {
145 public: 147 public:
146 DisplacementFullBench(bool small) : INHERITED(small) { } 148 DisplacementFullBench(bool small) : INHERITED(small) {
149 }
147 150
148 protected: 151 protected:
149 const char* onGetName() override { 152 const char* onGetName() override {
150 return isSmall() ? "displacement_full_small" : "displacement_full_large" ; 153 return isSmall() ? "displacement_full_small" : "displacement_full_large" ;
151 } 154 }
152 155
153 void onDraw(int loops, SkCanvas* canvas) override { 156 void onDraw(int loops, SkCanvas* canvas) override {
154 SkPaint paint; 157 SkPaint paint;
155 sk_sp<SkImageFilter> displ(SkImageSource::Make(fCheckerboard)); 158 sk_sp<SkImageFilter> displ(SkImageSource::Make(fCheckerboard));
156 // Displacement, with 2 non-alpha components 159 // Displacement, with 2 non-alpha components
157 paint.setImageFilter(SkDisplacementMapEffect::Make( 160 paint.setImageFilter(SkDisplacementMapEffect::Create(
158 SkDisplacementMapEffect::kR_Chan nelSelectorType, 161 SkDisplacementMapEffect::kR_ChannelSelectorType,
159 SkDisplacementMapEffect::kB_Chan nelSelectorType, 162 SkDisplacementMapEffect::kB_ChannelSelectorType, 32.0f, displ.get()) )->unref();
160 32.0f, std::move(displ), nullptr ));
161 for (int i = 0; i < loops; ++i) { 163 for (int i = 0; i < loops; ++i) {
162 this->drawClippedBitmap(canvas, 200, 0, paint); 164 this->drawClippedBitmap(canvas, 200, 0, paint);
163 } 165 }
164 } 166 }
165 167
166 private: 168 private:
167 typedef DisplacementBaseBench INHERITED; 169 typedef DisplacementBaseBench INHERITED;
168 }; 170 };
169 171
170 /////////////////////////////////////////////////////////////////////////////// 172 ///////////////////////////////////////////////////////////////////////////////
171 173
172 DEF_BENCH( return new DisplacementZeroBench(true); ) 174 DEF_BENCH( return new DisplacementZeroBench(true); )
173 DEF_BENCH( return new DisplacementAlphaBench(true); ) 175 DEF_BENCH( return new DisplacementAlphaBench(true); )
174 DEF_BENCH( return new DisplacementFullBench(true); ) 176 DEF_BENCH( return new DisplacementFullBench(true); )
175 DEF_BENCH( return new DisplacementZeroBench(false); ) 177 DEF_BENCH( return new DisplacementZeroBench(false); )
176 DEF_BENCH( return new DisplacementAlphaBench(false); ) 178 DEF_BENCH( return new DisplacementAlphaBench(false); )
177 DEF_BENCH( return new DisplacementFullBench(false); ) 179 DEF_BENCH( return new DisplacementFullBench(false); )
OLDNEW
« no previous file with comments | « no previous file | bench/ImageFilterDAGBench.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698