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

Commit 1d276351 authored by Alec Mouri's avatar Alec Mouri Committed by Android (Google) Code Review
Browse files

Merge "Add BGRX1010102" into main

parents a5f3ab39 2894315a
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -97,6 +97,8 @@ static int32_t flinger2bitmapFormat(aidl::android::hardware::graphics::common::P
            return ANDROID_BITMAP_FORMAT_RGBA_1010102;
        case aidl::android::hardware::graphics::common::PixelFormat::BGRA_1010102:
            return ANDROID_BITMAP_FORMAT_BGRA_1010102;
        case aidl::android::hardware::graphics::common::PixelFormat::BGRX_1010102:
            return ANDROID_BITMAP_FORMAT_BGRX_1010102;
        default:
            return ANDROID_BITMAP_FORMAT_RGBA_8888;
    }
+1 −0
Original line number Diff line number Diff line
@@ -19253,6 +19253,7 @@ package android.hardware {
    method public static boolean isSupported(@IntRange(from=1) int, @IntRange(from=1) int, int, @IntRange(from=1) int, long);
    method public void writeToParcel(android.os.Parcel, int);
    field @FlaggedApi("com.android.graphics.hwui.flags.requested_formats_bgra_1010102") public static final int BGRA_1010102 = 67; // 0x43
    field @FlaggedApi("com.android.graphics.hwui.flags.requested_formats_bgra_1010102") public static final int BGRX_1010102 = 68; // 0x44
    field public static final int BLOB = 33; // 0x21
    field @NonNull public static final android.os.Parcelable.Creator<android.hardware.HardwareBuffer> CREATOR;
    field public static final int DS_24UI8 = 50; // 0x32
+12 −0
Original line number Diff line number Diff line
@@ -78,6 +78,7 @@ public final class HardwareBuffer implements Parcelable, AutoCloseable {
            RGBA_12121212,
            RGBA_14141414,
            BGRA_1010102,
            BGRX_1010102,
    })
    public @interface Format {
    }
@@ -219,6 +220,17 @@ public final class HardwareBuffer implements Parcelable, AutoCloseable {
    @FlaggedApi(com.android.graphics.hwui.flags.Flags.FLAG_REQUESTED_FORMATS_BGRA_1010102)
    public static final int BGRA_1010102 = 0x43;

    /**
     * 32-bit packed format that has 2-bit unused, 10-bit R, G, and B components,
     * in that order, from the most-significant bits to the least-significant
     * bits.
     *
     * The component values are unsigned normalized to the range [0, 1], whose
     * interpretation is defined by the dataspace.
     */
    @FlaggedApi(com.android.graphics.hwui.flags.Flags.FLAG_REQUESTED_FORMATS_BGRA_1010102)
    public static final int BGRX_1010102 = 0x44;


    // Note: do not rename, this field is used by native code
    @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
+10 −2
Original line number Diff line number Diff line
@@ -67,6 +67,8 @@ static uint32_t getFormat(const SkImageInfo& info) {
            return ANDROID_BITMAP_FORMAT_BGRA_8888;
        case kBGRA_1010102_SkColorType:
            return ANDROID_BITMAP_FORMAT_BGRA_1010102;
        case kBGR_101010x_SkColorType:
            return ANDROID_BITMAP_FORMAT_BGRX_1010102;
        default:
            return ANDROID_BITMAP_FORMAT_NONE;
    }
@@ -90,6 +92,8 @@ static SkColorType getColorType(uint32_t format) {
            return kBGRA_8888_SkColorType;
        case ANDROID_BITMAP_FORMAT_BGRA_1010102:
            return kBGRA_1010102_SkColorType;
        case ANDROID_BITMAP_FORMAT_BGRX_1010102:
            return kBGR_101010x_SkColorType;
        default:
            return kUnknown_SkColorType;
    }
@@ -224,8 +228,9 @@ private:
int ABitmap_compress(const AndroidBitmapInfo* info, ADataSpace dataSpace, const void* pixels,
                     AndroidBitmapCompressFormat inFormat, int32_t quality, void* userContext,
                     AndroidBitmap_CompressWriteFunc fn) {
    // BGRA_1010102 isn't in the public bitmap api.
    if (info->format == ANDROID_BITMAP_FORMAT_BGRA_1010102) {
    // BGRA formats aren't in the public bitmap api.
    if (info->format == ANDROID_BITMAP_FORMAT_BGRA_1010102 ||
        info->format == ANDROID_BITMAP_FORMAT_BGRX_1010102) {
        ALOGE("%s: bad format %d", __func__, info->format);
        return ANDROID_BITMAP_RESULT_BAD_PARAMETER;
    }
@@ -285,6 +290,9 @@ int ABitmap_compressWithGainmap(const AndroidBitmapInfo* info, ADataSpace dataSp
        case ANDROID_BITMAP_FORMAT_BGRA_1010102:
            colorType = kBGRA_1010102_SkColorType;
            break;
        case ANDROID_BITMAP_FORMAT_BGRX_1010102:
            colorType = kBGR_101010x_SkColorType;
            break;
        default:
            ALOGE("%s: bad format %d", __func__, info->format);
            return ANDROID_BITMAP_RESULT_BAD_PARAMETER;
+1 −0
Original line number Diff line number Diff line
@@ -92,6 +92,7 @@ __END_DECLS
enum {
    ANDROID_BITMAP_FORMAT_BGRA_8888 = 5,
    ANDROID_BITMAP_FORMAT_BGRA_1010102 = 6,
    ANDROID_BITMAP_FORMAT_BGRX_1010102 = 11,
};

namespace android {
Loading