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

Side by Side Diff: bench/DisplacementBench.cpp

Issue 1842243002: Update SkImageSource to sk_sp (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: update to ToT 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/MergeBench.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"
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 DisplacementZeroBench(bool small) : INHERITED(small) { 95 DisplacementZeroBench(bool small) : INHERITED(small) {
96 } 96 }
97 97
98 protected: 98 protected:
99 const char* onGetName() override { 99 const char* onGetName() override {
100 return this->isSmall() ? "displacement_zero_small" : "displacement_zero_ large"; 100 return this->isSmall() ? "displacement_zero_small" : "displacement_zero_ large";
101 } 101 }
102 102
103 void onDraw(int loops, SkCanvas* canvas) override { 103 void onDraw(int loops, SkCanvas* canvas) override {
104 SkPaint paint; 104 SkPaint paint;
105 SkAutoTUnref<SkImageFilter> displ(SkImageSource::Create(fCheckerboard.ge t())); 105 sk_sp<SkImageFilter> displ(SkImageSource::Make(fCheckerboard));
106 // No displacement effect 106 // No displacement effect
107 paint.setImageFilter(SkDisplacementMapEffect::Create( 107 paint.setImageFilter(SkDisplacementMapEffect::Create(
108 SkDisplacementMapEffect::kR_ChannelSelectorType, 108 SkDisplacementMapEffect::kR_ChannelSelectorType,
109 SkDisplacementMapEffect::kG_ChannelSelectorType, 0.0f, displ))->unre f(); 109 SkDisplacementMapEffect::kG_ChannelSelectorType, 0.0f, displ.get())) ->unref();
110 110
111 for (int i = 0; i < loops; i++) { 111 for (int i = 0; i < loops; i++) {
112 this->drawClippedBitmap(canvas, 0, 0, paint); 112 this->drawClippedBitmap(canvas, 0, 0, paint);
113 } 113 }
114 } 114 }
115 115
116 private: 116 private:
117 typedef DisplacementBaseBench INHERITED; 117 typedef DisplacementBaseBench INHERITED;
118 }; 118 };
119 119
120 class DisplacementAlphaBench : public DisplacementBaseBench { 120 class DisplacementAlphaBench : public DisplacementBaseBench {
121 public: 121 public:
122 DisplacementAlphaBench(bool small) : INHERITED(small) { 122 DisplacementAlphaBench(bool small) : INHERITED(small) {
123 } 123 }
124 124
125 protected: 125 protected:
126 const char* onGetName() override { 126 const char* onGetName() override {
127 return isSmall() ? "displacement_alpha_small" : "displacement_alpha_larg e"; 127 return isSmall() ? "displacement_alpha_small" : "displacement_alpha_larg e";
128 } 128 }
129 129
130 void onDraw(int loops, SkCanvas* canvas) override { 130 void onDraw(int loops, SkCanvas* canvas) override {
131 SkPaint paint; 131 SkPaint paint;
132 SkAutoTUnref<SkImageFilter> displ(SkImageSource::Create(fCheckerboard.ge t())); 132 sk_sp<SkImageFilter> displ(SkImageSource::Make(fCheckerboard));
133 // Displacement, with 1 alpha component (which isn't pre-multiplied) 133 // Displacement, with 1 alpha component (which isn't pre-multiplied)
134 paint.setImageFilter(SkDisplacementMapEffect::Create( 134 paint.setImageFilter(SkDisplacementMapEffect::Create(
135 SkDisplacementMapEffect::kB_ChannelSelectorType, 135 SkDisplacementMapEffect::kB_ChannelSelectorType,
136 SkDisplacementMapEffect::kA_ChannelSelectorType, 16.0f, displ))->unr ef(); 136 SkDisplacementMapEffect::kA_ChannelSelectorType, 16.0f, displ.get()) )->unref();
137 for (int i = 0; i < loops; i++) { 137 for (int i = 0; i < loops; i++) {
138 drawClippedBitmap(canvas, 100, 0, paint); 138 drawClippedBitmap(canvas, 100, 0, paint);
139 } 139 }
140 } 140 }
141 141
142 private: 142 private:
143 typedef DisplacementBaseBench INHERITED; 143 typedef DisplacementBaseBench INHERITED;
144 }; 144 };
145 145
146 class DisplacementFullBench : public DisplacementBaseBench { 146 class DisplacementFullBench : public DisplacementBaseBench {
147 public: 147 public:
148 DisplacementFullBench(bool small) : INHERITED(small) { 148 DisplacementFullBench(bool small) : INHERITED(small) {
149 } 149 }
150 150
151 protected: 151 protected:
152 const char* onGetName() override { 152 const char* onGetName() override {
153 return isSmall() ? "displacement_full_small" : "displacement_full_large" ; 153 return isSmall() ? "displacement_full_small" : "displacement_full_large" ;
154 } 154 }
155 155
156 void onDraw(int loops, SkCanvas* canvas) override { 156 void onDraw(int loops, SkCanvas* canvas) override {
157 SkPaint paint; 157 SkPaint paint;
158 SkAutoTUnref<SkImageFilter> displ(SkImageSource::Create(fCheckerboard.ge t())); 158 sk_sp<SkImageFilter> displ(SkImageSource::Make(fCheckerboard));
159 // Displacement, with 2 non-alpha components 159 // Displacement, with 2 non-alpha components
160 paint.setImageFilter(SkDisplacementMapEffect::Create( 160 paint.setImageFilter(SkDisplacementMapEffect::Create(
161 SkDisplacementMapEffect::kR_ChannelSelectorType, 161 SkDisplacementMapEffect::kR_ChannelSelectorType,
162 SkDisplacementMapEffect::kB_ChannelSelectorType, 32.0f, displ))->unr ef(); 162 SkDisplacementMapEffect::kB_ChannelSelectorType, 32.0f, displ.get()) )->unref();
163 for (int i = 0; i < loops; ++i) { 163 for (int i = 0; i < loops; ++i) {
164 this->drawClippedBitmap(canvas, 200, 0, paint); 164 this->drawClippedBitmap(canvas, 200, 0, paint);
165 } 165 }
166 } 166 }
167 167
168 private: 168 private:
169 typedef DisplacementBaseBench INHERITED; 169 typedef DisplacementBaseBench INHERITED;
170 }; 170 };
171 171
172 /////////////////////////////////////////////////////////////////////////////// 172 ///////////////////////////////////////////////////////////////////////////////
173 173
174 DEF_BENCH( return new DisplacementZeroBench(true); ) 174 DEF_BENCH( return new DisplacementZeroBench(true); )
175 DEF_BENCH( return new DisplacementAlphaBench(true); ) 175 DEF_BENCH( return new DisplacementAlphaBench(true); )
176 DEF_BENCH( return new DisplacementFullBench(true); ) 176 DEF_BENCH( return new DisplacementFullBench(true); )
177 DEF_BENCH( return new DisplacementZeroBench(false); ) 177 DEF_BENCH( return new DisplacementZeroBench(false); )
178 DEF_BENCH( return new DisplacementAlphaBench(false); ) 178 DEF_BENCH( return new DisplacementAlphaBench(false); )
179 DEF_BENCH( return new DisplacementFullBench(false); ) 179 DEF_BENCH( return new DisplacementFullBench(false); )
OLDNEW
« no previous file with comments | « no previous file | bench/MergeBench.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698