summaryrefslogtreecommitdiff
path: root/core/java/android/view/Display.java
diff options
context:
space:
mode:
authorMichael Wright <michaelwr@google.com>2016-07-12 13:30:10 -0700
committerMichael Wright <michaelwr@google.com>2016-07-18 19:49:18 +0100
commit1c9977b762b4bac46b4470f04c898bfd17da5d90 (patch)
tree873eaf21a809a670356737f459f9b4dc37aef1f6 /core/java/android/view/Display.java
parent142c4f7a9f16f3cfdf5c8cc5e185b8738f94c80f (diff)
Rename color transform to color mode and persist the value.
Also, standardize on a set of possible modes for the displays to enter and separate the configuration of the color mode from the configuration of the display mode. Bug: 29044347 Change-Id: I6af0a7d1f11bc72d4cefc380f115c1fb00788864
Diffstat (limited to 'core/java/android/view/Display.java')
-rw-r--r--core/java/android/view/Display.java141
1 files changed, 33 insertions, 108 deletions
diff --git a/core/java/android/view/Display.java b/core/java/android/view/Display.java
index 8c49009ebf44..899ae49f31a8 100644
--- a/core/java/android/view/Display.java
+++ b/core/java/android/view/Display.java
@@ -36,7 +36,7 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.Arrays;
-import static android.Manifest.permission.CONFIGURE_DISPLAY_COLOR_TRANSFORM;
+import static android.Manifest.permission.CONFIGURE_DISPLAY_COLOR_MODE;
/**
* Provides information about the size and density of a logical display.
@@ -284,6 +284,27 @@ public final class Display {
*/
public static final int STATE_DOZE_SUSPEND = 4;
+ /* The color mode constants defined below must be kept in sync with the ones in
+ * system/graphics.h */
+
+ /**
+ * Display color mode: The current color mode is unknown or invalid.
+ * @hide
+ */
+ public static final int COLOR_MODE_INVALID = -1;
+
+ /**
+ * Display color mode: The default or native gamut of the display.
+ * @hide
+ */
+ public static final int COLOR_MODE_DEFAULT = 0;
+
+ /**
+ * Display color mode: SRGB
+ * @hide
+ */
+ public static final int COLOR_MODE_SRGB = 7;
+
/**
* Internal method to create a display.
* Applications should use {@link android.view.WindowManager#getDefaultDisplay()}
@@ -696,33 +717,22 @@ public final class Display {
}
/**
- * Request the display applies a color transform.
+ * Request the display applies a color mode.
* @hide
*/
- @RequiresPermission(CONFIGURE_DISPLAY_COLOR_TRANSFORM)
- public void requestColorTransform(ColorTransform colorTransform) {
- mGlobal.requestColorTransform(mDisplayId, colorTransform.getId());
- }
-
- /**
- * Returns the active color transform of this display
- * @hide
- */
- public ColorTransform getColorTransform() {
- synchronized (this) {
- updateDisplayInfoLocked();
- return mDisplayInfo.getColorTransform();
- }
+ @RequiresPermission(CONFIGURE_DISPLAY_COLOR_MODE)
+ public void requestColorMode(int colorMode) {
+ mGlobal.requestColorMode(mDisplayId, colorMode);
}
/**
- * Returns the default color transform of this display
+ * Returns the active color mode of this display
* @hide
*/
- public ColorTransform getDefaultColorTransform() {
+ public int getColorMode() {
synchronized (this) {
updateDisplayInfoLocked();
- return mDisplayInfo.getDefaultColorTransform();
+ return mDisplayInfo.colorMode;
}
}
@@ -737,14 +747,14 @@ public final class Display {
}
/**
- * Gets the supported color transforms of this device.
+ * Gets the supported color modes of this device.
* @hide
*/
- public ColorTransform[] getSupportedColorTransforms() {
+ public int[] getSupportedColorModes() {
synchronized (this) {
updateDisplayInfoLocked();
- ColorTransform[] transforms = mDisplayInfo.supportedColorTransforms;
- return Arrays.copyOf(transforms, transforms.length);
+ int[] colorModes = mDisplayInfo.supportedColorModes;
+ return Arrays.copyOf(colorModes, colorModes.length);
}
}
@@ -1263,89 +1273,4 @@ public final class Display {
return 0;
}
}
-
- /**
- * A color transform supported by a given display.
- *
- * @see Display#getSupportedColorTransforms()
- * @hide
- */
- public static final class ColorTransform implements Parcelable {
- public static final ColorTransform[] EMPTY_ARRAY = new ColorTransform[0];
-
- private final int mId;
- private final int mColorTransform;
-
- public ColorTransform(int id, int colorTransform) {
- mId = id;
- mColorTransform = colorTransform;
- }
-
- public int getId() {
- return mId;
- }
-
- public int getColorTransform() {
- return mColorTransform;
- }
-
- @Override
- public boolean equals(Object other) {
- if (this == other) {
- return true;
- }
- if (!(other instanceof ColorTransform)) {
- return false;
- }
- ColorTransform that = (ColorTransform) other;
- return mId == that.mId
- && mColorTransform == that.mColorTransform;
- }
-
- @Override
- public int hashCode() {
- int hash = 1;
- hash = hash * 17 + mId;
- hash = hash * 17 + mColorTransform;
- return hash;
- }
-
- @Override
- public String toString() {
- return new StringBuilder("{")
- .append("id=").append(mId)
- .append(", colorTransform=").append(mColorTransform)
- .append("}")
- .toString();
- }
-
- @Override
- public int describeContents() {
- return 0;
- }
-
- private ColorTransform(Parcel in) {
- this(in.readInt(), in.readInt());
- }
-
- @Override
- public void writeToParcel(Parcel out, int parcelableFlags) {
- out.writeInt(mId);
- out.writeInt(mColorTransform);
- }
-
- @SuppressWarnings("hiding")
- public static final Parcelable.Creator<ColorTransform> CREATOR
- = new Parcelable.Creator<ColorTransform>() {
- @Override
- public ColorTransform createFromParcel(Parcel in) {
- return new ColorTransform(in);
- }
-
- @Override
- public ColorTransform[] newArray(int size) {
- return new ColorTransform[size];
- }
- };
- }
}