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

Commit 41ed671e authored by John Reck's avatar John Reck
Browse files

Fix bufferFormat if we're falling back to 8888

Bug: 323896307
Test: atest android.graphics.cts.GainmapTest on sdk_gphone64_x86_64
Change-Id: Icb2f69239d4e8fbfc20922587e4e9e5f5d453460
parent bc608a87
Loading
Loading
Loading
Loading
+11 −4
Original line number Diff line number Diff line
@@ -378,10 +378,17 @@ static FormatInfo determineFormat(const SkBitmap& skBitmap, bool usingGL) {
            break;
        case kAlpha_8_SkColorType:
            formatInfo.isSupported = HardwareBitmapUploader::hasAlpha8Support();
            if (formatInfo.isSupported) {
                formatInfo.bufferFormat = AHARDWAREBUFFER_FORMAT_R8_UNORM;
                formatInfo.format = GL_RED;
                formatInfo.type = GL_UNSIGNED_BYTE;
                formatInfo.vkFormat = VK_FORMAT_R8_UNORM;
            } else {
                formatInfo.type = GL_UNSIGNED_BYTE;
                formatInfo.bufferFormat = AHARDWAREBUFFER_FORMAT_R8G8B8A8_UNORM;
                formatInfo.vkFormat = VK_FORMAT_R8G8B8A8_UNORM;
                formatInfo.format = GL_RGBA;
            }
            break;
        default:
            ALOGW("unable to create hardware bitmap of colortype: %d", skBitmap.info().colorType());
+1 −5
Original line number Diff line number Diff line
@@ -148,10 +148,6 @@ sk_sp<Bitmap> Bitmap::allocateAshmemBitmap(size_t size, const SkImageInfo& info,

sk_sp<Bitmap> Bitmap::allocateHardwareBitmap(const SkBitmap& bitmap) {
#ifdef __ANDROID__  // Layoutlib does not support hardware acceleration
    if (bitmap.colorType() == kAlpha_8_SkColorType &&
        !uirenderer::HardwareBitmapUploader::hasAlpha8Support()) {
        return nullptr;
    }
    return uirenderer::HardwareBitmapUploader::allocateHardwareBitmap(bitmap);
#else
    return Bitmap::allocateHeapBitmap(bitmap.info());