switch to new API for compute image size
Test: make
Change-Id: Ie3a5d068bef1c2a1790ab227f6398695aee11cf7
diff --git a/core/jni/android/graphics/Bitmap.cpp b/core/jni/android/graphics/Bitmap.cpp
index ad05a51..635eed3 100755
--- a/core/jni/android/graphics/Bitmap.cpp
+++ b/core/jni/android/graphics/Bitmap.cpp
@@ -1051,7 +1051,7 @@
}
// Read the bitmap blob.
- size_t size = bitmap->getSize();
+ size_t size = bitmap->computeByteSize();
android::Parcel::ReadableBlob blob;
android::status_t status = p->readBlob(size, &blob);
if (status) {
@@ -1188,7 +1188,7 @@
p->allowFds() ? "allowed" : "forbidden");
#endif
- size_t size = bitmap.getSize();
+ size_t size = bitmap.computeByteSize();
android::Parcel::WritableBlob blob;
status = p->writeBlob(size, mutableCopy, &blob);
if (status) {
@@ -1411,7 +1411,7 @@
android::AutoBufferPointer abp(env, jbuffer, JNI_TRUE);
// the java side has already checked that buffer is large enough
- memcpy(abp.pointer(), src, bitmap.getSize());
+ memcpy(abp.pointer(), src, bitmap.computeByteSize());
}
}
@@ -1424,7 +1424,7 @@
if (NULL != dst) {
android::AutoBufferPointer abp(env, jbuffer, JNI_FALSE);
// the java side has already checked that buffer is large enough
- memcpy(dst, abp.pointer(), bitmap.getSize());
+ memcpy(dst, abp.pointer(), bitmap.computeByteSize());
bitmap.notifyPixelsChanged();
}
}
diff --git a/core/jni/android/graphics/BitmapFactory.cpp b/core/jni/android/graphics/BitmapFactory.cpp
index 64e12b4..5990d7b 100644
--- a/core/jni/android/graphics/BitmapFactory.cpp
+++ b/core/jni/android/graphics/BitmapFactory.cpp
@@ -174,13 +174,12 @@
return false;
}
- const int64_t size64 = info.getSafeSize64(bitmap->rowBytes());
- if (!sk_64_isS32(size64)) {
+ const size_t size = info.computeByteSize(bitmap->rowBytes());
+ if (size > SK_MaxS32) {
ALOGW("bitmap is too large");
return false;
}
- const size_t size = sk_64_asS32(size64);
if (size > mSize) {
ALOGW("bitmap marked for reuse (%u bytes) can't fit new bitmap "
"(%zu bytes)", mSize, size);
diff --git a/core/jni/android/graphics/Graphics.cpp b/core/jni/android/graphics/Graphics.cpp
index 5ea501e..90cc7bb 100644
--- a/core/jni/android/graphics/Graphics.cpp
+++ b/core/jni/android/graphics/Graphics.cpp
@@ -645,7 +645,7 @@
const int maxHeight = SkTMax(bitmap->height(), mRecycledBitmap->info().height());
const SkImageInfo maxInfo = bitmap->info().makeWH(maxWidth, maxHeight);
const size_t rowBytes = maxInfo.minRowBytes();
- const size_t bytesNeeded = maxInfo.getSafeSize(rowBytes);
+ const size_t bytesNeeded = maxInfo.computeByteSize(rowBytes);
if (bytesNeeded <= mRecycledBytes) {
// Here we take advantage of reconfigure() to reset the rowBytes
// of mRecycledBitmap. It is very important that we pass in
diff --git a/rs/jni/android_renderscript_RenderScript.cpp b/rs/jni/android_renderscript_RenderScript.cpp
index f9f6bf7..b32be73 100644
--- a/rs/jni/android_renderscript_RenderScript.cpp
+++ b/rs/jni/android_renderscript_RenderScript.cpp
@@ -1328,7 +1328,7 @@
const void* ptr = bitmap.getPixels();
jlong id = (jlong)(uintptr_t)rsAllocationCreateFromBitmap((RsContext)con,
(RsType)type, (RsAllocationMipmapControl)mip,
- ptr, bitmap.getSize(), usage);
+ ptr, bitmap.computeByteSize(), usage);
return id;
}
@@ -1356,7 +1356,7 @@
const void* ptr = bitmap.getPixels();
jlong id = (jlong)(uintptr_t)rsAllocationCubeCreateFromBitmap((RsContext)con,
(RsType)type, (RsAllocationMipmapControl)mip,
- ptr, bitmap.getSize(), usage);
+ ptr, bitmap.computeByteSize(), usage);
return id;
}
@@ -1371,7 +1371,7 @@
const void* ptr = bitmap.getPixels();
rsAllocation2DData((RsContext)con, (RsAllocation)alloc, 0, 0,
0, RS_ALLOCATION_CUBEMAP_FACE_POSITIVE_X,
- w, h, ptr, bitmap.getSize(), 0);
+ w, h, ptr, bitmap.computeByteSize(), 0);
}
static void
@@ -1381,7 +1381,7 @@
GraphicsJNI::getSkBitmap(_env, jbitmap, &bitmap);
void* ptr = bitmap.getPixels();
- rsAllocationCopyToBitmap((RsContext)con, (RsAllocation)alloc, ptr, bitmap.getSize());
+ rsAllocationCopyToBitmap((RsContext)con, (RsAllocation)alloc, ptr, bitmap.computeByteSize());
bitmap.notifyPixelsChanged();
}