diff options
author | 2015-03-03 08:57:07 -0800 | |
---|---|---|
committer | 2015-03-03 08:57:07 -0800 | |
commit | 0aebf5d0d3a2aef38a71885c85303583fdeaad57 (patch) | |
tree | 1ec6aeef90ecc654f5040e7244f5c7246ce74690 /src/opts/SkPMFloat_none.h | |
parent | c2574f3657b1359496a4eba5b191961974b3a64f (diff) |
Test and fix SkPMFloat rounding.
SSE rounds for free (that was a happy accident: they also have a truncating version).
NEON does not, nor obviously the portable code, so they add 0.5 before truncating.
NOPRESUBMIT=true
BUG=skia:
Review URL: https://codereview.chromium.org/974643002
Diffstat (limited to 'src/opts/SkPMFloat_none.h')
-rw-r--r-- | src/opts/SkPMFloat_none.h | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/opts/SkPMFloat_none.h b/src/opts/SkPMFloat_none.h index 448b509d40..b67c8d7420 100644 --- a/src/opts/SkPMFloat_none.h +++ b/src/opts/SkPMFloat_none.h @@ -10,7 +10,7 @@ inline void SkPMFloat::set(SkPMColor c) { inline SkPMColor SkPMFloat::get() const { SkASSERT(this->isValid()); - return SkPackARGB32(this->a(), this->r(), this->g(), this->b()); + return SkPackARGB32(this->a()+0.5f, this->r()+0.5f, this->g()+0.5f, this->b()+0.5f); } inline SkPMColor SkPMFloat::clamped() const { @@ -22,5 +22,5 @@ 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, r, g, b); + return SkPackARGB32(a+0.5f, r+0.5f, g+0.5f, b+0.5f); } |