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

Unified Diff: gm/imageblur.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 | « no previous file | gm/imagemagnifier.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/imageblur.cpp
diff --git a/gm/imageblur.cpp b/gm/imageblur.cpp
index 406f9ef973e3b8b47db1ced76589b32dc405a34d..2b2b73fa2bb192edabdc99d1cfc2a83a573d447c 100644
--- a/gm/imageblur.cpp
+++ b/gm/imageblur.cpp
@@ -7,6 +7,7 @@
#include "gm.h"
#include "SkBlurImageFilter.h"
+#include "SkRandom.h"
#define WIDTH 500
#define HEIGHT 500
@@ -33,14 +34,15 @@ protected:
paint.setImageFilter(new SkBlurImageFilter(24.0f, 0.0f))->unref();
canvas->saveLayer(NULL, &paint);
const char* str = "The quick brown fox jumped over the lazy dog.";
- srand(1234);
+
+ SkRandom rand;
SkPaint textPaint;
textPaint.setAntiAlias(true);
for (int i = 0; i < 25; ++i) {
- int x = rand() % WIDTH;
- int y = rand() % HEIGHT;
- textPaint.setColor(rand() % 0x1000000 | 0xFF000000);
- textPaint.setTextSize(SkIntToScalar(rand() % 300));
+ int x = rand.nextULessThan(WIDTH);
+ int y = rand.nextULessThan(HEIGHT);
+ textPaint.setColor(rand.nextBits(24) | 0xFF000000);
+ textPaint.setTextSize(rand.nextULessThan(300));
canvas->drawText(str, strlen(str), SkIntToScalar(x),
SkIntToScalar(y), textPaint);
}
« no previous file with comments | « no previous file | gm/imagemagnifier.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698