Index: src/core/SkPM4fPriv.h |
diff --git a/src/core/SkPM4fPriv.h b/src/core/SkPM4fPriv.h |
index f2d2557d3a780e57a84c1d86d4789dcf0cb861f9..89a0caeb70ce0ff0994efbe3faf77f7f4a823268 100644 |
--- a/src/core/SkPM4fPriv.h |
+++ b/src/core/SkPM4fPriv.h |
@@ -55,4 +55,20 @@ |
return swizzle_rb(Sk4f_fromS32(color)); |
} |
+static inline void assert_unit(float x) { |
+ SkASSERT(0 <= x && x <= 1); |
+} |
+ |
+static inline float exact_srgb_to_linear(float srgb) { |
+ assert_unit(srgb); |
+ float linear; |
+ if (srgb <= 0.04045) { |
+ linear = srgb / 12.92f; |
+ } else { |
+ linear = powf((srgb + 0.055f) / 1.055f, 2.4f); |
+ } |
+ assert_unit(linear); |
+ return linear; |
+} |
+ |
#endif |