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

Commit 15a10855 authored by sergeyv's avatar sergeyv
Browse files

Fix getConfig on recycled bitmap

Test: android.graphics.cts.BitmapTest#testGetConfigOnRecycled
bug:33789983
Change-Id: Ic91c16cbd83acdd6002021b44da57636ee27742d
parent 055b324d
Loading
Loading
Loading
Loading
+11 −2
Original line number Diff line number Diff line
@@ -52,6 +52,7 @@ public:
        mAllocationSize = mBitmap->getAllocationByteCount();
        mRowBytes = mBitmap->rowBytes();
        mGenerationId = mBitmap->getGenerationID();
        mIsHardware = mBitmap->isHardware();
        mBitmap.reset();
    }

@@ -118,6 +119,13 @@ public:
        return mGenerationId;
    }

    bool isHardware() {
        if (mBitmap) {
            return mBitmap->isHardware();
        }
        return mIsHardware;
    }

    ~BitmapWrapper() { }

private:
@@ -127,6 +135,7 @@ private:
    size_t mAllocationSize;
    size_t mRowBytes;
    uint32_t mGenerationId;
    bool mIsHardware;
};

// Convenience class that does not take a global ref on the pixels, relying
@@ -775,7 +784,7 @@ static jint Bitmap_rowBytes(JNIEnv* env, jobject, jlong bitmapHandle) {

static jint Bitmap_config(JNIEnv* env, jobject, jlong bitmapHandle) {
    LocalScopedBitmap bitmap(bitmapHandle);
    if (bitmap->bitmap().isHardware()) {
    if (bitmap->isHardware()) {
        return GraphicsJNI::hardwareLegacyBitmapConfig();
    }
    return GraphicsJNI::colorTypeToLegacyBitmapConfig(bitmap->info().colorType());
@@ -1208,7 +1217,7 @@ static jboolean Bitmap_sameAs(JNIEnv* env, jobject, jlong bm0Handle, jlong bm1Ha
    // Paying the price for making Hardware Bitmap as Config:
    // later check for colorType will pass successfully,
    // because Hardware Config internally may be RGBA8888 or smth like that.
    if (bitmap0->bitmap().isHardware() != bitmap1->bitmap().isHardware()) {
    if (bitmap0->isHardware() != bitmap1->isHardware()) {
        return JNI_FALSE;
    }