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

Side by Side Diff: bench/BitmapBench.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/BicubicBench.cpp ('k') | bench/BitmapRectBench.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 /* 2 /*
3 * Copyright 2011 Google Inc. 3 * Copyright 2011 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 #include "SkBenchmark.h" 8 #include "SkBenchmark.h"
9 #include "SkBitmap.h" 9 #include "SkBitmap.h"
10 #include "SkPaint.h" 10 #include "SkPaint.h"
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 if (SkBitmap::kIndex8_Config == fConfig) { 123 if (SkBitmap::kIndex8_Config == fConfig) {
124 convertToIndex666(bm, &fBitmap, fIsOpaque); 124 convertToIndex666(bm, &fBitmap, fIsOpaque);
125 } else { 125 } else {
126 fBitmap = bm; 126 fBitmap = bm;
127 } 127 }
128 128
129 fBitmap.setAlphaType(fIsOpaque ? kOpaque_SkAlphaType : kPremul_SkAlphaTy pe); 129 fBitmap.setAlphaType(fIsOpaque ? kOpaque_SkAlphaType : kPremul_SkAlphaTy pe);
130 fBitmap.setIsVolatile(fIsVolatile); 130 fBitmap.setIsVolatile(fIsVolatile);
131 } 131 }
132 132
133 virtual void onDraw(SkCanvas* canvas) { 133 virtual void onDraw(const int loops, SkCanvas* canvas) {
134 SkIPoint dim = this->getSize(); 134 SkIPoint dim = this->getSize();
135 SkRandom rand; 135 SkRandom rand;
136 136
137 SkPaint paint(fPaint); 137 SkPaint paint(fPaint);
138 this->setupPaint(&paint); 138 this->setupPaint(&paint);
139 139
140 const SkBitmap& bitmap = fBitmap; 140 const SkBitmap& bitmap = fBitmap;
141 const SkScalar x0 = SkIntToScalar(-bitmap.width() / 2); 141 const SkScalar x0 = SkIntToScalar(-bitmap.width() / 2);
142 const SkScalar y0 = SkIntToScalar(-bitmap.height() / 2); 142 const SkScalar y0 = SkIntToScalar(-bitmap.height() / 2);
143 143
144 for (int i = 0; i < this->getLoops(); i++) { 144 for (int i = 0; i < loops; i++) {
145 SkScalar x = x0 + rand.nextUScalar1() * dim.fX; 145 SkScalar x = x0 + rand.nextUScalar1() * dim.fX;
146 SkScalar y = y0 + rand.nextUScalar1() * dim.fY; 146 SkScalar y = y0 + rand.nextUScalar1() * dim.fY;
147 147
148 if (fForceUpdate) 148 if (fForceUpdate)
149 bitmap.notifyPixelsChanged(); 149 bitmap.notifyPixelsChanged();
150 150
151 canvas->drawBitmap(bitmap, x, y, &paint); 151 canvas->drawBitmap(bitmap, x, y, &paint);
152 } 152 }
153 } 153 }
154 154
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 } 214 }
215 if (isBilerp(fFlags)) { 215 if (isBilerp(fFlags)) {
216 fFullName.append("_bilerp"); 216 fFullName.append("_bilerp");
217 } else if (isBicubic(fFlags)) { 217 } else if (isBicubic(fFlags)) {
218 fFullName.append("_bicubic"); 218 fFullName.append("_bicubic");
219 } 219 }
220 220
221 return fFullName.c_str(); 221 return fFullName.c_str();
222 } 222 }
223 223
224 virtual void onDraw(SkCanvas* canvas) { 224 virtual void onDraw(const int loops, SkCanvas* canvas) {
225 SkISize dim = canvas->getDeviceSize(); 225 SkISize dim = canvas->getDeviceSize();
226 if (fFlags & kScale_Flag) { 226 if (fFlags & kScale_Flag) {
227 const SkScalar x = SkIntToScalar(dim.fWidth) / 2; 227 const SkScalar x = SkIntToScalar(dim.fWidth) / 2;
228 const SkScalar y = SkIntToScalar(dim.fHeight) / 2; 228 const SkScalar y = SkIntToScalar(dim.fHeight) / 2;
229 229
230 canvas->translate(x, y); 230 canvas->translate(x, y);
231 // just enough so we can't take the sprite case 231 // just enough so we can't take the sprite case
232 canvas->scale(SK_Scalar1 * 99/100, SK_Scalar1 * 99/100); 232 canvas->scale(SK_Scalar1 * 99/100, SK_Scalar1 * 99/100);
233 canvas->translate(-x, -y); 233 canvas->translate(-x, -y);
234 } 234 }
235 if (fFlags & kRotate_Flag) { 235 if (fFlags & kRotate_Flag) {
236 const SkScalar x = SkIntToScalar(dim.fWidth) / 2; 236 const SkScalar x = SkIntToScalar(dim.fWidth) / 2;
237 const SkScalar y = SkIntToScalar(dim.fHeight) / 2; 237 const SkScalar y = SkIntToScalar(dim.fHeight) / 2;
238 238
239 canvas->translate(x, y); 239 canvas->translate(x, y);
240 canvas->rotate(SkIntToScalar(35)); 240 canvas->rotate(SkIntToScalar(35));
241 canvas->translate(-x, -y); 241 canvas->translate(-x, -y);
242 } 242 }
243 INHERITED::onDraw(canvas); 243 INHERITED::onDraw(loops, canvas);
244 } 244 }
245 245
246 virtual void setupPaint(SkPaint* paint) SK_OVERRIDE { 246 virtual void setupPaint(SkPaint* paint) SK_OVERRIDE {
247 this->INHERITED::setupPaint(paint); 247 this->INHERITED::setupPaint(paint);
248 248
249 int index = 0; 249 int index = 0;
250 if (fFlags & kBilerp_Flag) { 250 if (fFlags & kBilerp_Flag) {
251 index |= 1; 251 index |= 1;
252 } 252 }
253 if (fFlags & kBicubic_Flag) { 253 if (fFlags & kBicubic_Flag) {
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 DEF_BENCH( return new FilterBitmapBench(true, SkBitmap::kARGB_8888_Config, true, false, kScale_Flag | kRotate_Flag | kBilerp_Flag); ) 376 DEF_BENCH( return new FilterBitmapBench(true, SkBitmap::kARGB_8888_Config, true, false, kScale_Flag | kRotate_Flag | kBilerp_Flag); )
377 377
378 DEF_BENCH( return new FilterBitmapBench(false, SkBitmap::kARGB_8888_Config, fals e, false, kScale_Flag | kBilerp_Flag | kBicubic_Flag); ) 378 DEF_BENCH( return new FilterBitmapBench(false, SkBitmap::kARGB_8888_Config, fals e, false, kScale_Flag | kBilerp_Flag | kBicubic_Flag); )
379 DEF_BENCH( return new FilterBitmapBench(false, SkBitmap::kARGB_8888_Config, fals e, false, kScale_Flag | kRotate_Flag | kBilerp_Flag | kBicubic_Flag); ) 379 DEF_BENCH( return new FilterBitmapBench(false, SkBitmap::kARGB_8888_Config, fals e, false, kScale_Flag | kRotate_Flag | kBilerp_Flag | kBicubic_Flag); )
380 380
381 // source alpha tests -> S32A_Opaque_BlitRow32_{arm,neon} 381 // source alpha tests -> S32A_Opaque_BlitRow32_{arm,neon}
382 DEF_BENCH( return new SourceAlphaBitmapBench(SourceAlphaBitmapBench::kOpaque_Sou rceAlpha, SkBitmap::kARGB_8888_Config); ) 382 DEF_BENCH( return new SourceAlphaBitmapBench(SourceAlphaBitmapBench::kOpaque_Sou rceAlpha, SkBitmap::kARGB_8888_Config); )
383 DEF_BENCH( return new SourceAlphaBitmapBench(SourceAlphaBitmapBench::kTransparen t_SourceAlpha, SkBitmap::kARGB_8888_Config); ) 383 DEF_BENCH( return new SourceAlphaBitmapBench(SourceAlphaBitmapBench::kTransparen t_SourceAlpha, SkBitmap::kARGB_8888_Config); )
384 DEF_BENCH( return new SourceAlphaBitmapBench(SourceAlphaBitmapBench::kTwoStripes _SourceAlpha, SkBitmap::kARGB_8888_Config); ) 384 DEF_BENCH( return new SourceAlphaBitmapBench(SourceAlphaBitmapBench::kTwoStripes _SourceAlpha, SkBitmap::kARGB_8888_Config); )
385 DEF_BENCH( return new SourceAlphaBitmapBench(SourceAlphaBitmapBench::kThreeStrip es_SourceAlpha, SkBitmap::kARGB_8888_Config); ) 385 DEF_BENCH( return new SourceAlphaBitmapBench(SourceAlphaBitmapBench::kThreeStrip es_SourceAlpha, SkBitmap::kARGB_8888_Config); )
OLDNEW
« no previous file with comments | « bench/BicubicBench.cpp ('k') | bench/BitmapRectBench.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698