diff options
author | skia.committer@gmail.com <skia.committer@gmail.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-01-31 07:06:15 +0000 |
---|---|---|
committer | skia.committer@gmail.com <skia.committer@gmail.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-01-31 07:06:15 +0000 |
commit | 24d5ee4f886dd238731381b92e9d13d7194af728 (patch) | |
tree | 0780dbadc0af2ee69c4dfa0e2b1acf0de1b846eb /include/utils | |
parent | c3ecf65c69d26fbf462b9c4d1d4a35ec34beaed8 (diff) |
Sanitizing source files in Skia_Periodic_House_Keeping
git-svn-id: http://skia.googlecode.com/svn/trunk@7484 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'include/utils')
-rw-r--r-- | include/utils/SkRandom.h | 50 |
1 files changed, 25 insertions, 25 deletions
diff --git a/include/utils/SkRandom.h b/include/utils/SkRandom.h index 13a6c2ebc2..150384de0f 100644 --- a/include/utils/SkRandom.h +++ b/include/utils/SkRandom.h @@ -152,11 +152,11 @@ private: }; /** \class SkMWCRandom - + Utility class that implements pseudo random 32bit numbers using Marsaglia's - multiply-with-carry "mother of all" algorithm. Unlike rand(), this class holds + multiply-with-carry "mother of all" algorithm. Unlike rand(), this class holds its own state, so that multiple instances can be used with no side-effects. - + Has a large period and all bits are well-randomized. */ class SkMWCRandom { @@ -165,13 +165,13 @@ public: SkMWCRandom(uint32_t seed) { init(seed); } SkMWCRandom(const SkMWCRandom& rand) : fK(rand.fK), fJ(rand.fJ) {} - SkMWCRandom& operator=(const SkMWCRandom& rand) { + SkMWCRandom& operator=(const SkMWCRandom& rand) { fK = rand.fK; fJ = rand.fJ; return *this; } - + /** Return the next pseudo random number as an unsigned 32bit value. */ uint32_t nextU() { @@ -179,19 +179,19 @@ public: fJ = kJMul*(fJ & 0xffff) + (fJ >> 16); return (((fK << 16) | (fK >> 16)) + fJ); } - + /** Return the next pseudo random number as a signed 32bit value. */ int32_t nextS() { return (int32_t)this->nextU(); } - + /** Return the next pseudo random number as an unsigned 16bit value. */ U16CPU nextU16() { return this->nextU() >> 16; } - + /** Return the next pseudo random number as a signed 16bit value. */ S16CPU nextS16() { return this->nextS() >> 16; } - + /** * Returns value [0...1) as an IEEE float */ @@ -200,14 +200,14 @@ public: float f = *(float*)(&floatint) - 1.0f; return f; } - + /** * 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 @@ -216,7 +216,7 @@ public: SkASSERT(bitCount > 0 && bitCount <= 32); return this->nextU() >> (32 - bitCount); } - + /** Return the next pseudo random unsigned number, mapped to lie within [min, max] inclusive. */ @@ -229,7 +229,7 @@ public: return min + this->nextU() % range; } } - + /** Return the next pseudo random unsigned number, mapped to lie within [0, count). */ @@ -237,59 +237,59 @@ public: SkASSERT(count > 0); return this->nextRangeU(0, count - 1); } - + /** Return the next pseudo random number expressed as an unsigned SkFixed in the range [0..SK_Fixed1). */ SkFixed nextUFixed1() { return this->nextU() >> 16; } - + /** Return the next pseudo random number expressed as a signed SkFixed in the range (-SK_Fixed1..SK_Fixed1). */ SkFixed nextSFixed1() { return this->nextS() >> 15; } - + /** Return the next pseudo random number expressed as a SkScalar in the range [0..SK_Scalar1). */ SkScalar nextUScalar1() { return SkFixedToScalar(this->nextUFixed1()); } - + /** Return the next pseudo random number expressed as a SkScalar in the range [min..max). */ SkScalar nextRangeScalar(SkScalar min, SkScalar max) { return SkScalarMul(this->nextUScalar1(), (max - min)) + min; } - + /** Return the next pseudo random number expressed as a SkScalar in the range (-SK_Scalar1..SK_Scalar1). */ SkScalar nextSScalar1() { return SkFixedToScalar(this->nextSFixed1()); } - + /** Return the next pseudo random number as a bool. */ bool nextBool() { return this->nextU() >= 0x80000000; } - + /** A biased version of nextBool(). */ bool nextBiasedBool(SkScalar fractionTrue) { SkASSERT(fractionTrue >= 0 && fractionTrue <= SK_Scalar1); return this->nextUScalar1() <= fractionTrue; } - + /** Return the next pseudo random number as a signed 64bit value. */ void next64(Sk64* a) { SkASSERT(a); a->set(this->nextS(), this->nextU()); } - - /** Reset the random object. + + /** Reset the random object. */ void setSeed(uint32_t seed) { init(seed); } private: // Initialize state variables with LCG. - // We must ensure that both J and K are non-zero, otherwise the + // We must ensure that both J and K are non-zero, otherwise the // multiply-with-carry step will forevermore return zero. void init(uint32_t seed) { fK = NextLCG(seed); @@ -315,7 +315,7 @@ private: kKMul = 30345, kJMul = 18000, }; - + uint32_t fK; uint32_t fJ; }; |