summaryrefslogtreecommitdiff
path: root/core/java
diff options
context:
space:
mode:
authorPeiyong Lin <lpy@google.com>2019-01-17 11:37:07 -0800
committerPeiyong Lin <lpy@google.com>2019-01-17 14:51:20 -0800
commit5f4a568d804f94ddf95a160105c2523eddedf9bd (patch)
tree8f2e26406bbc4bd51b1917a0b950dba740e8c799 /core/java
parentbecdfa7a9ee246b61f5a3d7240ea0d7ded24a62e (diff)
[SurfaceControl] Add API to query composition color spaces.
To facilitate the need of returning color spaces about the composition pipeline, add an API to query this information. This API will be used by Canvas and Display, etc. BUG: 120904891 Test: Build, flash and boot. Verify by checking returned values. Change-Id: I97123ba1488ca76888a4c004128b4100a7c1f76c
Diffstat (limited to 'core/java')
-rw-r--r--core/java/android/view/SurfaceControl.java38
1 files changed, 38 insertions, 0 deletions
diff --git a/core/java/android/view/SurfaceControl.java b/core/java/android/view/SurfaceControl.java
index ff5120d09e25..4b4da938a73a 100644
--- a/core/java/android/view/SurfaceControl.java
+++ b/core/java/android/view/SurfaceControl.java
@@ -30,6 +30,7 @@ import static android.view.SurfaceControlProto.NAME;
import android.annotation.Size;
import android.annotation.UnsupportedAppUsage;
import android.graphics.Bitmap;
+import android.graphics.ColorSpace;
import android.graphics.GraphicBuffer;
import android.graphics.Matrix;
import android.graphics.PixelFormat;
@@ -141,6 +142,7 @@ public class SurfaceControl implements Parcelable {
private static native int nativeGetActiveConfig(IBinder displayToken);
private static native boolean nativeSetActiveConfig(IBinder displayToken, int id);
private static native int[] nativeGetDisplayColorModes(IBinder displayToken);
+ private static native int[] nativeGetCompositionDataspaces();
private static native int nativeGetActiveColorMode(IBinder displayToken);
private static native boolean nativeSetActiveColorMode(IBinder displayToken,
int colorMode);
@@ -374,6 +376,13 @@ public class SurfaceControl implements Parcelable {
*/
public static final int WINDOW_TYPE_DONT_SCREENSHOT = 441731;
+ /**
+ * 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) {
if (mNativeObject != 0) {
release();
@@ -1516,6 +1525,35 @@ public class SurfaceControl implements Parcelable {
}
/**
+ * Returns an array of color spaces with 2 elements. The first color space is the
+ * default color space and second one is wide color gamut color space.
+ * @hide
+ */
+ public static ColorSpace[] getCompositionColorSpaces() {
+ int[] dataspaces = nativeGetCompositionDataspaces();
+ ColorSpace srgb = ColorSpace.get(ColorSpace.Named.SRGB);
+ 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;
+ }
+ }
+ }
+ return colorSpaces;
+ }
+
+ /**
* @hide
*/
@UnsupportedAppUsage