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

Side by Side Diff: bench/ShaderMaskBench.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/ScalarBench.cpp ('k') | bench/SkBenchmark.h » ('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 "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkColorShader.h" 10 #include "SkColorShader.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 } 49 }
50 50
51 protected: 51 protected:
52 virtual const char* onGetName() { 52 virtual const char* onGetName() {
53 fName.printf("shadermask"); 53 fName.printf("shadermask");
54 fName.appendf("_%s", fontQualityName(fPaint)); 54 fName.appendf("_%s", fontQualityName(fPaint));
55 fName.appendf("_%02X", fPaint.getAlpha()); 55 fName.appendf("_%02X", fPaint.getAlpha());
56 return fName.c_str(); 56 return fName.c_str();
57 } 57 }
58 58
59 virtual void onDraw(SkCanvas* canvas) { 59 virtual void onDraw(const int loops, SkCanvas* canvas) {
60 const SkIPoint dim = this->getSize(); 60 const SkIPoint dim = this->getSize();
61 SkRandom rand; 61 SkRandom rand;
62 62
63 SkPaint paint(fPaint); 63 SkPaint paint(fPaint);
64 this->setupPaint(&paint); 64 this->setupPaint(&paint);
65 // explicitly need these 65 // explicitly need these
66 paint.setAlpha(fPaint.getAlpha()); 66 paint.setAlpha(fPaint.getAlpha());
67 paint.setAntiAlias(kBW != fFQ); 67 paint.setAntiAlias(kBW != fFQ);
68 paint.setLCDRenderText(kLCD == fFQ); 68 paint.setLCDRenderText(kLCD == fFQ);
69 69
70 const SkScalar x0 = SkIntToScalar(-10); 70 const SkScalar x0 = SkIntToScalar(-10);
71 const SkScalar y0 = SkIntToScalar(-10); 71 const SkScalar y0 = SkIntToScalar(-10);
72 72
73 paint.setTextSize(SkIntToScalar(12)); 73 paint.setTextSize(SkIntToScalar(12));
74 for (int i = 0; i < this->getLoops(); i++) { 74 for (int i = 0; i < loops; i++) {
75 SkScalar x = x0 + rand.nextUScalar1() * dim.fX; 75 SkScalar x = x0 + rand.nextUScalar1() * dim.fX;
76 SkScalar y = y0 + rand.nextUScalar1() * dim.fY; 76 SkScalar y = y0 + rand.nextUScalar1() * dim.fY;
77 canvas->drawText(fText.c_str(), fText.size(), x, y, paint); 77 canvas->drawText(fText.c_str(), fText.size(), x, y, paint);
78 } 78 }
79 79
80 paint.setTextSize(SkIntToScalar(48)); 80 paint.setTextSize(SkIntToScalar(48));
81 for (int i = 0; i < this->getLoops() / 4 ; i++) { 81 for (int i = 0; i < loops / 4 ; i++) {
82 SkScalar x = x0 + rand.nextUScalar1() * dim.fX; 82 SkScalar x = x0 + rand.nextUScalar1() * dim.fX;
83 SkScalar y = y0 + rand.nextUScalar1() * dim.fY; 83 SkScalar y = y0 + rand.nextUScalar1() * dim.fY;
84 canvas->drawText(fText.c_str(), fText.size(), x, y, paint); 84 canvas->drawText(fText.c_str(), fText.size(), x, y, paint);
85 } 85 }
86 } 86 }
87 87
88 private: 88 private:
89 typedef SkBenchmark INHERITED; 89 typedef SkBenchmark INHERITED;
90 }; 90 };
91 91
92 /////////////////////////////////////////////////////////////////////////////// 92 ///////////////////////////////////////////////////////////////////////////////
93 93
94 DEF_BENCH( return new ShaderMaskBench(true, kBW); ) 94 DEF_BENCH( return new ShaderMaskBench(true, kBW); )
95 DEF_BENCH( return new ShaderMaskBench(false, kBW); ) 95 DEF_BENCH( return new ShaderMaskBench(false, kBW); )
96 DEF_BENCH( return new ShaderMaskBench(true, kAA); ) 96 DEF_BENCH( return new ShaderMaskBench(true, kAA); )
97 DEF_BENCH( return new ShaderMaskBench(false, kAA); ) 97 DEF_BENCH( return new ShaderMaskBench(false, kAA); )
98 DEF_BENCH( return new ShaderMaskBench(true, kLCD); ) 98 DEF_BENCH( return new ShaderMaskBench(true, kLCD); )
99 DEF_BENCH( return new ShaderMaskBench(false, kLCD); ) 99 DEF_BENCH( return new ShaderMaskBench(false, kLCD); )
OLDNEW
« no previous file with comments | « bench/ScalarBench.cpp ('k') | bench/SkBenchmark.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698