diff --git a/api/current.txt b/api/current.txt index c4889bc896122..c1d10e82496ca 100644 --- a/api/current.txt +++ b/api/current.txt @@ -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 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 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 diff --git a/api/system-current.txt b/api/system-current.txt index 02470f934f9c8..d68a6f65380ee 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -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 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 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 diff --git a/api/test-current.txt b/api/test-current.txt index bf801f8b0c8de..25bd5deaa9c0e 100644 --- a/api/test-current.txt +++ b/api/test-current.txt @@ -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 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 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 diff --git a/core/java/android/hardware/HardwareBuffer.java b/core/java/android/hardware/HardwareBuffer.java index e97bb2f79be89..7b09e26ddb9e2 100644 --- a/core/java/android/hardware/HardwareBuffer.java +++ b/core/java/android/hardware/HardwareBuffer.java @@ -40,21 +40,24 @@ 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; + public static final int RGBA_8888 = 1; /** Format: 8 bits each red, green, blue, alpha, alpha is always 0xFF */ - public static final int RGBX_8888 = 2; + public static final int RGBX_8888 = 2; /** Format: 8 bits each red, green, blue, no alpha */ - public static final int RGB_888 = 3; + public static final int RGB_888 = 3; /** Format: 5 bits each red and blue, 6 bits green, no alpha */ - public static final int RGB_565 = 4; + public static final int RGB_565 = 4; /** Format: 16 bits each red, green, blue, alpha */ - public static final int RGBA_FP16 = 0x16; + 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; + public static final int BLOB = 0x21; // Note: do not rename, this field is used by native code private long mNativeObject; @@ -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 HardwareBuffer. */ 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 format 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: diff --git a/core/jni/android_hardware_HardwareBuffer.cpp b/core/jni/android_hardware_HardwareBuffer.cpp index 6cf5ccfa2d15b..5f0664b40a685 100644 --- a/core/jni/android_hardware_HardwareBuffer.cpp +++ b/core/jni/android_hardware_HardwareBuffer.cpp @@ -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: diff --git a/core/jni/android_view_Surface.cpp b/core/jni/android_view_Surface.cpp index bc5f847a4aa81..fb4469ebefe1c 100644 --- a/core/jni/android_view_Surface.cpp +++ b/core/jni/android_view_Surface.cpp @@ -169,6 +169,7 @@ PublicFormat android_view_Surface_mapHalFormatDataspaceToPublicFormat( case HAL_PIXEL_FORMAT_RGBA_8888: case HAL_PIXEL_FORMAT_RGBX_8888: case HAL_PIXEL_FORMAT_RGBA_FP16: + case HAL_PIXEL_FORMAT_RGBA_1010102: case HAL_PIXEL_FORMAT_RGB_888: case HAL_PIXEL_FORMAT_RGB_565: case HAL_PIXEL_FORMAT_Y8: diff --git a/core/jni/android_view_TextureView.cpp b/core/jni/android_view_TextureView.cpp index 613e0402412ad..18a13605f5396 100644 --- a/core/jni/android_view_TextureView.cpp +++ b/core/jni/android_view_TextureView.cpp @@ -83,7 +83,7 @@ static inline SkImageInfo convertPixelFormat(const ANativeWindow_Buffer& buffer) colorType = kN32_SkColorType; alphaType = kOpaque_SkAlphaType; break; - case WINDOW_FORMAT_RGBA_FP16: + case AHARDWAREBUFFER_FORMAT_R16G16B16A16_SFLOAT: colorType = kRGBA_F16_SkColorType; alphaType = kPremul_SkAlphaType; break; diff --git a/core/jni/include/android_runtime/android_view_Surface.h b/core/jni/include/android_runtime/android_view_Surface.h index 1bc85212090ae..e7e7b3c197592 100644 --- a/core/jni/include/android_runtime/android_view_Surface.h +++ b/core/jni/include/android_runtime/android_view_Surface.h @@ -49,6 +49,7 @@ enum class PublicFormat { RAW_PRIVATE = 0x24, RAW10 = 0x25, RAW12 = 0x26, + RGBA_1010102 = 0x2b, JPEG = 0x100, DEPTH_POINT_CLOUD = 0x101, YV12 = 0x32315659, diff --git a/graphics/java/android/graphics/PixelFormat.java b/graphics/java/android/graphics/PixelFormat.java index c3a944327fb5a..f93886dcb06b6 100644 --- a/graphics/java/android/graphics/PixelFormat.java +++ b/graphics/java/android/graphics/PixelFormat.java @@ -29,65 +29,66 @@ public class PixelFormat { /** @hide */ @Retention(RetentionPolicy.SOURCE) - @IntDef({RGBA_8888, RGBX_8888, RGBA_F16, RGB_888, RGB_565}) - public @interface Format { }; + @IntDef({RGBA_8888, RGBX_8888, RGBA_F16, RGBA_1010102, RGB_888, RGB_565}) + public @interface Format { } // NOTE: these constants must match the values from graphics/common/x.x/types.hal - public static final int UNKNOWN = 0; + public static final int UNKNOWN = 0; /** System chooses a format that supports translucency (many alpha bits) */ - public static final int TRANSLUCENT = -3; + public static final int TRANSLUCENT = -3; /** * System chooses a format that supports transparency * (at least 1 alpha bit) */ - public static final int TRANSPARENT = -2; + public static final int TRANSPARENT = -2; /** System chooses an opaque format (no alpha bits required) */ - public static final int OPAQUE = -1; + public static final int OPAQUE = -1; - public static final int RGBA_8888 = 1; - public static final int RGBX_8888 = 2; - public static final int RGB_888 = 3; - public static final int RGB_565 = 4; + public static final int RGBA_8888 = 1; + public static final int RGBX_8888 = 2; + public static final int RGB_888 = 3; + public static final int RGB_565 = 4; @Deprecated - public static final int RGBA_5551 = 6; + public static final int RGBA_5551 = 6; @Deprecated - public static final int RGBA_4444 = 7; + public static final int RGBA_4444 = 7; @Deprecated - public static final int A_8 = 8; + public static final int A_8 = 8; @Deprecated - public static final int L_8 = 9; + public static final int L_8 = 9; @Deprecated - public static final int LA_88 = 0xA; + public static final int LA_88 = 0xA; @Deprecated - public static final int RGB_332 = 0xB; + public static final int RGB_332 = 0xB; /** * @deprecated use {@link android.graphics.ImageFormat#NV16 * ImageFormat.NV16} instead. */ @Deprecated - public static final int YCbCr_422_SP= 0x10; + public static final int YCbCr_422_SP = 0x10; /** * @deprecated use {@link android.graphics.ImageFormat#NV21 * ImageFormat.NV21} instead. */ @Deprecated - public static final int YCbCr_420_SP= 0x11; + public static final int YCbCr_420_SP = 0x11; /** * @deprecated use {@link android.graphics.ImageFormat#YUY2 * ImageFormat.YUY2} instead. */ @Deprecated - public static final int YCbCr_422_I = 0x14; + public static final int YCbCr_422_I = 0x14; - public static final int RGBA_F16 = 0x16; + public static final int RGBA_F16 = 0x16; + public static final int RGBA_1010102 = 0x2B; /** * @deprecated use {@link android.graphics.ImageFormat#JPEG @@ -103,6 +104,7 @@ public class PixelFormat { switch (format) { case RGBA_8888: case RGBX_8888: + case RGBA_1010102: info.bitsPerPixel = 32; info.bytesPerPixel = 4; break; @@ -149,6 +151,7 @@ public class PixelFormat { case PixelFormat.RGBA_5551: case PixelFormat.RGBA_8888: case PixelFormat.RGBA_F16: + case PixelFormat.RGBA_1010102: case PixelFormat.TRANSLUCENT: case PixelFormat.TRANSPARENT: return true; @@ -176,6 +179,7 @@ public class PixelFormat { case RGB_888: case RGB_565: case RGBA_F16: + case RGBA_1010102: return true; }