diff options
-rw-r--r-- | bench/GrMemoryPoolBench.cpp | 6 | ||||
-rw-r--r-- | include/utils/SkRandom.h | 22 | ||||
-rw-r--r-- | src/effects/SkDiscretePathEffect.cpp | 4 |
3 files changed, 16 insertions, 16 deletions
diff --git a/bench/GrMemoryPoolBench.cpp b/bench/GrMemoryPoolBench.cpp index f1872fc136..9b60c3cc2c 100644 --- a/bench/GrMemoryPoolBench.cpp +++ b/bench/GrMemoryPoolBench.cpp @@ -50,9 +50,9 @@ protected: }; A* objects[kMaxObjects]; - // We delete if a random [-1, 1] fixed pt is < the thresh. Otherwise, + // We delete if a random number [-1, 1] is < the thresh. Otherwise, // we allocate. We start allocate-biased and ping-pong to delete-biased - SkFixed delThresh = -SK_FixedHalf; + SkScalar delThresh = -SK_ScalarHalf; const int kSwitchThreshPeriod = loops / (2 * kMaxObjects); int s = 0; @@ -62,7 +62,7 @@ protected: delThresh = -delThresh; s = 0; } - SkFixed del = r.nextSFixed1(); + SkScalar del = r.nextSScalar1(); if (count && (kMaxObjects == count || del < delThresh)) { delete objects[count-1]; diff --git a/include/utils/SkRandom.h b/include/utils/SkRandom.h index aee2d7a0aa..ecaedafc2f 100644 --- a/include/utils/SkRandom.h +++ b/include/utils/SkRandom.h @@ -97,16 +97,6 @@ public: 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). */ @@ -120,7 +110,7 @@ public: } /** Return the next pseudo random number expressed as a SkScalar - in the range (-SK_Scalar1..SK_Scalar1). + in the range [-SK_Scalar1..SK_Scalar1). */ SkScalar nextSScalar1() { return SkFixedToScalar(this->nextSFixed1()); } @@ -164,6 +154,16 @@ private: } static uint32_t NextLCG(uint32_t seed) { return kMul*seed + kAdd; } + /** 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; } + // See "Numerical Recipes in C", 1992 page 284 for these constants // For the LCG that sets the initial state from a seed enum { diff --git a/src/effects/SkDiscretePathEffect.cpp b/src/effects/SkDiscretePathEffect.cpp index 5e68dc67ef..5af6ab4ceb 100644 --- a/src/effects/SkDiscretePathEffect.cpp +++ b/src/effects/SkDiscretePathEffect.cpp @@ -47,7 +47,7 @@ public: LCGRandom(uint32_t seed) : fSeed(seed) {} /** Return the next pseudo random number expressed as a SkScalar - in the range (-SK_Scalar1..SK_Scalar1). + in the range [-SK_Scalar1..SK_Scalar1). */ SkScalar nextSScalar1() { return SkFixedToScalar(this->nextSFixed1()); } @@ -61,7 +61,7 @@ private: int32_t nextS() { return (int32_t)this->nextU(); } /** Return the next pseudo random number expressed as a signed SkFixed - in the range (-SK_Fixed1..SK_Fixed1). + in the range [-SK_Fixed1..SK_Fixed1). */ SkFixed nextSFixed1() { return this->nextS() >> 15; } |