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

Side by Side Diff: gm/circles.cpp

Issue 805963002: There can be only one (SkRandom)! (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Rebase Created 6 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
« no previous file with comments | « gm/beziers.cpp ('k') | gm/complexclip2.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 2012 Intel Inc. 3 * Copyright 2012 Intel 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 "gm.h" 8 #include "gm.h"
9 #include "SkBlurDrawLooper.h" 9 #include "SkBlurDrawLooper.h"
10 #include "SkBlurMask.h" 10 #include "SkBlurMask.h"
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 } 149 }
150 150
151 { 151 {
152 SkMatrix m; 152 SkMatrix m;
153 m.setRotate(SkIntToScalar(30)); 153 m.setRotate(SkIntToScalar(30));
154 fMatrices.push_back(m); 154 fMatrices.push_back(m);
155 } 155 }
156 } 156 }
157 157
158 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { 158 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
159 SkLCGRandom rand;
160 // Draw a giant AA circle as the background. 159 // Draw a giant AA circle as the background.
161 SkISize size = this->getISize(); 160 SkISize size = this->getISize();
162 SkScalar giantRadius = SkTMin(SkIntToScalar(size.fWidth), 161 SkScalar giantRadius = SkTMin(SkIntToScalar(size.fWidth),
163 SkIntToScalar(size.fHeight)) / 2.f; 162 SkIntToScalar(size.fHeight)) / 2.f;
164 SkPoint giantCenter = SkPoint::Make(SkIntToScalar(size.fWidth/2), 163 SkPoint giantCenter = SkPoint::Make(SkIntToScalar(size.fWidth/2),
165 SkIntToScalar(size.fHeight/2)); 164 SkIntToScalar(size.fHeight/2));
166 SkPaint giantPaint; 165 SkPaint giantPaint;
167 giantPaint.setAntiAlias(true); 166 giantPaint.setAntiAlias(true);
168 giantPaint.setColor(0x80808080); 167 giantPaint.setColor(0x80808080);
169 canvas->drawCircle(giantCenter.fX, giantCenter.fY, giantRadius, giantPai nt); 168 canvas->drawCircle(giantCenter.fX, giantCenter.fY, giantRadius, giantPai nt);
170 169
170 SkRandom rand;
171 canvas->translate(20 * SK_Scalar1, 20 * SK_Scalar1); 171 canvas->translate(20 * SK_Scalar1, 20 * SK_Scalar1);
172 int i; 172 int i;
173 for (i = 0; i < fPaints.count(); ++i) { 173 for (i = 0; i < fPaints.count(); ++i) {
174 canvas->save(); 174 canvas->save();
175 // position the path, and make it at off-integer coords. 175 // position the path, and make it at off-integer coords.
176 canvas->translate(SK_Scalar1 * 200 * (i % 5) + SK_Scalar1 / 4, 176 canvas->translate(SK_Scalar1 * 200 * (i % 5) + SK_Scalar1 / 4,
177 SK_Scalar1 * 200 * (i / 5) + 3 * SK_Scalar1 / 4); 177 SK_Scalar1 * 200 * (i / 5) + 3 * SK_Scalar1 / 4);
178 SkColor color = rand.nextU(); 178 SkColor color = rand.nextU();
179 color |= 0xff000000; 179 color |= 0xff000000;
180 fPaints[i].setColor(color); 180 fPaints[i].setColor(color);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 SkTArray<SkPaint> fPaints; 213 SkTArray<SkPaint> fPaints;
214 SkTArray<SkMatrix> fMatrices; 214 SkTArray<SkMatrix> fMatrices;
215 }; 215 };
216 216
217 ////////////////////////////////////////////////////////////////////////////// 217 //////////////////////////////////////////////////////////////////////////////
218 218
219 static GM* MyFactory(void*) { return new CircleGM; } 219 static GM* MyFactory(void*) { return new CircleGM; }
220 static GMRegistry reg(MyFactory); 220 static GMRegistry reg(MyFactory);
221 221
222 } 222 }
OLDNEW
« no previous file with comments | « gm/beziers.cpp ('k') | gm/complexclip2.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698