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

Side by Side Diff: samplecode/SampleCull.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/SampleClip.cpp ('k') | samplecode/SampleEmptyPath.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 "SampleCode.h" 8 #include "SampleCode.h"
9 #include "SkView.h" 9 #include "SkView.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 default: 89 default:
90 break; 90 break;
91 } 91 }
92 } 92 }
93 93
94 FINISHED2: 94 FINISHED2:
95 *count = n; 95 *count = n;
96 return array; 96 return array;
97 } 97 }
98 98
99 static SkScalar nextScalarRange(SkMWCRandom& rand, SkScalar min, SkScalar max) { 99 static SkScalar nextScalarRange(SkRandom& rand, SkScalar min, SkScalar max) {
100 return min + SkScalarMul(rand.nextUScalar1(), max - min); 100 return min + SkScalarMul(rand.nextUScalar1(), max - min);
101 } 101 }
102 102
103 class CullView : public SampleView { 103 class CullView : public SampleView {
104 public: 104 public:
105 CullView() { 105 CullView() {
106 fClip.set(0, 0, SkIntToScalar(160), SkIntToScalar(160)); 106 fClip.set(0, 0, SkIntToScalar(160), SkIntToScalar(160));
107 107
108 SkMWCRandom rand; 108 SkRandom rand;
109 109
110 for (int i = 0; i < 50; i++) { 110 for (int i = 0; i < 50; i++) {
111 SkScalar x = nextScalarRange(rand, -fClip.width()*1, fClip.width()*2 ); 111 SkScalar x = nextScalarRange(rand, -fClip.width()*1, fClip.width()*2 );
112 SkScalar y = nextScalarRange(rand, -fClip.height()*1, fClip.height() *2); 112 SkScalar y = nextScalarRange(rand, -fClip.height()*1, fClip.height() *2);
113 if (i == 0) 113 if (i == 0)
114 fPath.moveTo(x, y); 114 fPath.moveTo(x, y);
115 else 115 else
116 fPath.lineTo(x, y); 116 fPath.lineTo(x, y);
117 } 117 }
118 118
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 SkPath fPath; 186 SkPath fPath;
187 int fPtCount; 187 int fPtCount;
188 188
189 typedef SampleView INHERITED; 189 typedef SampleView INHERITED;
190 }; 190 };
191 191
192 ////////////////////////////////////////////////////////////////////////////// 192 //////////////////////////////////////////////////////////////////////////////
193 193
194 static SkView* MyFactory() { return new CullView; } 194 static SkView* MyFactory() { return new CullView; }
195 static SkViewRegister reg(MyFactory); 195 static SkViewRegister reg(MyFactory);
OLDNEW
« no previous file with comments | « samplecode/SampleClip.cpp ('k') | samplecode/SampleEmptyPath.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698