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

Side by Side Diff: bench/DisplacementBench.cpp

Issue 99893003: Simplify benchmark internal API. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: rebase Created 7 years 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 | Annotate | Revision Log
« no previous file with comments | « bench/DeferredSurfaceCopyBench.cpp ('k') | bench/FSRectBench.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 #include "SkBenchmark.h" 7 #include "SkBenchmark.h"
8 #include "SkBitmapDevice.h" 8 #include "SkBitmapDevice.h"
9 #include "SkBitmapSource.h" 9 #include "SkBitmapSource.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 class DisplacementZeroBench : public DisplacementBaseBench { 92 class DisplacementZeroBench : public DisplacementBaseBench {
93 public: 93 public:
94 DisplacementZeroBench(bool small) : INHERITED(small) { 94 DisplacementZeroBench(bool small) : INHERITED(small) {
95 } 95 }
96 96
97 protected: 97 protected:
98 virtual const char* onGetName() SK_OVERRIDE { 98 virtual const char* onGetName() SK_OVERRIDE {
99 return this->isSmall() ? "displacement_zero_small" : "displacement_zero_ large"; 99 return this->isSmall() ? "displacement_zero_small" : "displacement_zero_ large";
100 } 100 }
101 101
102 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { 102 virtual void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE {
103 SkPaint paint; 103 SkPaint paint;
104 SkAutoTUnref<SkImageFilter> displ(SkNEW_ARGS(SkBitmapSource, (fCheckerbo ard))); 104 SkAutoTUnref<SkImageFilter> displ(SkNEW_ARGS(SkBitmapSource, (fCheckerbo ard)));
105 // No displacement effect 105 // No displacement effect
106 paint.setImageFilter(SkNEW_ARGS(SkDisplacementMapEffect, 106 paint.setImageFilter(SkNEW_ARGS(SkDisplacementMapEffect,
107 (SkDisplacementMapEffect::kR_ChannelSelectorType, 107 (SkDisplacementMapEffect::kR_ChannelSelectorType,
108 SkDisplacementMapEffect::kG_ChannelSelectorType, 0.0f, displ)))->un ref(); 108 SkDisplacementMapEffect::kG_ChannelSelectorType, 0.0f, displ)))->un ref();
109 109
110 for (int i = 0; i < this->getLoops(); i++) { 110 for (int i = 0; i < loops; i++) {
111 this->drawClippedBitmap(canvas, 0, 0, paint); 111 this->drawClippedBitmap(canvas, 0, 0, paint);
112 } 112 }
113 } 113 }
114 114
115 private: 115 private:
116 typedef DisplacementBaseBench INHERITED; 116 typedef DisplacementBaseBench INHERITED;
117 }; 117 };
118 118
119 class DisplacementAlphaBench : public DisplacementBaseBench { 119 class DisplacementAlphaBench : public DisplacementBaseBench {
120 public: 120 public:
121 DisplacementAlphaBench(bool small) : INHERITED(small) { 121 DisplacementAlphaBench(bool small) : INHERITED(small) {
122 } 122 }
123 123
124 protected: 124 protected:
125 virtual const char* onGetName() SK_OVERRIDE { 125 virtual const char* onGetName() SK_OVERRIDE {
126 return isSmall() ? "displacement_alpha_small" : "displacement_alpha_larg e"; 126 return isSmall() ? "displacement_alpha_small" : "displacement_alpha_larg e";
127 } 127 }
128 128
129 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { 129 virtual void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE {
130 SkPaint paint; 130 SkPaint paint;
131 SkAutoTUnref<SkImageFilter> displ(SkNEW_ARGS(SkBitmapSource, (fCheckerbo ard))); 131 SkAutoTUnref<SkImageFilter> displ(SkNEW_ARGS(SkBitmapSource, (fCheckerbo ard)));
132 // Displacement, with 1 alpha component (which isn't pre-multiplied) 132 // Displacement, with 1 alpha component (which isn't pre-multiplied)
133 paint.setImageFilter(SkNEW_ARGS(SkDisplacementMapEffect, 133 paint.setImageFilter(SkNEW_ARGS(SkDisplacementMapEffect,
134 (SkDisplacementMapEffect::kB_ChannelSelectorType, 134 (SkDisplacementMapEffect::kB_ChannelSelectorType,
135 SkDisplacementMapEffect::kA_ChannelSelectorType, 16.0f, displ)))->u nref(); 135 SkDisplacementMapEffect::kA_ChannelSelectorType, 16.0f, displ)))->u nref();
136 for (int i = 0; i < this->getLoops(); i++) { 136 for (int i = 0; i < loops; i++) {
137 drawClippedBitmap(canvas, 100, 0, paint); 137 drawClippedBitmap(canvas, 100, 0, paint);
138 } 138 }
139 } 139 }
140 140
141 private: 141 private:
142 typedef DisplacementBaseBench INHERITED; 142 typedef DisplacementBaseBench INHERITED;
143 }; 143 };
144 144
145 class DisplacementFullBench : public DisplacementBaseBench { 145 class DisplacementFullBench : public DisplacementBaseBench {
146 public: 146 public:
147 DisplacementFullBench(bool small) : INHERITED(small) { 147 DisplacementFullBench(bool small) : INHERITED(small) {
148 } 148 }
149 149
150 protected: 150 protected:
151 virtual const char* onGetName() SK_OVERRIDE { 151 virtual const char* onGetName() SK_OVERRIDE {
152 return isSmall() ? "displacement_full_small" : "displacement_full_large" ; 152 return isSmall() ? "displacement_full_small" : "displacement_full_large" ;
153 } 153 }
154 154
155 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { 155 virtual void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE {
156 SkPaint paint; 156 SkPaint paint;
157 SkAutoTUnref<SkImageFilter> displ(SkNEW_ARGS(SkBitmapSource, (fCheckerbo ard))); 157 SkAutoTUnref<SkImageFilter> displ(SkNEW_ARGS(SkBitmapSource, (fCheckerbo ard)));
158 // Displacement, with 2 non-alpha components 158 // Displacement, with 2 non-alpha components
159 paint.setImageFilter(SkNEW_ARGS(SkDisplacementMapEffect, 159 paint.setImageFilter(SkNEW_ARGS(SkDisplacementMapEffect,
160 (SkDisplacementMapEffect::kR_ChannelSelectorType, 160 (SkDisplacementMapEffect::kR_ChannelSelectorType,
161 SkDisplacementMapEffect::kB_ChannelSelectorType, 32.0f, displ)))->u nref(); 161 SkDisplacementMapEffect::kB_ChannelSelectorType, 32.0f, displ)))->u nref();
162 for (int i = 0; i < this->getLoops(); ++i) { 162 for (int i = 0; i < loops; ++i) {
163 this->drawClippedBitmap(canvas, 200, 0, paint); 163 this->drawClippedBitmap(canvas, 200, 0, paint);
164 } 164 }
165 } 165 }
166 166
167 private: 167 private:
168 typedef DisplacementBaseBench INHERITED; 168 typedef DisplacementBaseBench INHERITED;
169 }; 169 };
170 170
171 /////////////////////////////////////////////////////////////////////////////// 171 ///////////////////////////////////////////////////////////////////////////////
172 172
173 DEF_BENCH( return new DisplacementZeroBench(true); ) 173 DEF_BENCH( return new DisplacementZeroBench(true); )
174 DEF_BENCH( return new DisplacementAlphaBench(true); ) 174 DEF_BENCH( return new DisplacementAlphaBench(true); )
175 DEF_BENCH( return new DisplacementFullBench(true); ) 175 DEF_BENCH( return new DisplacementFullBench(true); )
176 DEF_BENCH( return new DisplacementZeroBench(false); ) 176 DEF_BENCH( return new DisplacementZeroBench(false); )
177 DEF_BENCH( return new DisplacementAlphaBench(false); ) 177 DEF_BENCH( return new DisplacementAlphaBench(false); )
178 DEF_BENCH( return new DisplacementFullBench(false); ) 178 DEF_BENCH( return new DisplacementFullBench(false); )
OLDNEW
« no previous file with comments | « bench/DeferredSurfaceCopyBench.cpp ('k') | bench/FSRectBench.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698