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

Commit 57989c0e authored by Leon Scroggins III's avatar Leon Scroggins III Committed by Android (Google) Code Review
Browse files

Merge "Skip writing zeroes to java allocated memory." into klp-dev

parents ddc0a63d 1ffe727c
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -297,6 +297,9 @@ static jobject doDecode(JNIEnv* env, SkStreamRewindable* stream, jobject padding
            (SkBitmap::Allocator*)&recyclingAllocator : (SkBitmap::Allocator*)&javaAllocator;
    if (decodeMode != SkImageDecoder::kDecodeBounds_Mode) {
        if (!willScale) {
            // If the java allocator is being used to allocate the pixel memory, the decoder
            // need not write zeroes, since the memory is initialized to 0.
            decoder->setSkipWritingZeroes(outputAllocator == &javaAllocator);
            decoder->setAllocator(outputAllocator);
        } else if (javaBitmap != NULL) {
            // check for eventual scaled bounds at allocation time, so we don't decode the bitmap
@@ -403,7 +406,12 @@ static jobject doDecode(JNIEnv* env, SkStreamRewindable* stream, jobject padding
        if (!outputBitmap->allocPixels(outputAllocator, NULL)) {
            return nullObjectReturn("allocation failed for scaled bitmap");
        }

        // If outputBitmap's pixels are newly allocated by Java, there is no need
        // to erase to 0, since the pixels were initialized to 0.
        if (outputAllocator != &javaAllocator) {
            outputBitmap->eraseColor(0);
        }

        SkPaint paint;
        paint.setFilterBitmap(true);