diff options
author | 2015-04-02 11:21:11 -0700 | |
---|---|---|
committer | 2015-04-02 11:21:11 -0700 | |
commit | 07342361a3cda94376230b37d9e863052449653c (patch) | |
tree | 5b7d4f7f7baad36380884f6ecfcb5d8a363a3406 /src | |
parent | c9c3e62b4ef6ec288549a0ad1d252986d7f0889d (diff) |
SkPMFloat: fewer internal this->isValid() assertions.
Each of these conversion functions now only asserts is output is valid.
For SkPMColor -> SkPMFloat, we assert isValid().
For SkPMFloat -> SkPMColor, we SkPMColorAssert.
#floats
BUG=skia:
BUG=skia:3592
Review URL: https://codereview.chromium.org/1055093002
Diffstat (limited to 'src')
-rw-r--r-- | src/core/SkPMFloat.h | 6 | ||||
-rw-r--r-- | src/opts/SkPMFloat_SSE2.h | 1 | ||||
-rw-r--r-- | src/opts/SkPMFloat_SSSE3.h | 1 | ||||
-rw-r--r-- | src/opts/SkPMFloat_neon.h | 1 | ||||
-rw-r--r-- | src/opts/SkPMFloat_none.h | 9 |
5 files changed, 10 insertions, 8 deletions
diff --git a/src/core/SkPMFloat.h b/src/core/SkPMFloat.h index 3147879458..84c05ea762 100644 --- a/src/core/SkPMFloat.h +++ b/src/core/SkPMFloat.h @@ -43,9 +43,11 @@ public: float g() const { return fColors[SK_G32_SHIFT / 8]; } float b() const { return fColors[SK_B32_SHIFT / 8]; } + // N.B. All methods returning an SkPMColor call SkPMColorAssert on that result before returning. + // get() and clamped() round component values to the nearest integer. - SkPMColor get() const; // May SkASSERT(this->isValid()). Some implementations may clamp. - SkPMColor clamped() const; // Will clamp all values to [0, 255]. Then may assert isValid(). + SkPMColor get() const; // Assumes all values in [0, 255]. Some implementations may clamp. + SkPMColor clamped() const; // Will clamp all values to [0, 255]. // Like get(), but truncates instead of rounding. // The domain of this function is (-1.0f, 256.0f). Values in (-1.0f, 0.0f] trunc to a zero. diff --git a/src/opts/SkPMFloat_SSE2.h b/src/opts/SkPMFloat_SSE2.h index 231940d86e..2803293664 100644 --- a/src/opts/SkPMFloat_SSE2.h +++ b/src/opts/SkPMFloat_SSE2.h @@ -22,7 +22,6 @@ inline SkPMFloat::SkPMFloat(SkPMColor c) { } inline SkPMColor SkPMFloat::get() const { - SkASSERT(this->isValid()); return this->clamped(); // Haven't beaten this yet. } diff --git a/src/opts/SkPMFloat_SSSE3.h b/src/opts/SkPMFloat_SSSE3.h index ccc4d4feb8..2765048ad3 100644 --- a/src/opts/SkPMFloat_SSSE3.h +++ b/src/opts/SkPMFloat_SSSE3.h @@ -32,7 +32,6 @@ inline SkPMColor SkPMFloat::trunc() const { } inline SkPMColor SkPMFloat::get() const { - SkASSERT(this->isValid()); return SkPMFloat(Sk4f(0.5f) + *this).trunc(); } diff --git a/src/opts/SkPMFloat_neon.h b/src/opts/SkPMFloat_neon.h index 1373c3ae3a..4d46c975ec 100644 --- a/src/opts/SkPMFloat_neon.h +++ b/src/opts/SkPMFloat_neon.h @@ -31,7 +31,6 @@ inline SkPMColor SkPMFloat::trunc() const { } inline SkPMColor SkPMFloat::get() const { - SkASSERT(this->isValid()); return SkPMFloat(Sk4f(0.5f) + *this).trunc(); } diff --git a/src/opts/SkPMFloat_none.h b/src/opts/SkPMFloat_none.h index 19557f11de..7f03f2f53a 100644 --- a/src/opts/SkPMFloat_none.h +++ b/src/opts/SkPMFloat_none.h @@ -18,8 +18,9 @@ inline SkPMColor SkPMFloat::trunc() const { } inline SkPMColor SkPMFloat::get() const { - SkASSERT(this->isValid()); - return SkPackARGB32(this->a()+0.5f, this->r()+0.5f, this->g()+0.5f, this->b()+0.5f); + SkPMColor c = SkPackARGB32(this->a()+0.5f, this->r()+0.5f, this->g()+0.5f, this->b()+0.5f); + SkPMColorAssert(c); + return c; } inline SkPMColor SkPMFloat::clamped() const { @@ -31,7 +32,9 @@ inline SkPMColor SkPMFloat::clamped() const { r = r < 0 ? 0 : (r > 255 ? 255 : r); g = g < 0 ? 0 : (g > 255 ? 255 : g); b = b < 0 ? 0 : (b > 255 ? 255 : b); - return SkPackARGB32(a+0.5f, r+0.5f, g+0.5f, b+0.5f); + SkPMColor c = SkPackARGB32(a+0.5f, r+0.5f, g+0.5f, b+0.5f); + SkPMColorAssert(c); + return c; } inline void SkPMFloat::From4PMColors(const SkPMColor colors[4], |