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

Commit 79b9d545 authored by Sally Qi's avatar Sally Qi Committed by Android (Google) Code Review
Browse files

Merge "Expose OverlayProperties class and some APIs." into main

parents 5924e29a c65d4849
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@ aconfig_srcjars = [
    ":android.companion.flags-aconfig-java{.generated_srcjars}",
    ":android.content.pm.flags-aconfig-java{.generated_srcjars}",
    ":android.content.res.flags-aconfig-java{.generated_srcjars}",
    ":android.hardware.flags-aconfig-java{.generated_srcjars}",
    ":android.hardware.radio.flags-aconfig-java{.generated_srcjars}",
    ":android.location.flags-aconfig-java{.generated_srcjars}",
    ":android.nfc.flags-aconfig-java{.generated_srcjars}",
@@ -297,6 +298,19 @@ cc_aconfig_library {
    aconfig_declarations: "android.view.accessibility.flags-aconfig",
}

// Hardware
aconfig_declarations {
    name: "android.hardware.flags-aconfig",
    package: "android.hardware.flags",
    srcs: ["core/java/android/hardware/flags/*.aconfig"],
}

java_aconfig_library {
    name: "android.hardware.flags-aconfig-java",
    aconfig_declarations: "android.hardware.flags-aconfig",
    defaults: ["framework-minus-apex-aconfig-java-defaults"],
}

// Widget
aconfig_declarations {
    name: "android.widget.flags-aconfig",
+8 −0
Original line number Diff line number Diff line
@@ -18173,6 +18173,13 @@ package android.hardware {
    field public static final int YCBCR_P010 = 54; // 0x36
  }
  @FlaggedApi("android.hardware.flags.overlayproperties_class_api") public final class OverlayProperties implements android.os.Parcelable {
    method @FlaggedApi("android.hardware.flags.overlayproperties_class_api") public int describeContents();
    method @FlaggedApi("android.hardware.flags.overlayproperties_class_api") public boolean supportMixedColorSpaces();
    method @FlaggedApi("android.hardware.flags.overlayproperties_class_api") public void writeToParcel(@NonNull android.os.Parcel, int);
    field @FlaggedApi("android.hardware.flags.overlayproperties_class_api") @NonNull public static final android.os.Parcelable.Creator<android.hardware.OverlayProperties> CREATOR;
  }
  public final class Sensor {
    method public int getFifoMaxEventCount();
    method public int getFifoReservedEventCount();
@@ -49851,6 +49858,7 @@ package android.view {
    method public android.view.Display.Mode getMode();
    method public String getName();
    method @Deprecated public int getOrientation();
    method @FlaggedApi("android.hardware.flags.overlayproperties_class_api") @NonNull public android.hardware.OverlayProperties getOverlaySupport();
    method @Deprecated public int getPixelFormat();
    method @Nullable public android.graphics.ColorSpace getPreferredWideGamutColorSpace();
    method public long getPresentationDeadlineNanos();
+39 −24
Original line number Diff line number Diff line
@@ -16,21 +16,28 @@

package android.hardware;

import android.annotation.FlaggedApi;
import android.annotation.NonNull;
import android.hardware.flags.Flags;
import android.os.Parcel;
import android.os.Parcelable;

import libcore.util.NativeAllocationRegistry;

/**
 * The class provides overlay properties of the device. OverlayProperties
 * exposes some capabilities from HWC e.g. if fp16 can be supported for HWUI.
 * Provides supported overlay properties of the device.
 *
 * In the future, more capabilities can be added, e.g., whether or not
 * per-layer colorspaces are supported.
 *
 * @hide
 * <p>
 * Hardware overlay is a technique to composite different buffers directly
 * to the screen using display hardware rather than the GPU.
 * The system compositor is able to assign any content managed by a
 * {@link android.view.SurfaceControl} onto a hardware overlay if possible.
 * Applications may be interested in the display hardware capabilities exposed
 * by this class as a hint to determine if their {@link android.view.SurfaceControl}
 * tree is power-efficient and performant.
 * </p>
 */
@FlaggedApi(Flags.FLAG_OVERLAYPROPERTIES_CLASS_API)
public final class OverlayProperties implements Parcelable {

    private static final NativeAllocationRegistry sRegistry =
@@ -38,18 +45,33 @@ public final class OverlayProperties implements Parcelable {
            nGetDestructor());

    private long mNativeObject;
    // only for virtual displays
    private static OverlayProperties sDefaultOverlayProperties;
    // Invoked on destruction
    private Runnable mCloser;

    public OverlayProperties(long nativeObject) {
    private OverlayProperties(long nativeObject) {
        if (nativeObject != 0) {
            mCloser = sRegistry.registerNativeAllocation(this, nativeObject);
        }
        mNativeObject = nativeObject;
    }

    /**
     * For virtual displays, we provide an overlay properties object
     * with RGBA 8888 only, sRGB only, true for mixed color spaces.
     * @hide
     */
    public static OverlayProperties getDefault() {
        if (sDefaultOverlayProperties == null) {
            sDefaultOverlayProperties = new OverlayProperties(nCreateDefault());
        }
        return sDefaultOverlayProperties;
    }

    /**
     * @return True if the device can support fp16, false otherwise.
     * @hide
     */
    public boolean supportFp16ForHdr() {
        if (mNativeObject == 0) {
@@ -59,8 +81,13 @@ public final class OverlayProperties implements Parcelable {
    }

    /**
     * @return True if the device can support mixed colorspaces, false otherwise.
     * Indicates that hw composition of two or more overlays
     * with different colorspaces is supported on the device.
     *
     * @return True if the device can support mixed colorspaces efficiently,
     *         false if GPU composition fallback is otherwise required.
     */
    @FlaggedApi(Flags.FLAG_OVERLAYPROPERTIES_CLASS_API)
    public boolean supportMixedColorSpaces() {
        if (mNativeObject == 0) {
            return false;
@@ -68,28 +95,14 @@ public final class OverlayProperties implements Parcelable {
        return nSupportMixedColorSpaces(mNativeObject);
    }

    /**
     * Release the local reference.
     */
    public void release() {
        if (mNativeObject != 0) {
            mCloser.run();
            mNativeObject = 0;
        }
    }

    @FlaggedApi(Flags.FLAG_OVERLAYPROPERTIES_CLASS_API)
    @Override
    public int describeContents() {
        return 0;
    }

    /**
     * Flatten this object in to a Parcel.
     *
     * @param dest The Parcel in which the object should be written.
     * @param flags Additional flags about how the object should be written.
     *              May be 0 or {@link #PARCELABLE_WRITE_RETURN_VALUE}.
     */
    @FlaggedApi(Flags.FLAG_OVERLAYPROPERTIES_CLASS_API)
    @Override
    public void writeToParcel(@NonNull Parcel dest, int flags) {
        if (mNativeObject == 0) {
@@ -100,6 +113,7 @@ public final class OverlayProperties implements Parcelable {
        nWriteOverlayPropertiesToParcel(mNativeObject, dest);
    }

    @FlaggedApi(Flags.FLAG_OVERLAYPROPERTIES_CLASS_API)
    public static final @NonNull Parcelable.Creator<OverlayProperties> CREATOR =
            new Parcelable.Creator<OverlayProperties>() {
        public OverlayProperties createFromParcel(Parcel in) {
@@ -115,6 +129,7 @@ public final class OverlayProperties implements Parcelable {
    };

    private static native long nGetDestructor();
    private static native long nCreateDefault();
    private static native boolean nSupportFp16ForHdr(long nativeObject);
    private static native boolean nSupportMixedColorSpaces(long nativeObject);
    private static native void nWriteOverlayPropertiesToParcel(long nativeObject, Parcel dest);
+8 −0
Original line number Diff line number Diff line
package: "android.hardware.flags"

flag {
    name: "overlayproperties_class_api"
    namespace: "core_graphics"
    description: "public OverlayProperties class, OverlayProperties#supportMixedColorSpaces and Display#getOverlaySupport API"
    bug: "267234573"
}
+8 −5
Original line number Diff line number Diff line
@@ -18,8 +18,10 @@ package android.view;

import static android.Manifest.permission.CONFIGURE_DISPLAY_COLOR_MODE;
import static android.Manifest.permission.CONTROL_DISPLAY_BRIGHTNESS;
import static android.hardware.flags.Flags.FLAG_OVERLAYPROPERTIES_CLASS_API;

import android.Manifest;
import android.annotation.FlaggedApi;
import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
@@ -1468,17 +1470,18 @@ public final class Display {
    }

    /**
     * Returns null if it's virtual display.
     * @hide
     * Returns the {@link OverlayProperties} of the display.
     */
    @Nullable
    @FlaggedApi(FLAG_OVERLAYPROPERTIES_CLASS_API)
    @NonNull
    public OverlayProperties getOverlaySupport() {
        synchronized (mLock) {
            updateDisplayInfoLocked();
            if (mDisplayInfo.type != TYPE_VIRTUAL) {
            if (mDisplayInfo.type == TYPE_INTERNAL
                    || mDisplayInfo.type == TYPE_EXTERNAL) {
                return mGlobal.getOverlaySupport();
            }
            return null;
            return OverlayProperties.getDefault();
        }
    }

Loading