diff options
| author | 2019-03-17 17:30:41 -0700 | |
|---|---|---|
| committer | 2019-03-19 14:57:30 -0700 | |
| commit | 244daaeddc80aaca2e2f323e81df8bed0632f782 (patch) | |
| tree | 7768dff64be818ca368d1577ed77232ffbab1dac | |
| parent | 40e9a201db163bf4593511a23a2ec4570c511c0b (diff) | |
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
| -rw-r--r-- | graphics/java/android/graphics/ColorSpace.java | 39 | ||||
| -rw-r--r-- | services/core/java/com/android/server/display/color/ColorDisplayService.java | 2 |
2 files changed, 40 insertions, 1 deletions
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 @@ -1809,6 +1809,45 @@ public abstract class ColorSpace { } /** + * <p>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].</p> + * + * <p>The transform is computed using the methods in Kang et + * al., <i>Design of Advanced Color - Temperature Control System for HDTV + * Applications</i>, Journal of Korean Physical Society 41, 865-871 + * (2002).</p> + * + * @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}); + } + + /** * <p>Computes the chromaticity coordinates of a CIE series D illuminant * from the specified correlated color temperature (CCT). The specified CCT * must be greater than 0. A meaningful CCT range is [4000, 25000].</p> diff --git a/services/core/java/com/android/server/display/color/ColorDisplayService.java b/services/core/java/com/android/server/display/color/ColorDisplayService.java index 45567e5a34cb..ed420b73e79b 100644 --- a/services/core/java/com/android/server/display/color/ColorDisplayService.java +++ b/services/core/java/com/android/server/display/color/ColorDisplayService.java @@ -1417,7 +1417,7 @@ public final class ColorDisplayService extends SystemService { mCurrentColorTemperature = cct; // Adapt the display's nominal white point to match the requested CCT value - mCurrentColorTemperatureXYZ = ColorSpace.cctToIlluminantdXyz(cct); + mCurrentColorTemperatureXYZ = ColorSpace.cctToXyz(cct); mChromaticAdaptationMatrix = ColorSpace.chromaticAdaptation(ColorSpace.Adaptation.BRADFORD, |