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

Side by Side Diff: bench/TextBench.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/TableBench.cpp ('k') | bench/TileBench.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 "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkFontHost.h" 10 #include "SkFontHost.h"
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 } 84 }
85 fName.appendf("_%s", fontQualityName(fPaint)); 85 fName.appendf("_%s", fontQualityName(fPaint));
86 if (SK_ColorBLACK != fPaint.getColor()) { 86 if (SK_ColorBLACK != fPaint.getColor()) {
87 fName.appendf("_%02X", fPaint.getAlpha()); 87 fName.appendf("_%02X", fPaint.getAlpha());
88 } else { 88 } else {
89 fName.append("_BK"); 89 fName.append("_BK");
90 } 90 }
91 return fName.c_str(); 91 return fName.c_str();
92 } 92 }
93 93
94 virtual void onDraw(SkCanvas* canvas) { 94 virtual void onDraw(const int loops, SkCanvas* canvas) {
95 const SkIPoint dim = this->getSize(); 95 const SkIPoint dim = this->getSize();
96 SkRandom rand; 96 SkRandom rand;
97 97
98 SkPaint paint(fPaint); 98 SkPaint paint(fPaint);
99 this->setupPaint(&paint); 99 this->setupPaint(&paint);
100 // explicitly need these 100 // explicitly need these
101 paint.setColor(fPaint.getColor()); 101 paint.setColor(fPaint.getColor());
102 paint.setAntiAlias(kBW != fFQ); 102 paint.setAntiAlias(kBW != fFQ);
103 paint.setLCDRenderText(kLCD == fFQ); 103 paint.setLCDRenderText(kLCD == fFQ);
104 104
105 const SkScalar x0 = SkIntToScalar(-10); 105 const SkScalar x0 = SkIntToScalar(-10);
106 const SkScalar y0 = SkIntToScalar(-10); 106 const SkScalar y0 = SkIntToScalar(-10);
107 107
108 if (fDoPos) { 108 if (fDoPos) {
109 // realistically, the matrix is often at least translated, so we 109 // realistically, the matrix is often at least translated, so we
110 // do that since it exercises different code in drawPosText. 110 // do that since it exercises different code in drawPosText.
111 canvas->translate(SK_Scalar1, SK_Scalar1); 111 canvas->translate(SK_Scalar1, SK_Scalar1);
112 } 112 }
113 113
114 for (int i = 0; i < this->getLoops(); i++) { 114 for (int i = 0; i < loops; i++) {
115 if (fDoPos) { 115 if (fDoPos) {
116 canvas->drawPosText(fText.c_str(), fText.size(), fPos, paint); 116 canvas->drawPosText(fText.c_str(), fText.size(), fPos, paint);
117 } else { 117 } else {
118 SkScalar x = x0 + rand.nextUScalar1() * dim.fX; 118 SkScalar x = x0 + rand.nextUScalar1() * dim.fX;
119 SkScalar y = y0 + rand.nextUScalar1() * dim.fY; 119 SkScalar y = y0 + rand.nextUScalar1() * dim.fY;
120 canvas->drawText(fText.c_str(), fText.size(), x, y, paint); 120 canvas->drawText(fText.c_str(), fText.size(), x, y, paint);
121 } 121 }
122 } 122 }
123 } 123 }
124 124
(...skipping 11 matching lines...) Expand all
136 136
137 DEF_BENCH( return new TextBench(STR, 16, 0xFF000000, kAA); ) 137 DEF_BENCH( return new TextBench(STR, 16, 0xFF000000, kAA); )
138 DEF_BENCH( return new TextBench(STR, 16, 0xFFFF0000, kAA); ) 138 DEF_BENCH( return new TextBench(STR, 16, 0xFFFF0000, kAA); )
139 DEF_BENCH( return new TextBench(STR, 16, 0x88FF0000, kAA); ) 139 DEF_BENCH( return new TextBench(STR, 16, 0x88FF0000, kAA); )
140 140
141 DEF_BENCH( return new TextBench(STR, 16, 0xFF000000, kLCD); ) 141 DEF_BENCH( return new TextBench(STR, 16, 0xFF000000, kLCD); )
142 DEF_BENCH( return new TextBench(STR, 16, 0xFFFF0000, kLCD); ) 142 DEF_BENCH( return new TextBench(STR, 16, 0xFFFF0000, kLCD); )
143 DEF_BENCH( return new TextBench(STR, 16, 0x88FF0000, kLCD); ) 143 DEF_BENCH( return new TextBench(STR, 16, 0x88FF0000, kLCD); )
144 144
145 DEF_BENCH( return new TextBench(STR, 16, 0xFF000000, kAA, true); ) 145 DEF_BENCH( return new TextBench(STR, 16, 0xFF000000, kAA, true); )
OLDNEW
« no previous file with comments | « bench/TableBench.cpp ('k') | bench/TileBench.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698