Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9ff94c02 authored by Michael Wright's avatar Michael Wright Committed by David James
Browse files

Plumb HDR capabilities to Display

Bug: 25684127
Change-Id: I0a4fcdc59aa1a7b295c8df03699466685300e735
parent 54ac2191
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -722,7 +722,10 @@ public final class Display {
     * @hide
     */
    public HdrCapabilities getHdrCapabilities() {
        return new HdrCapabilities();
        synchronized (this) {
            updateDisplayInfoLocked();
            return mDisplayInfo.hdrCapabilities;
        }
    }

    /**
+9 −0
Original line number Diff line number Diff line
@@ -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 ");
+8 −0
Original line number Diff line number Diff line
@@ -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");
+3 −1
Original line number Diff line number Diff line
@@ -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",
+8 −0
Original line number Diff line number Diff line
@@ -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);
Loading