Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(97)

Unified Diff: src/core/SkNx.h

Issue 1312053004: Require Sk4f::toBytes() clamps (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: tweak Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/opts/SkNx_sse.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkNx.h
diff --git a/src/core/SkNx.h b/src/core/SkNx.h
index 895b972dd1b3f88bef79c4494ac9068376ce8498..ff94e0545870fa51bf9559b587fb615a3ca1e5bd 100644
--- a/src/core/SkNx.h
+++ b/src/core/SkNx.h
@@ -108,7 +108,7 @@ public:
fHi.store(vals+N/2);
}
// Please see note on FromBytes().
- // Truncates [0.0,256.0) floats to [0,255] bytes. Other inputs are unspecified.
+ // Clamps to [0.0,255.0] floats and truncates to [0,255] bytes.
void toBytes(uint8_t bytes[N]) const {
fLo.toBytes(bytes);
fHi.toBytes(bytes+N/2);
@@ -216,7 +216,7 @@ public:
static SkNf FromBytes(const uint8_t bytes[1]) { return SkNf((T)bytes[0]); }
void store(T vals[1]) const { vals[0] = fVal; }
- void toBytes(uint8_t bytes[1]) const { bytes[0] = (uint8_t)(fVal); }
+ void toBytes(uint8_t bytes[1]) const { bytes[0] = (uint8_t)(SkTMin(fVal, (T)255.0)); }
SkNi<1,I> castTrunc() const { return SkNi<1,I>(fVal); }
« no previous file with comments | « no previous file | src/opts/SkNx_sse.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698