aboutsummaryrefslogtreecommitdiffhomepage
path: root/gm/imageblur.cpp
diff options
context:
space:
mode:
authorGravatar mtklein@google.com <mtklein@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-09-16 18:19:30 +0000
committerGravatar mtklein@google.com <mtklein@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-09-16 18:19:30 +0000
commitcfa7ba7753720425bf09e7d6ee2905b36b8e27a3 (patch)
tree439393e6e20c49aaeb08be459a9eeedf86380edb /gm/imageblur.cpp
parentb6e915da2e7a55905b62875393b3dec7a3ab32d9 (diff)
srand() + rand() -> SkRandom
rand() makes these two GMs thread-unsafe. When run concurrently they can interfere with each other. Use SkRandom instead to guarantee independence. BUG=skia:1590 R=jvanverth@google.com Review URL: https://codereview.chromium.org/24105003 git-svn-id: http://skia.googlecode.com/svn/trunk@11295 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'gm/imageblur.cpp')
-rw-r--r--gm/imageblur.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/gm/imageblur.cpp b/gm/imageblur.cpp
index 406f9ef973..2b2b73fa2b 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);
}