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

Commit c37f05a6 authored by Jim Shargo's avatar Jim Shargo
Browse files

hwui: Add more detailed logs when compressing a bitmap

It can be really opaque why a bitmap fails to compress, this helps with
debugging.

Bug: 233363648
Flag: EXEMPT logging
Test: n/a (logs)
Change-Id: Ie6556371aea99a333e9e5fc9acc665750e241761
parent 16836443
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -245,6 +245,7 @@ int ABitmap_compressWithGainmap(const AndroidBitmapInfo* info, ADataSpace dataSp
            // kWEBP_JavaEncodeFormat is a valid parameter for Bitmap::compress,
            // for the deprecated Bitmap.CompressFormat.WEBP, but it should not
            // be provided via the NDK. Other integers are likewise invalid.
            ALOGE("%s: bad compress format %d", __func__, inFormat);
            return ANDROID_BITMAP_RESULT_BAD_PARAMETER;
    }

@@ -272,11 +273,13 @@ int ABitmap_compressWithGainmap(const AndroidBitmapInfo* info, ADataSpace dataSp
            colorType = kRGBA_1010102_SkColorType;
            break;
        default:
            ALOGE("%s: bad format %d", __func__, info->format);
            return ANDROID_BITMAP_RESULT_BAD_PARAMETER;
    }

    auto alphaType = getAlphaType(info);
    if (alphaType == kUnknown_SkAlphaType) {
        ALOGE("%s: bad alphaType %d", __func__, info->flags & ANDROID_BITMAP_FLAGS_ALPHA_MASK);
        return ANDROID_BITMAP_RESULT_BAD_PARAMETER;
    }

@@ -291,6 +294,7 @@ int ABitmap_compressWithGainmap(const AndroidBitmapInfo* info, ADataSpace dataSp
        // DataSpaceToColorSpace treats UNKNOWN as SRGB, but compress forces the
        // client to specify SRGB if that is what they want.
        if (!cs || dataSpace == ADATASPACE_UNKNOWN) {
            ALOGE("%s: bad dataspace %d", __func__, dataSpace);
            return ANDROID_BITMAP_RESULT_BAD_PARAMETER;
        }
    }
@@ -298,6 +302,7 @@ int ABitmap_compressWithGainmap(const AndroidBitmapInfo* info, ADataSpace dataSp
    {
        size_t size;
        if (!Bitmap::computeAllocationSize(info->stride, info->height, &size)) {
            ALOGE("%s: unable to compute allocation size", __func__);
            return ANDROID_BITMAP_RESULT_BAD_PARAMETER;
        }
    }
@@ -309,6 +314,7 @@ int ABitmap_compressWithGainmap(const AndroidBitmapInfo* info, ADataSpace dataSp
    {
        SkBitmap tempBitmap;
        if (!tempBitmap.installPixels(imageInfo, const_cast<void*>(pixels), info->stride)) {
            ALOGE("%s: unable to install pixels", __func__);
            return ANDROID_BITMAP_RESULT_BAD_PARAMETER;
        }
    }