From 223137f49d1a4e805f5c1b1c20b7fd68719ac54b Mon Sep 17 00:00:00 2001 From: "tfarina@chromium.org" Date: Wed, 21 Nov 2012 22:38:36 +0000 Subject: 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 --- include/core/SkRandom.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'include') 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 -- cgit v1.2.3