diff options
author | 2017-01-17 10:19:50 -0500 | |
---|---|---|
committer | 2017-01-17 16:05:11 +0000 | |
commit | d32b8177da4efad14a609c7c34784dffb47575ee (patch) | |
tree | 8edd4c3bdd32b363c8a03b7e856048cf3224665f /src | |
parent | eaf0079d81beac9fea2da7a20c3587ebbbbe6463 (diff) |
add and test SkFixed15::to_u8()
Change-Id: Iedbcd2d938122cdc8f6b235745eb6165e348c237
Reviewed-on: https://skia-review.googlesource.com/7108
Commit-Queue: Mike Klein <mtklein@chromium.org>
Reviewed-by: Herb Derby <herb@google.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/core/SkFixed15.h | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/core/SkFixed15.h b/src/core/SkFixed15.h index 43a9fae773..509febc7c1 100644 --- a/src/core/SkFixed15.h +++ b/src/core/SkFixed15.h @@ -32,6 +32,12 @@ public: + ((val+1)>>8); // All val but 255 are correct. +1 if val == 255 to get 32768. } + uint8_t to_u8() const { + // FromU8() and to_u8() roundtrip all bytes. + // There is still much room to tweak this towards the ideal, a rounding scale by 255/32768. + return (fVal - (fVal>>8))>>7; + } + SkFixed15 operator +(SkFixed15 o) const { return fVal + o.fVal; } SkFixed15 operator -(SkFixed15 o) const { return fVal - o.fVal; } SkFixed15 operator *(SkFixed15 o) const { return (fVal * o.fVal + (1<<14)) >> 15; } |