Add check if bitmap is hardware in Bitmap.sameAs

Test: BitmapTests#testHardwareSameAs
bug:30999911
Change-Id: I644776c1ad258fc84d5c2c2ae09bf0859424ee48
This commit is contained in:
sergeyv
2016-12-14 14:19:47 -08:00
committed by Sergei Vasilinetc
parent 0b2a66c72e
commit 1eabed3d14

View File

@@ -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() ||