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

Commit 8ec21062 authored by Romain Guy's avatar Romain Guy
Browse files

Add RGBA 10:10:10:2 format for surfaces

Bug: 2984164
Test: CtsHardwareTestCases
Change-Id: I4a42cb9002d8f1f1362999f2739d06c712157620
parent e8d2ebb5
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -5504,6 +5504,7 @@ package android.app {
  public final class NotificationChannelGroup implements android.os.Parcelable {
    ctor public NotificationChannelGroup(java.lang.String, java.lang.CharSequence);
    ctor protected NotificationChannelGroup(android.os.Parcel);
    method public android.app.NotificationChannelGroup clone();
    method public int describeContents();
    method public java.util.List<android.app.NotificationChannel> getChannels();
    method public java.lang.String getId();
@@ -13140,6 +13141,7 @@ package android.graphics {
    field public static final deprecated int LA_88 = 10; // 0xa
    field public static final deprecated int L_8 = 9; // 0x9
    field public static final int OPAQUE = -1; // 0xffffffff
    field public static final int RGBA_1010102 = 43; // 0x2b
    field public static final deprecated int RGBA_4444 = 7; // 0x7
    field public static final deprecated int RGBA_5551 = 6; // 0x6
    field public static final int RGBA_8888 = 1; // 0x1
@@ -14371,6 +14373,7 @@ package android.hardware {
    method public void writeToParcel(android.os.Parcel, int);
    field public static final int BLOB = 33; // 0x21
    field public static final android.os.Parcelable.Creator<android.hardware.HardwareBuffer> CREATOR;
    field public static final int RGBA_1010102 = 43; // 0x2b
    field public static final int RGBA_8888 = 1; // 0x1
    field public static final int RGBA_FP16 = 22; // 0x16
    field public static final int RGBX_8888 = 2; // 0x2
+3 −0
Original line number Diff line number Diff line
@@ -5698,6 +5698,7 @@ package android.app {
    ctor public NotificationChannelGroup(java.lang.String, java.lang.CharSequence);
    ctor protected NotificationChannelGroup(android.os.Parcel);
    method public void addChannel(android.app.NotificationChannel);
    method public android.app.NotificationChannelGroup clone();
    method public int describeContents();
    method public java.util.List<android.app.NotificationChannel> getChannels();
    method public java.lang.String getId();
@@ -13708,6 +13709,7 @@ package android.graphics {
    field public static final deprecated int LA_88 = 10; // 0xa
    field public static final deprecated int L_8 = 9; // 0x9
    field public static final int OPAQUE = -1; // 0xffffffff
    field public static final int RGBA_1010102 = 43; // 0x2b
    field public static final deprecated int RGBA_4444 = 7; // 0x7
    field public static final deprecated int RGBA_5551 = 6; // 0x6
    field public static final int RGBA_8888 = 1; // 0x1
@@ -14939,6 +14941,7 @@ package android.hardware {
    method public void writeToParcel(android.os.Parcel, int);
    field public static final int BLOB = 33; // 0x21
    field public static final android.os.Parcelable.Creator<android.hardware.HardwareBuffer> CREATOR;
    field public static final int RGBA_1010102 = 43; // 0x2b
    field public static final int RGBA_8888 = 1; // 0x1
    field public static final int RGBA_FP16 = 22; // 0x16
    field public static final int RGBX_8888 = 2; // 0x2
+3 −0
Original line number Diff line number Diff line
@@ -5514,6 +5514,7 @@ package android.app {
  public final class NotificationChannelGroup implements android.os.Parcelable {
    ctor public NotificationChannelGroup(java.lang.String, java.lang.CharSequence);
    ctor protected NotificationChannelGroup(android.os.Parcel);
    method public android.app.NotificationChannelGroup clone();
    method public int describeContents();
    method public java.util.List<android.app.NotificationChannel> getChannels();
    method public java.lang.String getId();
@@ -13174,6 +13175,7 @@ package android.graphics {
    field public static final deprecated int LA_88 = 10; // 0xa
    field public static final deprecated int L_8 = 9; // 0x9
    field public static final int OPAQUE = -1; // 0xffffffff
    field public static final int RGBA_1010102 = 43; // 0x2b
    field public static final deprecated int RGBA_4444 = 7; // 0x7
    field public static final deprecated int RGBA_5551 = 6; // 0x6
    field public static final int RGBA_8888 = 1; // 0x1
@@ -14405,6 +14407,7 @@ package android.hardware {
    method public void writeToParcel(android.os.Parcel, int);
    field public static final int BLOB = 33; // 0x21
    field public static final android.os.Parcelable.Creator<android.hardware.HardwareBuffer> CREATOR;
    field public static final int RGBA_1010102 = 43; // 0x2b
    field public static final int RGBA_8888 = 1; // 0x1
    field public static final int RGBA_FP16 = 22; // 0x16
    field public static final int RGBX_8888 = 2; // 0x2
+19 −14
Original line number Diff line number Diff line
@@ -40,8 +40,9 @@ import libcore.util.NativeAllocationRegistry;
public final class HardwareBuffer implements Parcelable {
    /** @hide */
    @Retention(RetentionPolicy.SOURCE)
    @IntDef({RGBA_8888, RGBA_FP16, RGBX_8888, RGB_888, RGB_565, BLOB})
    public @interface Format {};
    @IntDef({RGBA_8888, RGBA_FP16, RGBA_1010102, RGBX_8888, RGB_888, RGB_565, BLOB})
    public @interface Format {
    }

    /** Format: 8 bits each red, green, blue, alpha */
    public static final int RGBA_8888    = 1;
@@ -53,6 +54,8 @@ public final class HardwareBuffer implements Parcelable {
    public static final int RGB_565      = 4;
    /** Format: 16 bits each red, green, blue, alpha */
    public static final int RGBA_FP16    = 0x16;
    /** Format: 10 bits each red, green, blue, 2 bits alpha */
    public static final int RGBA_1010102 = 0x2b;
    /** Format: opaque format used for raw data transfer; must have a height of 1 */
    public static final int BLOB         = 0x21;

@@ -107,7 +110,7 @@ public final class HardwareBuffer implements Parcelable {
     * @param width The width in pixels of the buffer
     * @param height The height in pixels of the buffer
     * @param format The format of each pixel, one of {@link #RGBA_8888}, {@link #RGBA_FP16},
     * {@link #RGBX_8888}, {@link #RGB_565}, {@link #RGB_888}
     * {@link #RGBX_8888}, {@link #RGB_565}, {@link #RGB_888}, {@link #RGBA_1010102}, {@link #BLOB}
     * @param layers The number of layers in the buffer
     * @param usage Flags describing how the buffer will be used, one of
     *     {@link #USAGE0_CPU_READ}, {@link #USAGE0_CPU_READ_OFTEN}, {@link #USAGE0_CPU_WRITE},
@@ -150,15 +153,15 @@ public final class HardwareBuffer implements Parcelable {
    }

    /**
     * Private use only. See {@link #create(int, int, int, int, int, long, long)}. May also be
     * Private use only. See {@link #create(int, int, int, int, long)}. May also be
     * called from JNI using an already allocated native <code>HardwareBuffer</code>.
     */
    private HardwareBuffer(long nativeObject) {
        mNativeObject = nativeObject;

        long nativeSize = NATIVE_HARDWARE_BUFFER_SIZE;
        ClassLoader loader = HardwareBuffer.class.getClassLoader();
        NativeAllocationRegistry registry = new NativeAllocationRegistry(
            HardwareBuffer.class.getClassLoader(), nGetNativeFinalizer(), nativeSize);
                loader, nGetNativeFinalizer(), NATIVE_HARDWARE_BUFFER_SIZE);
        mCleaner = registry.registerNativeAllocation(this, mNativeObject);
    }

@@ -186,8 +189,9 @@ public final class HardwareBuffer implements Parcelable {

    /**
     * Returns the format of this buffer, one of {@link #RGBA_8888}, {@link #RGBA_FP16},
     * {@link #RGBX_8888}, {@link #RGB_565}, or {@link #RGB_888}.
     * {@link #RGBX_8888}, {@link #RGB_565}, {@link #RGB_888}, {@link #RGBA_1010102}, {@link #BLOB}.
     */
    @Format
    public int getFormat() {
        if (mNativeObject == 0) {
            throw new IllegalStateException("This HardwareBuffer has been destroyed and its format "
@@ -291,12 +295,13 @@ public final class HardwareBuffer implements Parcelable {
     * @param format The format to validate.
     *
     * @return True if <code>format</code> is a supported format. false otherwise.
     * See {@link #create(int, int, int, int, int, long, long)}.a
     * See {@link #create(int, int, int, int, long)}.
     */
    private static boolean isSupportedFormat(@Format int format) {
        switch(format) {
            case RGBA_8888:
            case RGBA_FP16:
            case RGBA_1010102:
            case RGBX_8888:
            case RGB_565:
            case RGB_888:
+4 −0
Original line number Diff line number Diff line
@@ -239,6 +239,8 @@ uint32_t android_hardware_HardwareBuffer_convertFromPixelFormat(uint32_t format)
            return AHARDWAREBUFFER_FORMAT_R8G8B8_UNORM;
        case HAL_PIXEL_FORMAT_RGBA_FP16:
            return AHARDWAREBUFFER_FORMAT_R16G16B16A16_SFLOAT;
        case HAL_PIXEL_FORMAT_RGBA_1010102:
            return AHARDWAREBUFFER_FORMAT_A2R10G10B10_UNORM_PACK32;
        case HAL_PIXEL_FORMAT_BLOB:
            return AHARDWAREBUFFER_FORMAT_BLOB;
        default:
@@ -259,6 +261,8 @@ uint32_t android_hardware_HardwareBuffer_convertToPixelFormat(uint32_t format) {
            return HAL_PIXEL_FORMAT_RGB_888;
        case AHARDWAREBUFFER_FORMAT_R16G16B16A16_SFLOAT:
            return HAL_PIXEL_FORMAT_RGBA_FP16;
        case AHARDWAREBUFFER_FORMAT_A2R10G10B10_UNORM_PACK32:
            return HAL_PIXEL_FORMAT_RGBA_1010102;
        case AHARDWAREBUFFER_FORMAT_BLOB:
            return HAL_PIXEL_FORMAT_BLOB;
        default:
Loading