aboutsummaryrefslogtreecommitdiffstats
path: root/gm/points.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'gm/points.cpp')
-rw-r--r--gm/points.cpp23
1 files changed, 15 insertions, 8 deletions
diff --git a/gm/points.cpp b/gm/points.cpp
index 48d8fec..e4f3c2e 100644
--- a/gm/points.cpp
+++ b/gm/points.cpp
@@ -1,3 +1,10 @@
+
+/*
+ * 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"
@@ -16,18 +23,18 @@ protected:
return make_isize(640, 490);
}
- void drawBG(SkCanvas* canvas) {
- canvas->drawColor(SK_ColorWHITE);
- }
-
static void fill_pts(SkPoint pts[], size_t n, SkRandom* rand) {
- for (size_t i = 0; i < n; i++)
- pts[i].set(rand->nextUScalar1() * 640, rand->nextUScalar1() * 480);
+ for (size_t i = 0; i < n; i++) {
+ // Compute these independently and store in variables, rather
+ // than in the parameter-passing expression, to get consistent
+ // evaluation order across compilers.
+ SkScalar y = rand->nextUScalar1() * 480;
+ SkScalar x = rand->nextUScalar1() * 640;
+ pts[i].set(x, y);
+ }
}
virtual void onDraw(SkCanvas* canvas) {
- this->drawBG(canvas);
-
canvas->translate(SK_Scalar1, SK_Scalar1);
SkRandom rand;