remove PremulLinear
No one is using it at the moment, and I'd prefer no
one ever stumble into it thinking it's a good idea.
Change-Id: I5db49252413329547f1d703756fd4d38c0fd727d
Reviewed-on: https://skia-review.googlesource.com/150545
Auto-Submit: Mike Klein <mtklein@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
diff --git a/fuzz/fuzz_iccprofile_transform.c b/fuzz/fuzz_iccprofile_transform.c
index c71ba20..829bb03 100644
--- a/fuzz/fuzz_iccprofile_transform.c
+++ b/fuzz/fuzz_iccprofile_transform.c
@@ -82,9 +82,9 @@
uint8_t src[256],
dst[256];
for (skcms_AlphaFormat srcAlpha = skcms_AlphaFormat_Opaque;
- srcAlpha <= skcms_AlphaFormat_PremulLinear; ++srcAlpha) {
+ srcAlpha <= skcms_AlphaFormat_PremulAsEncoded; ++srcAlpha) {
for (skcms_AlphaFormat dstAlpha = skcms_AlphaFormat_Opaque;
- dstAlpha <= skcms_AlphaFormat_PremulLinear; ++dstAlpha) {
+ dstAlpha <= skcms_AlphaFormat_PremulAsEncoded; ++dstAlpha) {
for (int i = 0; i < 256; i++) {
src[i] = (uint8_t)i;
}
diff --git a/skcms.cc b/skcms.cc
index 1599e4e..0e93a4c 100644
--- a/skcms.cc
+++ b/skcms.cc
@@ -2125,11 +2125,7 @@
*ops++ = Op_unpremul;
}
- // TODO: We can skip this work if both srcAlpha and dstAlpha are PremulLinear, and the profiles
- // are the same. Also, if dstAlpha is PremulLinear, and SrcAlpha is Opaque.
- if (dstProfile != srcProfile ||
- srcAlpha == skcms_AlphaFormat_PremulLinear ||
- dstAlpha == skcms_AlphaFormat_PremulLinear) {
+ if (dstProfile != srcProfile) {
if (!prep_for_destination(dstProfile,
&from_xyz, &inv_dst_tf_r, &inv_dst_tf_b, &inv_dst_tf_g)) {
@@ -2201,13 +2197,6 @@
return false;
}
- // At this point our source colors are linear, either RGB (XYZ-type profiles)
- // or XYZ (A2B-type profiles). Unpremul is a linear operation (multiply by a
- // constant 1/a), so either way we can do it now if needed.
- if (srcAlpha == skcms_AlphaFormat_PremulLinear) {
- *ops++ = Op_unpremul;
- }
-
// A2B sources should already be in XYZD50 at this point.
// Others still need to be transformed using their toXYZD50 matrix.
// N.B. There are profiles that contain both A2B tags and toXYZD50 matrices.
@@ -2230,10 +2219,6 @@
*args++ = &from_xyz;
}
- if (dstAlpha == skcms_AlphaFormat_PremulLinear) {
- *ops++ = Op_premul;
- }
-
// Encode back to dst RGB using its parametric transfer functions.
if (!is_identity_tf(&inv_dst_tf_r)) { *ops++ = Op_tf_r; *args++ = &inv_dst_tf_r; }
if (!is_identity_tf(&inv_dst_tf_g)) { *ops++ = Op_tf_g; *args++ = &inv_dst_tf_g; }
diff --git a/skcms.h b/skcms.h
index abc604b..c607463 100644
--- a/skcms.h
+++ b/skcms.h
@@ -208,10 +208,8 @@
// any source alpha and treat it as 1.0, and will make sure that any destination alpha
// channel is filled with the equivalent of 1.0.
-// When premultiplying and/or using a non-linear transfer function, it's important
-// that we know the order the operations are applied. If you're used to working
-// with non-color-managed drawing systems, PremulAsEncoded is probably the "premul"
-// you're looking for; if you want linear blending, PremulLinear is the choice for you.
+// We used to offer multiple types of premultiplication, but now just one, PremulAsEncoded.
+// This is the premul you're probably used to working with.
typedef enum skcms_AlphaFormat {
skcms_AlphaFormat_Opaque, // alpha is always opaque
@@ -220,8 +218,6 @@
// tf-1(r), tf-1(g), tf-1(b), a
skcms_AlphaFormat_PremulAsEncoded, // premultiplied while encoded
// tf-1(r)*a, tf-1(g)*a, tf-1(b)*a, a
- skcms_AlphaFormat_PremulLinear, // premultiplied while linear
- // tf-1(r*a), tf-1(g*a), tf-1(b*a), a
} skcms_AlphaFormat;
// Convert npixels pixels from src format and color profile to dst format and color profile
diff --git a/tests.c b/tests.c
index 06b3aa1..a3cfee8 100644
--- a/tests.c
+++ b/tests.c
@@ -892,32 +892,6 @@
expect( dst[i+3] == src[i+3] );
}
- expect(skcms_Transform(
- src, skcms_PixelFormat_RGBA_8888, skcms_AlphaFormat_Unpremul , &sRGB,
- dst, skcms_PixelFormat_RGBA_8888, skcms_AlphaFormat_PremulLinear, &sRGB,
- 64));
- for (int i = 0; i < 256; i+=4) {
- for (int k = 0; k < 3; k++) {
- float l = skcms_TransferFunction_eval(tf, src[i+k]/255.0f);
- float e = skcms_TransferFunction_eval(&inv, l * src[i+3]/255.0f);
- expect( dst[i+k] == (uint8_t)(255.0f*e + 0.5f) );
- }
- expect( dst[i+3] == src[i+3] );
- }
-
- expect(skcms_Transform(
- src, skcms_PixelFormat_RGBA_8888, skcms_AlphaFormat_PremulLinear, &sRGB,
- dst, skcms_PixelFormat_RGBA_8888, skcms_AlphaFormat_Unpremul , &sRGB,
- 64));
- for (int i = 0; i < 256; i+=4) {
- for (int k = 0; k < 3; k++) {
- float pm = skcms_TransferFunction_eval(tf, src[i+k]/255.0f );
- float e = skcms_TransferFunction_eval(&inv, pm / (src[i+3]/255.0f));
- expect( dst[i+k] == (uint8_t)(255.0f*e + 0.5f) );
- }
- expect( dst[i+3] == src[i+3] );
- }
-
free(ptr);
}