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

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

Clean-ups for BitmapRegionDecoder

Check for OOM after calling encodedFormatToString().

Do not correct Alpha8 to Gray8.  This will be handled in Skia.

Change-Id: Id573548608fbd5fbeef2898844480d8f8f73e1d0
parent ca9c0d42
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -265,7 +265,7 @@ static jobject doDecode(JNIEnv* env, SkStreamRewindable* stream, jobject padding
    if (options != NULL) {
    if (options != NULL) {
        jstring mimeType = encodedFormatToString(env, codec->getEncodedFormat());
        jstring mimeType = encodedFormatToString(env, codec->getEncodedFormat());
        if (env->ExceptionCheck()) {
        if (env->ExceptionCheck()) {
            return nullObjectReturn("OOM in getEncodedFormat()");
            return nullObjectReturn("OOM in encodedFormatToString()");
        }
        }
        env->SetIntField(options, gOptions_widthFieldID, size.width());
        env->SetIntField(options, gOptions_widthFieldID, size.width());
        env->SetIntField(options, gOptions_heightFieldID, size.height());
        env->SetIntField(options, gOptions_heightFieldID, size.height());
+3 −3
Original line number Original line Diff line number Diff line
@@ -136,9 +136,6 @@ static jobject nativeDecodeRegion(JNIEnv* env, jobject, jlong brdHandle, jint in
        sampleSize = env->GetIntField(options, gOptions_sampleSizeFieldID);
        sampleSize = env->GetIntField(options, gOptions_sampleSizeFieldID);
        jobject jconfig = env->GetObjectField(options, gOptions_configFieldID);
        jobject jconfig = env->GetObjectField(options, gOptions_configFieldID);
        colorType = GraphicsJNI::getNativeBitmapColorType(env, jconfig);
        colorType = GraphicsJNI::getNativeBitmapColorType(env, jconfig);
        if (kAlpha_8_SkColorType == colorType) {
            colorType = kGray_8_SkColorType;
        }
        requireUnpremul = !env->GetBooleanField(options, gOptions_premultipliedFieldID);
        requireUnpremul = !env->GetBooleanField(options, gOptions_premultipliedFieldID);
        javaBitmap = env->GetObjectField(options, gOptions_bitmapFieldID);
        javaBitmap = env->GetObjectField(options, gOptions_bitmapFieldID);
        // The Java options of ditherMode and preferQualityOverSpeed are deprecated.  We will
        // The Java options of ditherMode and preferQualityOverSpeed are deprecated.  We will
@@ -189,6 +186,9 @@ static jobject nativeDecodeRegion(JNIEnv* env, jobject, jlong brdHandle, jint in
        env->SetIntField(options, gOptions_heightFieldID, bitmap.height());
        env->SetIntField(options, gOptions_heightFieldID, bitmap.height());
        env->SetObjectField(options, gOptions_mimeFieldID,
        env->SetObjectField(options, gOptions_mimeFieldID,
                encodedFormatToString(env, brd->getEncodedFormat()));
                encodedFormatToString(env, brd->getEncodedFormat()));
        if (env->ExceptionCheck()) {
            return nullObjectReturn("OOM in encodedFormatToString()");
        }
    }
    }


    // If we may have reused a bitmap, we need to indicate that the pixels have changed.
    // If we may have reused a bitmap, we need to indicate that the pixels have changed.