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

Commit 1eabed3d authored by sergeyv's avatar sergeyv Committed by Sergei Vasilinetc
Browse files

Add check if bitmap is hardware in Bitmap.sameAs

Test: BitmapTests#testHardwareSameAs
bug:30999911
Change-Id: I644776c1ad258fc84d5c2c2ae09bf0859424ee48
parent 0b2a66c7
Loading
Loading
Loading
Loading
+13 −2
Original line number Diff line number Diff line
@@ -1131,8 +1131,19 @@ static jboolean Bitmap_sameAs(JNIEnv* env, jobject, jlong bm0Handle,
                              jlong bm1Handle) {
    SkBitmap bm0;
    SkBitmap bm1;
    reinterpret_cast<BitmapWrapper*>(bm0Handle)->getSkBitmap(&bm0);
    reinterpret_cast<BitmapWrapper*>(bm1Handle)->getSkBitmap(&bm1);

    LocalScopedBitmap bitmap0(bm0Handle);
    LocalScopedBitmap bitmap1(bm1Handle);

    // 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()) {
        return JNI_FALSE;
    }

    bitmap0->bitmap().getSkBitmap(&bm0);
    bitmap1->bitmap().getSkBitmap(&bm1);
    if (bm0.width() != bm1.width() ||
        bm0.height() != bm1.height() ||
        bm0.colorType() != bm1.colorType() ||