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

Side by Side Diff: gm/convexpaths.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/complexclip2.cpp ('k') | gm/cubicpaths.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 "gm.h" 8 #include "gm.h"
9 #include "SkRandom.h" 9 #include "SkRandom.h"
10 #include "SkTArray.h" 10 #include "SkTArray.h"
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 // small circle. This is listed last so that it has device coords far 258 // small circle. This is listed last so that it has device coords far
259 // from the origin (small area relative to x,y values). 259 // from the origin (small area relative to x,y values).
260 fPaths.push_back().addCircle(0, 0, 1.2f); 260 fPaths.push_back().addCircle(0, 0, 1.2f);
261 } 261 }
262 262
263 virtual void onDraw(SkCanvas* canvas) { 263 virtual void onDraw(SkCanvas* canvas) {
264 this->makePaths(); 264 this->makePaths();
265 265
266 SkPaint paint; 266 SkPaint paint;
267 paint.setAntiAlias(true); 267 paint.setAntiAlias(true);
268 SkLCGRandom rand; 268 SkRandom rand;
269 canvas->translate(20 * SK_Scalar1, 20 * SK_Scalar1); 269 canvas->translate(20 * SK_Scalar1, 20 * SK_Scalar1);
270 270
271 // As we've added more paths this has gotten pretty big. Scale the whole thi ng down. 271 // As we've added more paths this has gotten pretty big. Scale the whole thi ng down.
272 canvas->scale(2 * SK_Scalar1 / 3, 2 * SK_Scalar1 / 3); 272 canvas->scale(2 * SK_Scalar1 / 3, 2 * SK_Scalar1 / 3);
273 273
274 for (int i = 0; i < fPaths.count(); ++i) { 274 for (int i = 0; i < fPaths.count(); ++i) {
275 canvas->save(); 275 canvas->save();
276 // position the path, and make it at off-integer coords. 276 // position the path, and make it at off-integer coords.
277 canvas->translate(SK_Scalar1 * 200 * (i % 5) + SK_Scalar1 / 10, 277 canvas->translate(SK_Scalar1 * 200 * (i % 5) + SK_Scalar1 / 10,
278 SK_Scalar1 * 200 * (i / 5) + 9 * SK_Scalar1 / 10); 278 SK_Scalar1 * 200 * (i / 5) + 9 * SK_Scalar1 / 10);
(...skipping 13 matching lines...) Expand all
292 typedef GM INHERITED; 292 typedef GM INHERITED;
293 SkTArray<SkPath> fPaths; 293 SkTArray<SkPath> fPaths;
294 }; 294 };
295 295
296 ////////////////////////////////////////////////////////////////////////////// 296 //////////////////////////////////////////////////////////////////////////////
297 297
298 static GM* MyFactory(void*) { return new ConvexPathsGM; } 298 static GM* MyFactory(void*) { return new ConvexPathsGM; }
299 static GMRegistry reg(MyFactory); 299 static GMRegistry reg(MyFactory);
300 300
301 } 301 }
OLDNEW
« no previous file with comments | « gm/complexclip2.cpp ('k') | gm/cubicpaths.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698