From 244daaeddc80aaca2e2f323e81df8bed0632f782 Mon Sep 17 00:00:00 2001 From: Daniel Solomon Date: Sun, 17 Mar 2019 17:30:41 -0700 Subject: Change Display White Balance to track the Planckian locus Currently when DWB adjusts the display's white point it uses standard Illuminant D to convert CCT to CIE xy coordinates. This causes a slight green tint, detectable by some users. Change this behavior to calculate CIE xy based on the Planckian locus. Bug: 128712066 Test: a. Manual, by overriding target DWB CCT and observing resulting target xy coordinates b. atest FrameworksServicesTests:ColorDisplayServiceTest, making sure there are no new failures (existing failures tracked in a separate bug) Change-Id: I6fa336ee694730df45d5eacceb442aa556b5718e --- graphics/java/android/graphics/ColorSpace.java | 39 ++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'graphics/java/android') diff --git a/graphics/java/android/graphics/ColorSpace.java b/graphics/java/android/graphics/ColorSpace.java index 0d5233880674..9c4b5e8b0165 100644 --- a/graphics/java/android/graphics/ColorSpace.java +++ b/graphics/java/android/graphics/ColorSpace.java @@ -1808,6 +1808,45 @@ public abstract class ColorSpace { return mul3x3(inverse3x3(matrix), mul3x3Diag(LMS, matrix)); } + /** + *

Computes the chromaticity coordinates of a specified correlated color + * temperature (CCT) on the Planckian locus. The specified CCT must be + * greater than 0. A meaningful CCT range is [1667, 25000].

+ * + *

The transform is computed using the methods in Kang et + * al., Design of Advanced Color - Temperature Control System for HDTV + * Applications, Journal of Korean Physical Society 41, 865-871 + * (2002).

+ * + * @param cct The correlated color temperature, in Kelvin + * @return Corresponding XYZ values + * @throws IllegalArgumentException If cct is invalid + * + * @hide + */ + @NonNull + @Size(3) + public static float[] cctToXyz(@IntRange(from = 1) int cct) { + if (cct < 1) { + throw new IllegalArgumentException("Temperature must be greater than 0"); + } + + final float icct = 1e3f / cct; + final float icct2 = icct * icct; + final float x = cct <= 4000.0f ? + 0.179910f + 0.8776956f * icct - 0.2343589f * icct2 - 0.2661239f * icct2 * icct : + 0.240390f + 0.2226347f * icct + 2.1070379f * icct2 - 3.0258469f * icct2 * icct; + + final float x2 = x * x; + final float y = cct <= 2222.0f ? + -0.20219683f + 2.18555832f * x - 1.34811020f * x2 - 1.1063814f * x2 * x : + cct <= 4000.0f ? + -0.16748867f + 2.09137015f * x - 1.37418593f * x2 - 0.9549476f * x2 * x : + -0.37001483f + 3.75112997f * x - 5.8733867f * x2 + 3.0817580f * x2 * x; + + return xyYToXyz(new float[] {x, y}); + } + /** *

Computes the chromaticity coordinates of a CIE series D illuminant * from the specified correlated color temperature (CCT). The specified CCT -- cgit v1.2.3-59-g8ed1b