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

Unified Diff: gm/strokerects.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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gm/roundrects.cpp ('k') | gm/strokes.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/strokerects.cpp
diff --git a/gm/strokerects.cpp b/gm/strokerects.cpp
index 61ee9e0309b472d503d8f3cf0ebcf6d926a5b850..5d42ca39ab871456b0836828adac097b8f5b1d09 100644
--- a/gm/strokerects.cpp
+++ b/gm/strokerects.cpp
@@ -1,83 +1,83 @@
-
-/*
- * Copyright 2011 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-
-
-#include "gm.h"
-#include "SkRandom.h"
-
-namespace skiagm {
-
-#define W 400
-#define H 400
-#define N 100
-
-static const SkScalar SW = SkIntToScalar(W);
-static const SkScalar SH = SkIntToScalar(H);
-
-class StrokeRectGM : public GM {
-public:
- StrokeRectGM() {}
-
-protected:
- virtual SkString onShortName() {
- return SkString("strokerects");
- }
-
- virtual SkISize onISize() {
- return make_isize(W*2, H*2);
- }
-
- static void rnd_rect(SkRect* r, SkRandom& rand) {
- SkScalar x = rand.nextUScalar1() * W;
- SkScalar y = rand.nextUScalar1() * H;
- SkScalar w = rand.nextUScalar1() * (W >> 2);
- SkScalar h = rand.nextUScalar1() * (H >> 2);
- SkScalar hoffset = rand.nextSScalar1();
- SkScalar woffset = rand.nextSScalar1();
-
- r->set(x, y, x + w, y + h);
- r->offset(-w/2 + woffset, -h/2 + hoffset);
- }
-
- virtual void onDraw(SkCanvas* canvas) {
- SkPaint paint;
- paint.setStyle(SkPaint::kStroke_Style);
-
- for (int y = 0; y < 2; y++) {
- paint.setAntiAlias(!!y);
- for (int x = 0; x < 2; x++) {
- paint.setStrokeWidth(x * SkIntToScalar(3));
-
- SkAutoCanvasRestore acr(canvas, true);
- canvas->translate(SW * x, SH * y);
- canvas->clipRect(SkRect::MakeLTRB(
- SkIntToScalar(2), SkIntToScalar(2)
- , SW - SkIntToScalar(2), SH - SkIntToScalar(2)
- ));
-
- SkRandom rand;
- for (int i = 0; i < N; i++) {
- SkRect r;
- rnd_rect(&r, rand);
- canvas->drawRect(r, paint);
- }
- }
- }
- }
-
-private:
- typedef GM INHERITED;
-};
-
-//////////////////////////////////////////////////////////////////////////////
-
-static GM* MyFactory(void*) { return new StrokeRectGM; }
-static GMRegistry reg(MyFactory);
-
-}
+
+/*
+ * Copyright 2011 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+
+
+#include "gm.h"
+#include "SkRandom.h"
+
+namespace skiagm {
+
+#define W 400
+#define H 400
+#define N 100
+
+static const SkScalar SW = SkIntToScalar(W);
+static const SkScalar SH = SkIntToScalar(H);
+
+class StrokeRectGM : public GM {
+public:
+ StrokeRectGM() {}
+
+protected:
+ virtual SkString onShortName() {
+ return SkString("strokerects");
+ }
+
+ virtual SkISize onISize() {
+ return make_isize(W*2, H*2);
+ }
+
+ static void rnd_rect(SkRect* r, SkLCGRandom& rand) {
+ SkScalar x = rand.nextUScalar1() * W;
+ SkScalar y = rand.nextUScalar1() * H;
+ SkScalar w = rand.nextUScalar1() * (W >> 2);
+ SkScalar h = rand.nextUScalar1() * (H >> 2);
+ SkScalar hoffset = rand.nextSScalar1();
+ SkScalar woffset = rand.nextSScalar1();
+
+ r->set(x, y, x + w, y + h);
+ r->offset(-w/2 + woffset, -h/2 + hoffset);
+ }
+
+ virtual void onDraw(SkCanvas* canvas) {
+ SkPaint paint;
+ paint.setStyle(SkPaint::kStroke_Style);
+
+ for (int y = 0; y < 2; y++) {
+ paint.setAntiAlias(!!y);
+ for (int x = 0; x < 2; x++) {
+ paint.setStrokeWidth(x * SkIntToScalar(3));
+
+ SkAutoCanvasRestore acr(canvas, true);
+ canvas->translate(SW * x, SH * y);
+ canvas->clipRect(SkRect::MakeLTRB(
+ SkIntToScalar(2), SkIntToScalar(2)
+ , SW - SkIntToScalar(2), SH - SkIntToScalar(2)
+ ));
+
+ SkLCGRandom rand;
+ for (int i = 0; i < N; i++) {
+ SkRect r;
+ rnd_rect(&r, rand);
+ canvas->drawRect(r, paint);
+ }
+ }
+ }
+ }
+
+private:
+ typedef GM INHERITED;
+};
+
+//////////////////////////////////////////////////////////////////////////////
+
+static GM* MyFactory(void*) { return new StrokeRectGM; }
+static GMRegistry reg(MyFactory);
+
+}
« no previous file with comments | « gm/roundrects.cpp ('k') | gm/strokes.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698