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

Unified Diff: gm/getpostextpath.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/emptypath.cpp ('k') | gm/hittestpath.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/getpostextpath.cpp
diff --git a/gm/getpostextpath.cpp b/gm/getpostextpath.cpp
index 39a3fc160fa4414ff1bfa94330365aba22271de2..d8336b2ca172a61bc1ff374c61bfdf6b78516a9b 100644
--- a/gm/getpostextpath.cpp
+++ b/gm/getpostextpath.cpp
@@ -1,73 +1,73 @@
-/*
- * Copyright 2012 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 "SkPaint.h"
-#include "SkRandom.h"
-#include "SkTemplates.h"
-
-class GetPosTextPathGM : public skiagm::GM {
-public:
- GetPosTextPathGM() {}
-
-protected:
- SkString onShortName() {
- return SkString("getpostextpath");
- }
-
- SkISize onISize() { return skiagm::make_isize(480, 780); }
-
- static void strokePath(SkCanvas* canvas, const SkPath& path) {
- SkPaint paint;
- paint.setAntiAlias(true);
- paint.setColor(SK_ColorRED);
- paint.setStyle(SkPaint::kStroke_Style);
- canvas->drawPath(path, paint);
- }
-
- virtual void onDraw(SkCanvas* canvas) {
- // explicitly add spaces, to test a prev. bug
- const char* text = "Ham bur ge fons";
- size_t len = strlen(text);
- SkPath path;
-
- SkPaint paint;
- paint.setAntiAlias(true);
- paint.setTextSize(SkIntToScalar(48));
-
- canvas->translate(SkIntToScalar(10), SkIntToScalar(64));
-
- canvas->drawText(text, len, 0, 0, paint);
- paint.getTextPath(text, len, 0, 0, &path);
- strokePath(canvas, path);
- path.reset();
-
- SkAutoTArray<SkPoint> pos(len);
- SkAutoTArray<SkScalar> widths(len);
- paint.getTextWidths(text, len, &widths[0]);
-
- SkRandom rand;
- SkScalar x = SkIntToScalar(20);
- SkScalar y = SkIntToScalar(100);
- for (size_t i = 0; i < len; ++i) {
- pos[i].set(x, y + rand.nextSScalar1() * 24);
- x += widths[i];
- }
-
- canvas->translate(0, SkIntToScalar(64));
-
- canvas->drawPosText(text, len, &pos[0], paint);
- paint.getPosTextPath(text, len, &pos[0], &path);
- strokePath(canvas, path);
- }
-};
-
-//////////////////////////////////////////////////////////////////////////////
-
-static skiagm::GM* F(void*) { return new GetPosTextPathGM; }
-static skiagm::GMRegistry gR(F);
+/*
+ * Copyright 2012 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 "SkPaint.h"
+#include "SkRandom.h"
+#include "SkTemplates.h"
+
+class GetPosTextPathGM : public skiagm::GM {
+public:
+ GetPosTextPathGM() {}
+
+protected:
+ SkString onShortName() {
+ return SkString("getpostextpath");
+ }
+
+ SkISize onISize() { return skiagm::make_isize(480, 780); }
+
+ static void strokePath(SkCanvas* canvas, const SkPath& path) {
+ SkPaint paint;
+ paint.setAntiAlias(true);
+ paint.setColor(SK_ColorRED);
+ paint.setStyle(SkPaint::kStroke_Style);
+ canvas->drawPath(path, paint);
+ }
+
+ virtual void onDraw(SkCanvas* canvas) {
+ // explicitly add spaces, to test a prev. bug
+ const char* text = "Ham bur ge fons";
+ size_t len = strlen(text);
+ SkPath path;
+
+ SkPaint paint;
+ paint.setAntiAlias(true);
+ paint.setTextSize(SkIntToScalar(48));
+
+ canvas->translate(SkIntToScalar(10), SkIntToScalar(64));
+
+ canvas->drawText(text, len, 0, 0, paint);
+ paint.getTextPath(text, len, 0, 0, &path);
+ strokePath(canvas, path);
+ path.reset();
+
+ SkAutoTArray<SkPoint> pos(len);
+ SkAutoTArray<SkScalar> widths(len);
+ paint.getTextWidths(text, len, &widths[0]);
+
+ SkLCGRandom rand;
+ SkScalar x = SkIntToScalar(20);
+ SkScalar y = SkIntToScalar(100);
+ for (size_t i = 0; i < len; ++i) {
+ pos[i].set(x, y + rand.nextSScalar1() * 24);
+ x += widths[i];
+ }
+
+ canvas->translate(0, SkIntToScalar(64));
+
+ canvas->drawPosText(text, len, &pos[0], paint);
+ paint.getPosTextPath(text, len, &pos[0], &path);
+ strokePath(canvas, path);
+ }
+};
+
+//////////////////////////////////////////////////////////////////////////////
+
+static skiagm::GM* F(void*) { return new GetPosTextPathGM; }
+static skiagm::GMRegistry gR(F);
« no previous file with comments | « gm/emptypath.cpp ('k') | gm/hittestpath.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698