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

Unified Diff: gm/hittestpath.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/getpostextpath.cpp ('k') | gm/linepaths.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/hittestpath.cpp
diff --git a/gm/hittestpath.cpp b/gm/hittestpath.cpp
index 03275719fb2bd0ed697df4f1968d926494ac50de..45dce7f08d79ea6b8be70019b0289336c54deadd 100644
--- a/gm/hittestpath.cpp
+++ b/gm/hittestpath.cpp
@@ -1,75 +1,75 @@
-/*
- * 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 "SkCanvas.h"
-#include "SkCullPoints.h"
-#include "SkRandom.h"
-
-static void test_hittest(SkCanvas* canvas, const SkPath& path) {
- SkPaint paint;
- SkRect r = path.getBounds();
-
- paint.setColor(SK_ColorRED);
- canvas->drawPath(path, paint);
-
- const SkScalar MARGIN = SkIntToScalar(4);
-
- paint.setColor(0x800000FF);
- for (SkScalar y = r.fTop + SK_ScalarHalf - MARGIN; y < r.fBottom + MARGIN; y += SK_Scalar1) {
- for (SkScalar x = r.fLeft + SK_ScalarHalf - MARGIN; x < r.fRight + MARGIN; x += SK_Scalar1) {
- if (path.contains(x, y)) {
- canvas->drawPoint(x, y, paint);
- }
- }
- }
-}
-
-class HitTestPathGM : public skiagm::GM {
-public:
- HitTestPathGM () {}
-
-protected:
- virtual SkString onShortName() {
- return SkString("hittestpath");
- }
-
- virtual SkISize onISize() { return SkISize::Make(700, 460); }
-
- virtual void onDraw(SkCanvas* canvas) {
- SkPath path;
- SkRandom rand;
-
- int scale = 300;
- for (int i = 0; i < 4; ++i) {
- path.lineTo(rand.nextUScalar1() * scale, rand.nextUScalar1() * scale);
- path.quadTo(rand.nextUScalar1() * scale, rand.nextUScalar1() * scale,
- rand.nextUScalar1() * scale, rand.nextUScalar1() * scale);
- path.cubicTo(rand.nextUScalar1() * scale, rand.nextUScalar1() * scale,
- rand.nextUScalar1() * scale, rand.nextUScalar1() * scale,
- rand.nextUScalar1() * scale, rand.nextUScalar1() * scale);
- }
-
- path.setFillType(SkPath::kEvenOdd_FillType);
- path.offset(SkIntToScalar(20), SkIntToScalar(20));
-
- test_hittest(canvas, path);
-
- canvas->translate(SkIntToScalar(scale), 0);
- path.setFillType(SkPath::kWinding_FillType);
-
- test_hittest(canvas, path);
- }
-
-private:
- typedef GM INHERITED;
-};
-
-//////////////////////////////////////////////////////////////////////////////
-
-static skiagm::GM* MyFactory(void*) { return new HitTestPathGM; }
-static skiagm::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 "SkCanvas.h"
+#include "SkCullPoints.h"
+#include "SkRandom.h"
+
+static void test_hittest(SkCanvas* canvas, const SkPath& path) {
+ SkPaint paint;
+ SkRect r = path.getBounds();
+
+ paint.setColor(SK_ColorRED);
+ canvas->drawPath(path, paint);
+
+ const SkScalar MARGIN = SkIntToScalar(4);
+
+ paint.setColor(0x800000FF);
+ for (SkScalar y = r.fTop + SK_ScalarHalf - MARGIN; y < r.fBottom + MARGIN; y += SK_Scalar1) {
+ for (SkScalar x = r.fLeft + SK_ScalarHalf - MARGIN; x < r.fRight + MARGIN; x += SK_Scalar1) {
+ if (path.contains(x, y)) {
+ canvas->drawPoint(x, y, paint);
+ }
+ }
+ }
+}
+
+class HitTestPathGM : public skiagm::GM {
+public:
+ HitTestPathGM () {}
+
+protected:
+ virtual SkString onShortName() {
+ return SkString("hittestpath");
+ }
+
+ virtual SkISize onISize() { return SkISize::Make(700, 460); }
+
+ virtual void onDraw(SkCanvas* canvas) {
+ SkPath path;
+ SkLCGRandom rand;
+
+ int scale = 300;
+ for (int i = 0; i < 4; ++i) {
+ path.lineTo(rand.nextUScalar1() * scale, rand.nextUScalar1() * scale);
+ path.quadTo(rand.nextUScalar1() * scale, rand.nextUScalar1() * scale,
+ rand.nextUScalar1() * scale, rand.nextUScalar1() * scale);
+ path.cubicTo(rand.nextUScalar1() * scale, rand.nextUScalar1() * scale,
+ rand.nextUScalar1() * scale, rand.nextUScalar1() * scale,
+ rand.nextUScalar1() * scale, rand.nextUScalar1() * scale);
+ }
+
+ path.setFillType(SkPath::kEvenOdd_FillType);
+ path.offset(SkIntToScalar(20), SkIntToScalar(20));
+
+ test_hittest(canvas, path);
+
+ canvas->translate(SkIntToScalar(scale), 0);
+ path.setFillType(SkPath::kWinding_FillType);
+
+ test_hittest(canvas, path);
+ }
+
+private:
+ typedef GM INHERITED;
+};
+
+//////////////////////////////////////////////////////////////////////////////
+
+static skiagm::GM* MyFactory(void*) { return new HitTestPathGM; }
+static skiagm::GMRegistry reg(MyFactory);
« no previous file with comments | « gm/getpostextpath.cpp ('k') | gm/linepaths.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698