Merge changes from topic 'atv-hdr' into nyc-dev
* changes: Unhide getHdrCapabilities and HdrCapabilities. Plumb HDR capabilities to Display Revert "Revert "Hook up HDR capabilities from native SurfaceControl""
This commit is contained in:
@@ -40933,6 +40933,7 @@ package android.view {
|
||||
method public void getCurrentSizeRange(android.graphics.Point, android.graphics.Point);
|
||||
method public int getDisplayId();
|
||||
method public int getFlags();
|
||||
method public android.view.Display.HdrCapabilities getHdrCapabilities();
|
||||
method public deprecated int getHeight();
|
||||
method public void getMetrics(android.util.DisplayMetrics);
|
||||
method public android.view.Display.Mode getMode();
|
||||
@@ -40965,6 +40966,21 @@ package android.view {
|
||||
field public static final int STATE_UNKNOWN = 0; // 0x0
|
||||
}
|
||||
|
||||
public static final class Display.HdrCapabilities implements android.os.Parcelable {
|
||||
ctor public Display.HdrCapabilities(int[], float, float, float);
|
||||
method public int describeContents();
|
||||
method public float getDesiredMaxAverageLuminance();
|
||||
method public float getDesiredMaxLuminance();
|
||||
method public float getDesiredMinLuminance();
|
||||
method public int[] getSupportedHdrTypes();
|
||||
method public void writeToParcel(android.os.Parcel, int);
|
||||
field public static final android.os.Parcelable.Creator<android.view.Display.HdrCapabilities> CREATOR;
|
||||
field public static final int HDR_TYPE_DOLBY_VISION = 1; // 0x1
|
||||
field public static final int HDR_TYPE_HDR10 = 2; // 0x2
|
||||
field public static final int HDR_TYPE_HLG = 3; // 0x3
|
||||
field public static final float INVALID_LUMINANCE = -1.0f;
|
||||
}
|
||||
|
||||
public static final class Display.Mode implements android.os.Parcelable {
|
||||
method public int describeContents();
|
||||
method public int getModeId();
|
||||
|
||||
@@ -43923,6 +43923,7 @@ package android.view {
|
||||
method public void getCurrentSizeRange(android.graphics.Point, android.graphics.Point);
|
||||
method public int getDisplayId();
|
||||
method public int getFlags();
|
||||
method public android.view.Display.HdrCapabilities getHdrCapabilities();
|
||||
method public deprecated int getHeight();
|
||||
method public void getMetrics(android.util.DisplayMetrics);
|
||||
method public android.view.Display.Mode getMode();
|
||||
@@ -43955,6 +43956,21 @@ package android.view {
|
||||
field public static final int STATE_UNKNOWN = 0; // 0x0
|
||||
}
|
||||
|
||||
public static final class Display.HdrCapabilities implements android.os.Parcelable {
|
||||
ctor public Display.HdrCapabilities(int[], float, float, float);
|
||||
method public int describeContents();
|
||||
method public float getDesiredMaxAverageLuminance();
|
||||
method public float getDesiredMaxLuminance();
|
||||
method public float getDesiredMinLuminance();
|
||||
method public int[] getSupportedHdrTypes();
|
||||
method public void writeToParcel(android.os.Parcel, int);
|
||||
field public static final android.os.Parcelable.Creator<android.view.Display.HdrCapabilities> CREATOR;
|
||||
field public static final int HDR_TYPE_DOLBY_VISION = 1; // 0x1
|
||||
field public static final int HDR_TYPE_HDR10 = 2; // 0x2
|
||||
field public static final int HDR_TYPE_HLG = 3; // 0x3
|
||||
field public static final float INVALID_LUMINANCE = -1.0f;
|
||||
}
|
||||
|
||||
public static final class Display.Mode implements android.os.Parcelable {
|
||||
method public int describeContents();
|
||||
method public int getModeId();
|
||||
|
||||
@@ -41011,6 +41011,7 @@ package android.view {
|
||||
method public void getCurrentSizeRange(android.graphics.Point, android.graphics.Point);
|
||||
method public int getDisplayId();
|
||||
method public int getFlags();
|
||||
method public android.view.Display.HdrCapabilities getHdrCapabilities();
|
||||
method public deprecated int getHeight();
|
||||
method public void getMetrics(android.util.DisplayMetrics);
|
||||
method public android.view.Display.Mode getMode();
|
||||
@@ -41043,6 +41044,21 @@ package android.view {
|
||||
field public static final int STATE_UNKNOWN = 0; // 0x0
|
||||
}
|
||||
|
||||
public static final class Display.HdrCapabilities implements android.os.Parcelable {
|
||||
ctor public Display.HdrCapabilities(int[], float, float, float);
|
||||
method public int describeContents();
|
||||
method public float getDesiredMaxAverageLuminance();
|
||||
method public float getDesiredMaxLuminance();
|
||||
method public float getDesiredMinLuminance();
|
||||
method public int[] getSupportedHdrTypes();
|
||||
method public void writeToParcel(android.os.Parcel, int);
|
||||
field public static final android.os.Parcelable.Creator<android.view.Display.HdrCapabilities> CREATOR;
|
||||
field public static final int HDR_TYPE_DOLBY_VISION = 1; // 0x1
|
||||
field public static final int HDR_TYPE_HDR10 = 2; // 0x2
|
||||
field public static final int HDR_TYPE_HLG = 3; // 0x3
|
||||
field public static final float INVALID_LUMINANCE = -1.0f;
|
||||
}
|
||||
|
||||
public static final class Display.Mode implements android.os.Parcelable {
|
||||
method public int describeContents();
|
||||
method public int getModeId();
|
||||
|
||||
@@ -719,10 +719,12 @@ public final class Display {
|
||||
|
||||
/**
|
||||
* Returns the display's HDR capabilities.
|
||||
* @hide
|
||||
*/
|
||||
public HdrCapabilities getHdrCapabilities() {
|
||||
return new HdrCapabilities();
|
||||
synchronized (this) {
|
||||
updateDisplayInfoLocked();
|
||||
return mDisplayInfo.hdrCapabilities;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1127,7 +1129,6 @@ public final class Display {
|
||||
* For example, what HDR types it supports and details about the desired luminance data.
|
||||
* <p>You can get an instance for a given {@link Display} object with
|
||||
* {@link Display#getHdrCapabilities getHdrCapabilities()}.
|
||||
* @hide
|
||||
*/
|
||||
public static final class HdrCapabilities implements Parcelable {
|
||||
/**
|
||||
@@ -1147,6 +1148,7 @@ public final class Display {
|
||||
*/
|
||||
public static final int HDR_TYPE_HLG = 3;
|
||||
|
||||
/** @hide */
|
||||
@IntDef({
|
||||
HDR_TYPE_DOLBY_VISION,
|
||||
HDR_TYPE_HDR10,
|
||||
@@ -1160,9 +1162,20 @@ public final class Display {
|
||||
private float mMaxAverageLuminance = INVALID_LUMINANCE;
|
||||
private float mMinLuminance = INVALID_LUMINANCE;
|
||||
|
||||
/**
|
||||
* @hide
|
||||
*/
|
||||
public HdrCapabilities() {
|
||||
}
|
||||
|
||||
public HdrCapabilities(int[] supportedHdrTypes, float maxLuminance,
|
||||
float maxAverageLuminance, float minLuminance) {
|
||||
mSupportedHdrTypes = supportedHdrTypes;
|
||||
mMaxLuminance = maxLuminance;
|
||||
mMaxAverageLuminance = maxAverageLuminance;
|
||||
mMinLuminance = minLuminance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the supported HDR types of this display.
|
||||
* Returns empty array if HDR is not supported by the display.
|
||||
@@ -1205,6 +1218,9 @@ public final class Display {
|
||||
readFromParcel(source);
|
||||
}
|
||||
|
||||
/**
|
||||
* @hide
|
||||
*/
|
||||
public void readFromParcel(Parcel source) {
|
||||
int types = source.readInt();
|
||||
mSupportedHdrTypes = new int[types];
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
#include <memory>
|
||||
#include <stdio.h>
|
||||
#include <ui/DisplayInfo.h>
|
||||
#include <ui/HdrCapabilities.h>
|
||||
#include <ui/FrameStats.h>
|
||||
#include <ui/Rect.h>
|
||||
#include <ui/Region.h>
|
||||
@@ -83,6 +84,11 @@ static struct {
|
||||
jmethodID init;
|
||||
} gWindowAnimationFrameStatsClassInfo;
|
||||
|
||||
static struct {
|
||||
jclass clazz;
|
||||
jmethodID ctor;
|
||||
} gHdrCapabilitiesClassInfo;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
static jlong nativeCreate(JNIEnv* env, jclass clazz, jobject sessionObj,
|
||||
@@ -610,6 +616,22 @@ static jobject nativeGetHandle(JNIEnv* env, jclass clazz, jlong nativeObject) {
|
||||
return javaObjectForIBinder(env, ctrl->getHandle());
|
||||
}
|
||||
|
||||
static jobject nativeGetHdrCapabilities(JNIEnv* env, jclass clazz, jobject tokenObject) {
|
||||
sp<IBinder> token(ibinderForJavaObject(env, tokenObject));
|
||||
if (token == NULL) return NULL;
|
||||
|
||||
HdrCapabilities capabilities;
|
||||
SurfaceComposerClient::getHdrCapabilities(token, &capabilities);
|
||||
|
||||
const auto& types = capabilities.getSupportedHdrTypes();
|
||||
auto typesArray = env->NewIntArray(types.size());
|
||||
env->SetIntArrayRegion(typesArray, 0, types.size(), types.data());
|
||||
|
||||
return env->NewObject(gHdrCapabilitiesClassInfo.clazz, gHdrCapabilitiesClassInfo.ctor,
|
||||
typesArray, capabilities.getDesiredMaxLuminance(),
|
||||
capabilities.getDesiredMaxAverageLuminance(), capabilities.getDesiredMinLuminance());
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
static const JNINativeMethod sSurfaceControlMethods[] = {
|
||||
@@ -671,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",
|
||||
@@ -733,6 +757,11 @@ int register_android_view_SurfaceControl(JNIEnv* env)
|
||||
animFrameStatsClazz, "init", "(J[J)V");
|
||||
gWindowAnimationFrameStatsClassInfo.UNDEFINED_TIME_NANO = undefined_time_nano;
|
||||
|
||||
jclass hdrCapabilitiesClazz = FindClassOrDie(env, "android/view/Display$HdrCapabilities");
|
||||
gHdrCapabilitiesClassInfo.clazz = MakeGlobalRefOrDie(env, hdrCapabilitiesClazz);
|
||||
gHdrCapabilitiesClassInfo.ctor = GetMethodIDOrDie(env, hdrCapabilitiesClazz, "<init>",
|
||||
"([IFFF)V");
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
@@ -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