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

Side by Side Diff: samplecode/SampleChart.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 | « samplecode/SampleApp.cpp ('k') | samplecode/SampleClip.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 #include "SampleCode.h" 8 #include "SampleCode.h"
9 #include "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkPaint.h" 10 #include "SkPaint.h"
11 #include "SkRandom.h" 11 #include "SkRandom.h"
12 #include "SkView.h" 12 #include "SkView.h"
13 13
14 namespace { 14 namespace {
15 15
16 // Generates y values for the chart plots. 16 // Generates y values for the chart plots.
17 void gen_data(SkScalar yAvg, SkScalar ySpread, int count, SkTDArray<SkScalar>* d ataPts) { 17 void gen_data(SkScalar yAvg, SkScalar ySpread, int count, SkTDArray<SkScalar>* d ataPts) {
18 dataPts->setCount(count); 18 dataPts->setCount(count);
19 static SkMWCRandom gRandom; 19 static SkRandom gRandom;
20 for (int i = 0; i < count; ++i) { 20 for (int i = 0; i < count; ++i) {
21 (*dataPts)[i] = gRandom.nextRangeScalar(yAvg - SkScalarHalf(ySpread), 21 (*dataPts)[i] = gRandom.nextRangeScalar(yAvg - SkScalarHalf(ySpread),
22 yAvg + SkScalarHalf(ySpread)); 22 yAvg + SkScalarHalf(ySpread));
23 } 23 }
24 } 24 }
25 25
26 // Generates a path to stroke along the top of each plot and a fill path for the area below each 26 // Generates a path to stroke along the top of each plot and a fill path for the area below each
27 // plot. The fill path is bounded below by the bottomData plot points or a horiz ontal line at 27 // plot. The fill path is bounded below by the bottomData plot points or a horiz ontal line at
28 // yBase if bottomData == NULL. 28 // yBase if bottomData == NULL.
29 // The plots are animated by rotating the data points by leftShift. 29 // The plots are animated by rotating the data points by leftShift.
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 116
117 for (int i = 0; i < kNumGraphs; ++i) { 117 for (int i = 0; i < kNumGraphs; ++i) {
118 SkScalar y = (kNumGraphs - i) * (height - ySpread) / (kNumGraphs + 1); 118 SkScalar y = (kNumGraphs - i) * (height - ySpread) / (kNumGraphs + 1);
119 fData[i].reset(); 119 fData[i].reset();
120 gen_data(y, ySpread, dataPointCount, fData + i); 120 gen_data(y, ySpread, dataPointCount, fData + i);
121 } 121 }
122 } 122 }
123 123
124 canvas->clear(0xFFE0F0E0); 124 canvas->clear(0xFFE0F0E0);
125 125
126 static SkMWCRandom colorRand; 126 static SkRandom colorRand;
127 static SkColor gColors[kNumGraphs] = { 0x0 }; 127 static SkColor gColors[kNumGraphs] = { 0x0 };
128 if (0 == gColors[0]) { 128 if (0 == gColors[0]) {
129 for (int i = 0; i < kNumGraphs; ++i) { 129 for (int i = 0; i < kNumGraphs; ++i) {
130 gColors[i] = colorRand.nextU() | 0xff000000; 130 gColors[i] = colorRand.nextU() | 0xff000000;
131 } 131 }
132 } 132 }
133 133
134 SkPath plotPath; 134 SkPath plotPath;
135 SkPath fillPath; 135 SkPath fillPath;
136 136
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 int fShift; 179 int fShift;
180 SkISize fSize; 180 SkISize fSize;
181 SkTDArray<SkScalar> fData[kNumGraphs]; 181 SkTDArray<SkScalar> fData[kNumGraphs];
182 typedef SampleView INHERITED; 182 typedef SampleView INHERITED;
183 }; 183 };
184 184
185 ////////////////////////////////////////////////////////////////////////////// 185 //////////////////////////////////////////////////////////////////////////////
186 186
187 static SkView* MyFactory() { return new ChartView; } 187 static SkView* MyFactory() { return new ChartView; }
188 static SkViewRegister reg(MyFactory); 188 static SkViewRegister reg(MyFactory);
OLDNEW
« no previous file with comments | « samplecode/SampleApp.cpp ('k') | samplecode/SampleClip.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698