Plumb HDR capabilities to Display
Bug: 25684127 Change-Id: I0a4fcdc59aa1a7b295c8df03699466685300e735
This commit is contained in:
committed by
David James
parent
54ac219184
commit
9ff94c0251
@@ -722,7 +722,10 @@ public final class Display {
|
||||
* @hide
|
||||
*/
|
||||
public HdrCapabilities getHdrCapabilities() {
|
||||
return new HdrCapabilities();
|
||||
synchronized (this) {
|
||||
updateDisplayInfoLocked();
|
||||
return mDisplayInfo.hdrCapabilities;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -178,6 +178,9 @@ public final class DisplayInfo implements Parcelable {
|
||||
/** The list of supported color transforms */
|
||||
public Display.ColorTransform[] supportedColorTransforms = Display.ColorTransform.EMPTY_ARRAY;
|
||||
|
||||
/** The display's HDR capabilities */
|
||||
public Display.HdrCapabilities hdrCapabilities;
|
||||
|
||||
/**
|
||||
* The logical display density which is the basis for density-independent
|
||||
* pixels.
|
||||
@@ -290,6 +293,7 @@ public final class DisplayInfo implements Parcelable {
|
||||
&& defaultModeId == other.defaultModeId
|
||||
&& colorTransformId == other.colorTransformId
|
||||
&& defaultColorTransformId == other.defaultColorTransformId
|
||||
&& Objects.equal(hdrCapabilities, other.hdrCapabilities)
|
||||
&& logicalDensityDpi == other.logicalDensityDpi
|
||||
&& physicalXDpi == other.physicalXDpi
|
||||
&& physicalYDpi == other.physicalYDpi
|
||||
@@ -332,6 +336,7 @@ public final class DisplayInfo implements Parcelable {
|
||||
defaultColorTransformId = other.defaultColorTransformId;
|
||||
supportedColorTransforms = Arrays.copyOf(
|
||||
other.supportedColorTransforms, other.supportedColorTransforms.length);
|
||||
hdrCapabilities = other.hdrCapabilities;
|
||||
logicalDensityDpi = other.logicalDensityDpi;
|
||||
physicalXDpi = other.physicalXDpi;
|
||||
physicalYDpi = other.physicalYDpi;
|
||||
@@ -375,6 +380,7 @@ public final class DisplayInfo implements Parcelable {
|
||||
for (int i = 0; i < nColorTransforms; i++) {
|
||||
supportedColorTransforms[i] = Display.ColorTransform.CREATOR.createFromParcel(source);
|
||||
}
|
||||
hdrCapabilities = Display.HdrCapabilities.CREATOR.createFromParcel(source);
|
||||
logicalDensityDpi = source.readInt();
|
||||
physicalXDpi = source.readFloat();
|
||||
physicalYDpi = source.readFloat();
|
||||
@@ -418,6 +424,7 @@ public final class DisplayInfo implements Parcelable {
|
||||
for (int i = 0; i < supportedColorTransforms.length; i++) {
|
||||
supportedColorTransforms[i].writeToParcel(dest, flags);
|
||||
}
|
||||
hdrCapabilities.writeToParcel(dest, flags);
|
||||
dest.writeInt(logicalDensityDpi);
|
||||
dest.writeFloat(physicalXDpi);
|
||||
dest.writeFloat(physicalYDpi);
|
||||
@@ -614,6 +621,8 @@ public final class DisplayInfo implements Parcelable {
|
||||
sb.append(defaultColorTransformId);
|
||||
sb.append(", supportedColorTransforms ");
|
||||
sb.append(Arrays.toString(supportedColorTransforms));
|
||||
sb.append(", hdrCapabilities ");
|
||||
sb.append(hdrCapabilities);
|
||||
sb.append(", rotation ");
|
||||
sb.append(rotation);
|
||||
sb.append(", density ");
|
||||
|
||||
@@ -88,6 +88,7 @@ public class SurfaceControl {
|
||||
private static native void nativeSetOverrideScalingMode(long nativeObject,
|
||||
int scalingMode);
|
||||
private static native IBinder nativeGetHandle(long nativeObject);
|
||||
private static native Display.HdrCapabilities nativeGetHdrCapabilities(IBinder displayToken);
|
||||
|
||||
|
||||
private final CloseGuard mCloseGuard = CloseGuard.get();
|
||||
@@ -656,6 +657,13 @@ public class SurfaceControl {
|
||||
nativeSetDisplaySize(displayToken, width, height);
|
||||
}
|
||||
|
||||
public static Display.HdrCapabilities getHdrCapabilities(IBinder displayToken) {
|
||||
if (displayToken == null) {
|
||||
throw new IllegalArgumentException("displayToken must not be null");
|
||||
}
|
||||
return nativeGetHdrCapabilities(displayToken);
|
||||
}
|
||||
|
||||
public static IBinder createDisplay(String name, boolean secure) {
|
||||
if (name == null) {
|
||||
throw new IllegalArgumentException("name must not be null");
|
||||
|
||||
@@ -627,7 +627,7 @@ static jobject nativeGetHdrCapabilities(JNIEnv* env, jclass clazz, jobject token
|
||||
auto typesArray = env->NewIntArray(types.size());
|
||||
env->SetIntArrayRegion(typesArray, 0, types.size(), types.data());
|
||||
|
||||
return env->NewObject(gHdrCapabilitiesClassInfo.clazz, gPhysicalDisplayInfoClassInfo.ctor,
|
||||
return env->NewObject(gHdrCapabilitiesClassInfo.clazz, gHdrCapabilitiesClassInfo.ctor,
|
||||
typesArray, capabilities.getDesiredMaxLuminance(),
|
||||
capabilities.getDesiredMaxAverageLuminance(), capabilities.getDesiredMinLuminance());
|
||||
}
|
||||
@@ -693,6 +693,8 @@ static const JNINativeMethod sSurfaceControlMethods[] = {
|
||||
(void*)nativeGetActiveConfig },
|
||||
{"nativeSetActiveConfig", "(Landroid/os/IBinder;I)Z",
|
||||
(void*)nativeSetActiveConfig },
|
||||
{"nativeGetHdrCapabilities", "(Landroid/os/IBinder;)Landroid/view/Display$HdrCapabilities;",
|
||||
(void*)nativeGetHdrCapabilities },
|
||||
{"nativeClearContentFrameStats", "(J)Z",
|
||||
(void*)nativeClearContentFrameStats },
|
||||
{"nativeGetContentFrameStats", "(JLandroid/view/WindowContentFrameStats;)Z",
|
||||
|
||||
@@ -164,6 +164,11 @@ final class DisplayDeviceInfo {
|
||||
/** The supported color transforms of the display */
|
||||
public Display.ColorTransform[] supportedColorTransforms = Display.ColorTransform.EMPTY_ARRAY;
|
||||
|
||||
/**
|
||||
* The HDR capabilities this display claims to support.
|
||||
*/
|
||||
public Display.HdrCapabilities hdrCapabilities;
|
||||
|
||||
/**
|
||||
* The nominal apparent density of the display in DPI used for layout calculations.
|
||||
* This density is sensitive to the viewing distance. A big TV and a tablet may have
|
||||
@@ -288,6 +293,7 @@ final class DisplayDeviceInfo {
|
||||
|| colorTransformId != other.colorTransformId
|
||||
|| defaultColorTransformId != other.defaultColorTransformId
|
||||
|| !Arrays.equals(supportedColorTransforms, other.supportedColorTransforms)
|
||||
|| !Objects.equal(hdrCapabilities, other.hdrCapabilities)
|
||||
|| densityDpi != other.densityDpi
|
||||
|| xDpi != other.xDpi
|
||||
|| yDpi != other.yDpi
|
||||
@@ -321,6 +327,7 @@ final class DisplayDeviceInfo {
|
||||
colorTransformId = other.colorTransformId;
|
||||
defaultColorTransformId = other.defaultColorTransformId;
|
||||
supportedColorTransforms = other.supportedColorTransforms;
|
||||
hdrCapabilities = other.hdrCapabilities;
|
||||
densityDpi = other.densityDpi;
|
||||
xDpi = other.xDpi;
|
||||
yDpi = other.yDpi;
|
||||
@@ -349,6 +356,7 @@ final class DisplayDeviceInfo {
|
||||
sb.append(", colorTransformId ").append(colorTransformId);
|
||||
sb.append(", defaultColorTransformId ").append(defaultColorTransformId);
|
||||
sb.append(", supportedColorTransforms ").append(Arrays.toString(supportedColorTransforms));
|
||||
sb.append(", HdrCapabilities ").append(hdrCapabilities);
|
||||
sb.append(", density ").append(densityDpi);
|
||||
sb.append(", ").append(xDpi).append(" x ").append(yDpi).append(" dpi");
|
||||
sb.append(", appVsyncOff ").append(appVsyncOffsetNanos);
|
||||
|
||||
@@ -158,6 +158,7 @@ final class LocalDisplayAdapter extends DisplayAdapter {
|
||||
private int mDefaultColorTransformId;
|
||||
private int mActiveColorTransformId;
|
||||
private boolean mActiveColorTransformInvalid;
|
||||
private Display.HdrCapabilities mHdrCapabilities;
|
||||
|
||||
private SurfaceControl.PhysicalDisplayInfo mDisplayInfos[];
|
||||
|
||||
@@ -172,6 +173,7 @@ final class LocalDisplayAdapter extends DisplayAdapter {
|
||||
} else {
|
||||
mBacklight = null;
|
||||
}
|
||||
mHdrCapabilities = SurfaceControl.getHdrCapabilities(displayToken);
|
||||
}
|
||||
|
||||
public boolean updatePhysicalDisplayInfoLocked(
|
||||
@@ -368,6 +370,7 @@ final class LocalDisplayAdapter extends DisplayAdapter {
|
||||
for (int i = 0; i < mSupportedColorTransforms.size(); i++) {
|
||||
mInfo.supportedColorTransforms[i] = mSupportedColorTransforms.valueAt(i);
|
||||
}
|
||||
mInfo.hdrCapabilities = mHdrCapabilities;
|
||||
mInfo.appVsyncOffsetNanos = phys.appVsyncOffsetNanos;
|
||||
mInfo.presentationDeadlineNanos = phys.presentationDeadlineNanos;
|
||||
mInfo.state = mState;
|
||||
|
||||
@@ -241,6 +241,7 @@ final class LogicalDisplay {
|
||||
mBaseDisplayInfo.supportedColorTransforms = Arrays.copyOf(
|
||||
deviceInfo.supportedColorTransforms,
|
||||
deviceInfo.supportedColorTransforms.length);
|
||||
mBaseDisplayInfo.hdrCapabilities = deviceInfo.hdrCapabilities;
|
||||
mBaseDisplayInfo.logicalDensityDpi = deviceInfo.densityDpi;
|
||||
mBaseDisplayInfo.physicalXDpi = deviceInfo.xDpi;
|
||||
mBaseDisplayInfo.physicalYDpi = deviceInfo.yDpi;
|
||||
|
||||
Reference in New Issue
Block a user