From 938309fa09a28fc73b4a2831365120545650b989 Mon Sep 17 00:00:00 2001 From: Sally Qi Date: Fri, 10 Feb 2023 22:43:30 +0000 Subject: [PATCH] Use ColorSpace#getFromDataSpace in SurfaceControl#getCompositionColorSpaces instead of hardcoded conversion. Bug: 268701910 Test: builds Change-Id: I8de54872cf64813439ac21a2e8f924031902b425 --- core/java/android/view/SurfaceControl.java | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-) diff --git a/core/java/android/view/SurfaceControl.java b/core/java/android/view/SurfaceControl.java index 8e0941144b51e..fb78eacc36cc9 100644 --- a/core/java/android/view/SurfaceControl.java +++ b/core/java/android/view/SurfaceControl.java @@ -742,13 +742,6 @@ public final class SurfaceControl implements Parcelable { */ public static final int POWER_MODE_ON_SUSPEND = 4; - /** - * internal representation of how to interpret pixel value, used only to convert to ColorSpace. - */ - private static final int INTERNAL_DATASPACE_SRGB = 142671872; - private static final int INTERNAL_DATASPACE_DISPLAY_P3 = 143261696; - private static final int INTERNAL_DATASPACE_SCRGB = 411107328; - private void assignNativeObject(long nativeObject, String callsite) { if (mNativeObject != 0) { release(); @@ -2171,18 +2164,9 @@ public final class SurfaceControl implements Parcelable { ColorSpace[] colorSpaces = { srgb, srgb }; if (dataspaces.length == 2) { for (int i = 0; i < 2; ++i) { - switch(dataspaces[i]) { - case INTERNAL_DATASPACE_DISPLAY_P3: - colorSpaces[i] = ColorSpace.get(ColorSpace.Named.DISPLAY_P3); - break; - case INTERNAL_DATASPACE_SCRGB: - colorSpaces[i] = ColorSpace.get(ColorSpace.Named.EXTENDED_SRGB); - break; - case INTERNAL_DATASPACE_SRGB: - // Other dataspace is not recognized, use SRGB color space instead, - // the default value of the array is already SRGB, thus do nothing. - default: - break; + ColorSpace cs = ColorSpace.getFromDataSpace(dataspaces[i]); + if (cs != null) { + colorSpaces[i] = cs; } } }