Loading cmds/screencap/screencap.cpp +9 −4 Original line number Diff line number Diff line Loading @@ -37,6 +37,7 @@ #include <ui/GraphicTypes.h> #include <ui/PixelFormat.h> #include "aidl/android/hardware/graphics/common/PixelFormat.h" #include "screencap_utils.h" #include "utils/Errors.h" Loading Loading @@ -87,12 +88,14 @@ static const struct option LONG_OPTIONS[] = {{"png", no_argument, nullptr, 'p'}, LongOpts::HintForSeamless}, {0, 0, 0, 0}}; static int32_t flinger2bitmapFormat(PixelFormat f) { static int32_t flinger2bitmapFormat(aidl::android::hardware::graphics::common::PixelFormat f) { switch (f) { case PIXEL_FORMAT_RGB_565: case aidl::android::hardware::graphics::common::PixelFormat::RGB_565: return ANDROID_BITMAP_FORMAT_RGB_565; case PIXEL_FORMAT_RGBA_1010102: case aidl::android::hardware::graphics::common::PixelFormat::RGBA_1010102: return ANDROID_BITMAP_FORMAT_RGBA_1010102; case aidl::android::hardware::graphics::common::PixelFormat::BGRA_1010102: return ANDROID_BITMAP_FORMAT_BGRA_1010102; default: return ANDROID_BITMAP_FORMAT_RGBA_8888; } Loading Loading @@ -205,7 +208,9 @@ status_t saveImage(const char* fn, std::optional<AndroidBitmapCompressFormat> fo if (format) { AndroidBitmapInfo info; info.format = flinger2bitmapFormat(buffer->getPixelFormat()); info.format = flinger2bitmapFormat( static_cast<aidl::android::hardware::graphics::common::PixelFormat>( buffer->getPixelFormat())); info.flags = ANDROID_BITMAP_FLAGS_ALPHA_PREMUL; info.width = buffer->getWidth(); info.height = buffer->getHeight(); Loading libs/hwui/apex/android_bitmap.cpp +13 −0 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ #include <utils/Color.h> #include "GraphicsJNI.h" #include "SkColorType.h" #include "TypeCast.h" #include "android/graphics/bitmap.h" Loading Loading @@ -64,6 +65,8 @@ static uint32_t getFormat(const SkImageInfo& info) { return ANDROID_BITMAP_FORMAT_RGBA_1010102; case kBGRA_8888_SkColorType: return ANDROID_BITMAP_FORMAT_BGRA_8888; case kBGRA_1010102_SkColorType: return ANDROID_BITMAP_FORMAT_BGRA_1010102; default: return ANDROID_BITMAP_FORMAT_NONE; } Loading @@ -85,6 +88,8 @@ static SkColorType getColorType(uint32_t format) { return kRGBA_1010102_SkColorType; case ANDROID_BITMAP_FORMAT_BGRA_8888: return kBGRA_8888_SkColorType; case ANDROID_BITMAP_FORMAT_BGRA_1010102: return kBGRA_1010102_SkColorType; default: return kUnknown_SkColorType; } Loading Loading @@ -219,6 +224,11 @@ 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) { ALOGE("%s: bad format %d", __func__, info->format); return ANDROID_BITMAP_RESULT_BAD_PARAMETER; } return ABitmap_compressWithGainmap(info, dataSpace, pixels, nullptr, -1.f, inFormat, quality, userContext, fn); } Loading Loading @@ -272,6 +282,9 @@ int ABitmap_compressWithGainmap(const AndroidBitmapInfo* info, ADataSpace dataSp case ANDROID_BITMAP_FORMAT_RGBA_1010102: colorType = kRGBA_1010102_SkColorType; break; case ANDROID_BITMAP_FORMAT_BGRA_1010102: colorType = kBGRA_1010102_SkColorType; break; default: ALOGE("%s: bad format %d", __func__, info->format); return ANDROID_BITMAP_RESULT_BAD_PARAMETER; Loading libs/hwui/apex/include/android/graphics/bitmap.h +1 −0 Original line number Diff line number Diff line Loading @@ -91,6 +91,7 @@ __END_DECLS // Internal extension to AndroidBitmapFormat. enum { ANDROID_BITMAP_FORMAT_BGRA_8888 = 5, ANDROID_BITMAP_FORMAT_BGRA_1010102 = 6, }; namespace android { Loading native/graphics/jni/imagedecoder.cpp +2 −0 Original line number Diff line number Diff line Loading @@ -214,6 +214,8 @@ static SkColorType getColorType(uint32_t format) { return kRGBA_1010102_SkColorType; case ANDROID_BITMAP_FORMAT_BGRA_8888: return kBGRA_8888_SkColorType; case ANDROID_BITMAP_FORMAT_BGRA_1010102: return kBGRA_1010102_SkColorType; default: return kUnknown_SkColorType; } Loading Loading
cmds/screencap/screencap.cpp +9 −4 Original line number Diff line number Diff line Loading @@ -37,6 +37,7 @@ #include <ui/GraphicTypes.h> #include <ui/PixelFormat.h> #include "aidl/android/hardware/graphics/common/PixelFormat.h" #include "screencap_utils.h" #include "utils/Errors.h" Loading Loading @@ -87,12 +88,14 @@ static const struct option LONG_OPTIONS[] = {{"png", no_argument, nullptr, 'p'}, LongOpts::HintForSeamless}, {0, 0, 0, 0}}; static int32_t flinger2bitmapFormat(PixelFormat f) { static int32_t flinger2bitmapFormat(aidl::android::hardware::graphics::common::PixelFormat f) { switch (f) { case PIXEL_FORMAT_RGB_565: case aidl::android::hardware::graphics::common::PixelFormat::RGB_565: return ANDROID_BITMAP_FORMAT_RGB_565; case PIXEL_FORMAT_RGBA_1010102: case aidl::android::hardware::graphics::common::PixelFormat::RGBA_1010102: return ANDROID_BITMAP_FORMAT_RGBA_1010102; case aidl::android::hardware::graphics::common::PixelFormat::BGRA_1010102: return ANDROID_BITMAP_FORMAT_BGRA_1010102; default: return ANDROID_BITMAP_FORMAT_RGBA_8888; } Loading Loading @@ -205,7 +208,9 @@ status_t saveImage(const char* fn, std::optional<AndroidBitmapCompressFormat> fo if (format) { AndroidBitmapInfo info; info.format = flinger2bitmapFormat(buffer->getPixelFormat()); info.format = flinger2bitmapFormat( static_cast<aidl::android::hardware::graphics::common::PixelFormat>( buffer->getPixelFormat())); info.flags = ANDROID_BITMAP_FLAGS_ALPHA_PREMUL; info.width = buffer->getWidth(); info.height = buffer->getHeight(); Loading
libs/hwui/apex/android_bitmap.cpp +13 −0 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ #include <utils/Color.h> #include "GraphicsJNI.h" #include "SkColorType.h" #include "TypeCast.h" #include "android/graphics/bitmap.h" Loading Loading @@ -64,6 +65,8 @@ static uint32_t getFormat(const SkImageInfo& info) { return ANDROID_BITMAP_FORMAT_RGBA_1010102; case kBGRA_8888_SkColorType: return ANDROID_BITMAP_FORMAT_BGRA_8888; case kBGRA_1010102_SkColorType: return ANDROID_BITMAP_FORMAT_BGRA_1010102; default: return ANDROID_BITMAP_FORMAT_NONE; } Loading @@ -85,6 +88,8 @@ static SkColorType getColorType(uint32_t format) { return kRGBA_1010102_SkColorType; case ANDROID_BITMAP_FORMAT_BGRA_8888: return kBGRA_8888_SkColorType; case ANDROID_BITMAP_FORMAT_BGRA_1010102: return kBGRA_1010102_SkColorType; default: return kUnknown_SkColorType; } Loading Loading @@ -219,6 +224,11 @@ 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) { ALOGE("%s: bad format %d", __func__, info->format); return ANDROID_BITMAP_RESULT_BAD_PARAMETER; } return ABitmap_compressWithGainmap(info, dataSpace, pixels, nullptr, -1.f, inFormat, quality, userContext, fn); } Loading Loading @@ -272,6 +282,9 @@ int ABitmap_compressWithGainmap(const AndroidBitmapInfo* info, ADataSpace dataSp case ANDROID_BITMAP_FORMAT_RGBA_1010102: colorType = kRGBA_1010102_SkColorType; break; case ANDROID_BITMAP_FORMAT_BGRA_1010102: colorType = kBGRA_1010102_SkColorType; break; default: ALOGE("%s: bad format %d", __func__, info->format); return ANDROID_BITMAP_RESULT_BAD_PARAMETER; Loading
libs/hwui/apex/include/android/graphics/bitmap.h +1 −0 Original line number Diff line number Diff line Loading @@ -91,6 +91,7 @@ __END_DECLS // Internal extension to AndroidBitmapFormat. enum { ANDROID_BITMAP_FORMAT_BGRA_8888 = 5, ANDROID_BITMAP_FORMAT_BGRA_1010102 = 6, }; namespace android { Loading
native/graphics/jni/imagedecoder.cpp +2 −0 Original line number Diff line number Diff line Loading @@ -214,6 +214,8 @@ static SkColorType getColorType(uint32_t format) { return kRGBA_1010102_SkColorType; case ANDROID_BITMAP_FORMAT_BGRA_8888: return kBGRA_8888_SkColorType; case ANDROID_BITMAP_FORMAT_BGRA_1010102: return kBGRA_1010102_SkColorType; default: return kUnknown_SkColorType; } Loading