aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--third_party/skcms/skcms.cc12
-rwxr-xr-xthird_party/skcms/version.sha12
2 files changed, 10 insertions, 4 deletions
diff --git a/third_party/skcms/skcms.cc b/third_party/skcms/skcms.cc
index e81f94919a..0a820629ad 100644
--- a/third_party/skcms/skcms.cc
+++ b/third_party/skcms/skcms.cc
@@ -2285,6 +2285,15 @@ bool skcms_Transform(const void* src,
if (!is_identity_tf(&inv_dst_tf_b)) { *ops++ = Op_tf_b; *args++ = &inv_dst_tf_b; }
}
+ // Clamp here before premul to make sure we're clamping to fixed-point values _and_ gamut,
+ // not just to values that fit in the fixed point representation.
+ //
+ // E.g. r = 1.1, a = 0.5 would fit fine in fixed point after premul (ra=0.55,a=0.5),
+ // but would be carrying r > 1, which is really unexpected for downstream consumers.
+ // TODO(mtklein): add a unit test
+ if (dstFmt < skcms_PixelFormat_RGB_hhh) {
+ *ops++ = Op_clamp;
+ }
if (dstAlpha == skcms_AlphaFormat_Opaque) {
*ops++ = Op_force_opaque;
} else if (dstAlpha == skcms_AlphaFormat_PremulAsEncoded) {
@@ -2293,9 +2302,6 @@ bool skcms_Transform(const void* src,
if (dstFmt & 1) {
*ops++ = Op_swap_rb;
}
- if (dstFmt < skcms_PixelFormat_RGB_hhh) {
- *ops++ = Op_clamp;
- }
switch (dstFmt >> 1) {
default: return false;
case skcms_PixelFormat_A_8 >> 1: *ops++ = Op_store_a8; break;
diff --git a/third_party/skcms/version.sha1 b/third_party/skcms/version.sha1
index 7aabdabaf9..746a312baf 100755
--- a/third_party/skcms/version.sha1
+++ b/third_party/skcms/version.sha1
@@ -1 +1 @@
-4642d9fe69e1ace1bb565a39f38fea9f776d8adb \ No newline at end of file
+23e7777f421d11992e8245771641141aa273556b \ No newline at end of file