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

Side by Side Diff: bench/ChartBench.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/BlurRoundRectBench.cpp ('k') | bench/ChecksumBench.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 "SkBenchmark.h" 8 #include "SkBenchmark.h"
9 #include "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkPaint.h" 10 #include "SkPaint.h"
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 95
96 protected: 96 protected:
97 virtual const char* onGetName() SK_OVERRIDE { 97 virtual const char* onGetName() SK_OVERRIDE {
98 if (fAA) { 98 if (fAA) {
99 return "chart_aa"; 99 return "chart_aa";
100 } else { 100 } else {
101 return "chart_bw"; 101 return "chart_bw";
102 } 102 }
103 } 103 }
104 104
105 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { 105 virtual void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE {
106 bool sizeChanged = false; 106 bool sizeChanged = false;
107 if (canvas->getDeviceSize() != fSize) { 107 if (canvas->getDeviceSize() != fSize) {
108 fSize = canvas->getDeviceSize(); 108 fSize = canvas->getDeviceSize();
109 sizeChanged = true; 109 sizeChanged = true;
110 } 110 }
111 111
112 SkScalar ySpread = SkIntToScalar(fSize.fHeight / 20); 112 SkScalar ySpread = SkIntToScalar(fSize.fHeight / 20);
113 113
114 SkScalar height = SkIntToScalar(fSize.fHeight); 114 SkScalar height = SkIntToScalar(fSize.fHeight);
115 if (sizeChanged) { 115 if (sizeChanged) {
116 int dataPointCount = SkMax32(fSize.fWidth / kPixelsPerTick + 1, 2); 116 int dataPointCount = SkMax32(fSize.fWidth / kPixelsPerTick + 1, 2);
117 117
118 for (int i = 0; i < kNumGraphs; ++i) { 118 for (int i = 0; i < kNumGraphs; ++i) {
119 SkScalar y = (kNumGraphs - i) * (height - ySpread) / (kNumGraphs + 1); 119 SkScalar y = (kNumGraphs - i) * (height - ySpread) / (kNumGraphs + 1);
120 fData[i].reset(); 120 fData[i].reset();
121 gen_data(y, ySpread, dataPointCount, fData + i); 121 gen_data(y, ySpread, dataPointCount, fData + i);
122 } 122 }
123 } 123 }
124 124
125 for (int frame = 0; frame < this->getLoops(); ++frame) { 125 for (int frame = 0; frame < loops; ++frame) {
126 126
127 canvas->clear(0xFFE0F0E0); 127 canvas->clear(0xFFE0F0E0);
128 128
129 static SkRandom colorRand; 129 static SkRandom colorRand;
130 static SkColor gColors[kNumGraphs] = { 0x0 }; 130 static SkColor gColors[kNumGraphs] = { 0x0 };
131 if (0 == gColors[0]) { 131 if (0 == gColors[0]) {
132 for (int i = 0; i < kNumGraphs; ++i) { 132 for (int i = 0; i < kNumGraphs; ++i) {
133 gColors[i] = colorRand.nextU() | 0xff000000; 133 gColors[i] = colorRand.nextU() | 0xff000000;
134 } 134 }
135 } 135 }
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 SkTDArray<SkScalar> fData[kNumGraphs]; 184 SkTDArray<SkScalar> fData[kNumGraphs];
185 bool fAA; 185 bool fAA;
186 186
187 typedef SkBenchmark INHERITED; 187 typedef SkBenchmark INHERITED;
188 }; 188 };
189 189
190 ////////////////////////////////////////////////////////////////////////////// 190 //////////////////////////////////////////////////////////////////////////////
191 191
192 DEF_BENCH( return new ChartBench(true); ) 192 DEF_BENCH( return new ChartBench(true); )
193 DEF_BENCH( return new ChartBench(false); ) 193 DEF_BENCH( return new ChartBench(false); )
OLDNEW
« no previous file with comments | « bench/BlurRoundRectBench.cpp ('k') | bench/ChecksumBench.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698