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
This commit is contained in:
parent
c9c3e62b4e
commit
07342361a3
@ -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.
|
||||
|
@ -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.
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,6 @@ inline SkPMColor SkPMFloat::trunc() const {
|
||||
}
|
||||
|
||||
inline SkPMColor SkPMFloat::get() const {
|
||||
SkASSERT(this->isValid());
|
||||
return SkPMFloat(Sk4f(0.5f) + *this).trunc();
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,6 @@ inline SkPMColor SkPMFloat::trunc() const {
|
||||
}
|
||||
|
||||
inline SkPMColor SkPMFloat::get() const {
|
||||
SkASSERT(this->isValid());
|
||||
return SkPMFloat(Sk4f(0.5f) + *this).trunc();
|
||||
}
|
||||
|
||||
|
@ -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],
|
||||
|
Loading…
Reference in New Issue
Block a user