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

Unified Diff: gm/imagemagnifier.cpp

Issue 24105003: srand() + rand() -> SkRandom (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: 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/imageblur.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/imagemagnifier.cpp
diff --git a/gm/imagemagnifier.cpp b/gm/imagemagnifier.cpp
index 0966121d0dcd8ed759f121b76e99543d77c0b441..a5f942d5ccbf96e0d1f7e0a19e56a124aa4d438f 100644
--- a/gm/imagemagnifier.cpp
+++ b/gm/imagemagnifier.cpp
@@ -7,6 +7,7 @@
#include "gm.h"
#include "SkMagnifierImageFilter.h"
+#include "SkRandom.h"
#define WIDTH 500
#define HEIGHT 500
@@ -44,12 +45,12 @@ protected:
canvas->saveLayer(NULL, &paint);
paint.setAntiAlias(true);
const char* str = "The quick brown fox jumped over the lazy dog.";
- srand(1234);
+ SkRandom rand;
for (int i = 0; i < 25; ++i) {
- int x = rand() % WIDTH;
- int y = rand() % HEIGHT;
- paint.setColor(rand() % 0x1000000 | 0xFF000000);
- paint.setTextSize(SkIntToScalar(rand() % 300));
+ int x = rand.nextULessThan(WIDTH);
+ int y = rand.nextULessThan(HEIGHT);
+ paint.setColor(rand.nextBits(24) | 0xFF000000);
+ paint.setTextSize(rand.nextULessThan(300));
canvas->drawText(str, strlen(str), SkIntToScalar(x),
SkIntToScalar(y), paint);
}
« no previous file with comments | « gm/imageblur.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698