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

Side by Side Diff: bench/ChartBench.cpp

Issue 23576015: Change old PRG to be SkLCGRandom; change new one to SkRandom (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Fix some spurious SkMWCRandoms Created 7 years, 3 months 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/BlurBench.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 /* 2 /*
3 * Copyright 2013 Google Inc. 3 * Copyright 2013 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 8
9 #include "SkBenchmark.h" 9 #include "SkBenchmark.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
11 #include "SkPaint.h" 11 #include "SkPaint.h"
12 #include "SkRandom.h" 12 #include "SkRandom.h"
13 13
14 /** 14 /**
15 * This is a conversion of samplecode/SampleChart.cpp into a bench. It sure woul d be nice to be able 15 * This is a conversion of samplecode/SampleChart.cpp into a bench. It sure woul d be nice to be able
16 * to write one subclass that can be a GM, bench, and/or Sample. 16 * to write one subclass that can be a GM, bench, and/or Sample.
17 */ 17 */
18 18
19 namespace { 19 namespace {
20 20
21 // Generates y values for the chart plots. 21 // Generates y values for the chart plots.
22 void gen_data(SkScalar yAvg, SkScalar ySpread, int count, SkTDArray<SkScalar>* d ataPts) { 22 void gen_data(SkScalar yAvg, SkScalar ySpread, int count, SkTDArray<SkScalar>* d ataPts) {
23 dataPts->setCount(count); 23 dataPts->setCount(count);
24 static SkMWCRandom gRandom; 24 static SkRandom gRandom;
25 for (int i = 0; i < count; ++i) { 25 for (int i = 0; i < count; ++i) {
26 (*dataPts)[i] = gRandom.nextRangeScalar(yAvg - SkScalarHalf(ySpread), 26 (*dataPts)[i] = gRandom.nextRangeScalar(yAvg - SkScalarHalf(ySpread),
27 yAvg + SkScalarHalf(ySpread)); 27 yAvg + SkScalarHalf(ySpread));
28 } 28 }
29 } 29 }
30 30
31 // Generates a path to stroke along the top of each plot and a fill path for the area below each 31 // Generates a path to stroke along the top of each plot and a fill path for the area below each
32 // plot. The fill path is bounded below by the bottomData plot points or a horiz ontal line at 32 // plot. The fill path is bounded below by the bottomData plot points or a horiz ontal line at
33 // yBase if bottomData == NULL. 33 // yBase if bottomData == NULL.
34 // The plots are animated by rotating the data points by leftShift. 34 // The plots are animated by rotating the data points by leftShift.
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 SkScalar y = (kNumGraphs - i) * (height - ySpread) / (kNumGraphs + 1); 124 SkScalar y = (kNumGraphs - i) * (height - ySpread) / (kNumGraphs + 1);
125 fData[i].reset(); 125 fData[i].reset();
126 gen_data(y, ySpread, dataPointCount, fData + i); 126 gen_data(y, ySpread, dataPointCount, fData + i);
127 } 127 }
128 } 128 }
129 129
130 for (int frame = 0; frame < kFramesPerRun; ++frame) { 130 for (int frame = 0; frame < kFramesPerRun; ++frame) {
131 131
132 canvas->clear(0xFFE0F0E0); 132 canvas->clear(0xFFE0F0E0);
133 133
134 static SkMWCRandom colorRand; 134 static SkRandom colorRand;
135 static SkColor gColors[kNumGraphs] = { 0x0 }; 135 static SkColor gColors[kNumGraphs] = { 0x0 };
136 if (0 == gColors[0]) { 136 if (0 == gColors[0]) {
137 for (int i = 0; i < kNumGraphs; ++i) { 137 for (int i = 0; i < kNumGraphs; ++i) {
138 gColors[i] = colorRand.nextU() | 0xff000000; 138 gColors[i] = colorRand.nextU() | 0xff000000;
139 } 139 }
140 } 140 }
141 141
142 SkPath plotPath; 142 SkPath plotPath;
143 SkPath fillPath; 143 SkPath fillPath;
144 144
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 typedef SkBenchmark INHERITED; 194 typedef SkBenchmark INHERITED;
195 }; 195 };
196 196
197 ////////////////////////////////////////////////////////////////////////////// 197 //////////////////////////////////////////////////////////////////////////////
198 198
199 static SkBenchmark* Fact0(void* p) { return new ChartBench(p, true); } 199 static SkBenchmark* Fact0(void* p) { return new ChartBench(p, true); }
200 static SkBenchmark* Fact1(void* p) { return new ChartBench(p, false); } 200 static SkBenchmark* Fact1(void* p) { return new ChartBench(p, false); }
201 201
202 static BenchRegistry gReg0(Fact0); 202 static BenchRegistry gReg0(Fact0);
203 static BenchRegistry gReg1(Fact1); 203 static BenchRegistry gReg1(Fact1);
OLDNEW
« no previous file with comments | « bench/BlurBench.cpp ('k') | bench/ChecksumBench.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698