aboutsummaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorGravatar tfarina@chromium.org <tfarina@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-11-21 22:38:36 +0000
committerGravatar tfarina@chromium.org <tfarina@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-11-21 22:38:36 +0000
commit223137f49d1a4e805f5c1b1c20b7fd68719ac54b (patch)
tree511963f798f4ab68d8e2d0f5bfd33088b61f4522 /include
parent729e1c46cea63dfaa6e4a05608b8f3be41e19dce (diff)
Remove GrRandom API in favor of SkRandom.
TEST=tests R=bsalomon@google.com Review URL: https://codereview.appspot.com/6855062 git-svn-id: http://skia.googlecode.com/svn/trunk@6539 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'include')
-rw-r--r--include/core/SkRandom.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/include/core/SkRandom.h b/include/core/SkRandom.h
index 4731bbed4b..c8d71996e5 100644
--- a/include/core/SkRandom.h
+++ b/include/core/SkRandom.h
@@ -40,6 +40,21 @@ public:
*/
S16CPU nextS16() { return this->nextS() >> 16; }
+ /**
+ * Returns value [0...1) as a float
+ */
+ float nextF() {
+ // const is 1 / (2^32 - 1)
+ return (float)(this->nextU() * 2.32830644e-10);
+ }
+
+ /**
+ * Returns value [min...max) as a float
+ */
+ float nextRangeF(float min, float max) {
+ return min + this->nextF() * (max - min);
+ }
+
/** Return the next pseudo random number, as an unsigned value of
at most bitCount bits.
@param bitCount The maximum number of bits to be returned