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

Commit a493f62a authored by Matt Sarett's avatar Matt Sarett
Browse files

Request legacy mode behavior from SkCodec in BitmapFactory

Png assets look funny when we perform a correct, linear
premultiply.

Change-Id: Ifd1202c49ab8b0061a255c2d5319dcfa2f3fd22f
(cherry picked from commit 76094dbd7f618db5e920cf52482fd3bfe4ddcd90)
parent 682ad3b4
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -384,9 +384,12 @@ static jobject doDecode(JNIEnv* env, SkStreamRewindable* stream, jobject padding
    // Set the alpha type for the decode.
    SkAlphaType alphaType = codec->computeOutputAlphaType(requireUnpremultiplied);

    const SkImageInfo decodeInfo = codec->getInfo().makeWH(size.width(), size.height())
                                                   .makeColorType(decodeColorType)
                                                   .makeAlphaType(alphaType);
    // Enable legacy behavior to avoid any gamma correction.  Android's assets are
    // adjusted to expect a non-gamma correct premultiply.
    sk_sp<SkColorSpace> colorSpace = nullptr;
    const SkImageInfo decodeInfo = SkImageInfo::Make(size.width(), size.height(), decodeColorType,
                                                     alphaType, colorSpace);

    SkImageInfo bitmapInfo = decodeInfo;
    if (decodeColorType == kGray_8_SkColorType) {
        // The legacy implementation of BitmapFactory used kAlpha8 for