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

Commit f889444f authored by Leon Scroggins III's avatar Leon Scroggins III Committed by Leon Scroggins
Browse files

AImageDecoder: Suppress log messages

Bug: 153071768
Test: AImageDecoderTest

For simplicity, I1aff544e8d6932b9ed0931a00da66a0aba6cd536 made
ImageDecoder skip specifying kOpaque when setting the SkImageInfo for
decoding. For some formats (e.g. jpeg and heif), this results in a log
message:

"Warning: an opaque image should be decoded as opaque - it is being
 decoded as non-opaque, which will draw slower"

This isn't relevant to AImageDecoder, which doesn't let you specify
kOpaque or not (since the intent is not to create an SkBitmap for Skia).

Now that ImageDecoder specifies kOpaque properly, the JNI code no longer
needs to correct it.

Replace another opacity check with ::opaque() for simplicity.

Change-Id: I7c270d9b9db61a61a338f40b056ce5d23a56e14d
parent d8c1e77c
Loading
Loading
Loading
Loading
+3 −6
Original line number Original line Diff line number Diff line
@@ -50,10 +50,8 @@ ImageDecoder::ImageDecoder(std::unique_ptr<SkAndroidCodec> codec, sk_sp<SkPngChu
}
}


SkAlphaType ImageDecoder::getOutAlphaType() const {
SkAlphaType ImageDecoder::getOutAlphaType() const {
    // While an SkBitmap may want to use kOpaque_SkAlphaType for a performance
    return opaque() ? kOpaque_SkAlphaType
    // optimization, this class just outputs raw pixels. Using either
                    : mUnpremultipliedRequired ? kUnpremul_SkAlphaType : kPremul_SkAlphaType;
    // premultiplication choice has no effect on decoding an opaque encoded image.
    return mUnpremultipliedRequired ? kUnpremul_SkAlphaType : kPremul_SkAlphaType;
}
}


bool ImageDecoder::setTargetSize(int width, int height) {
bool ImageDecoder::setTargetSize(int width, int height) {
@@ -82,8 +80,7 @@ bool ImageDecoder::setTargetSize(int width, int height) {
    SkISize targetSize = { width, height }, decodeSize = targetSize;
    SkISize targetSize = { width, height }, decodeSize = targetSize;
    int sampleSize = mCodec->computeSampleSize(&decodeSize);
    int sampleSize = mCodec->computeSampleSize(&decodeSize);


    if (decodeSize != targetSize && mUnpremultipliedRequired
    if (decodeSize != targetSize && mUnpremultipliedRequired && !opaque()) {
            && !mCodec->getInfo().isOpaque()) {
        return false;
        return false;
    }
    }


+0 −3
Original line number Original line Diff line number Diff line
@@ -305,9 +305,6 @@ static jobject ImageDecoder_nDecodeBitmap(JNIEnv* env, jobject /*clazz*/, jlong
    }
    }


    SkImageInfo bitmapInfo = decoder->getOutputInfo();
    SkImageInfo bitmapInfo = decoder->getOutputInfo();
    if (decoder->opaque()) {
        bitmapInfo = bitmapInfo.makeAlphaType(kOpaque_SkAlphaType);
    }
    if (asAlphaMask && colorType == kGray_8_SkColorType) {
    if (asAlphaMask && colorType == kGray_8_SkColorType) {
        bitmapInfo = bitmapInfo.makeColorType(kAlpha_8_SkColorType);
        bitmapInfo = bitmapInfo.makeColorType(kAlpha_8_SkColorType);
    }
    }