diff options
author | Mike Reed <reed@google.com> | 2017-10-06 16:25:49 -0400 |
---|---|---|
committer | Mike Reed <reed@google.com> | 2017-10-06 16:25:55 -0400 |
commit | 7569de0f90959b7eb9b432cc349425ab6d27f6cc (patch) | |
tree | 7eef77ed4823bace5e987c10ebde03e337424c0f | |
parent | 771f811c38b1dd2a8cdcb51c0f97e9364a3edb0f (diff) |
switch to new API for compute image size
Test: make
Change-Id: Ie3a5d068bef1c2a1790ab227f6398695aee11cf7
-rwxr-xr-x | core/jni/android/graphics/Bitmap.cpp | 8 | ||||
-rw-r--r-- | core/jni/android/graphics/BitmapFactory.cpp | 5 | ||||
-rw-r--r-- | core/jni/android/graphics/Graphics.cpp | 2 | ||||
-rw-r--r-- | rs/jni/android_renderscript_RenderScript.cpp | 8 |
4 files changed, 11 insertions, 12 deletions
diff --git a/core/jni/android/graphics/Bitmap.cpp b/core/jni/android/graphics/Bitmap.cpp index ad05a5113dff..635eed3fd0ef 100755 --- a/core/jni/android/graphics/Bitmap.cpp +++ b/core/jni/android/graphics/Bitmap.cpp @@ -1051,7 +1051,7 @@ static jobject Bitmap_createFromParcel(JNIEnv* env, jobject, jobject parcel) { } // 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 @@ static jboolean Bitmap_writeToParcel(JNIEnv* env, jobject, 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 @@ static void Bitmap_copyPixelsToBuffer(JNIEnv* env, jobject, 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 @@ static void Bitmap_copyPixelsFromBuffer(JNIEnv* env, jobject, 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 64e12b4ec05c..5990d7be9d23 100644 --- a/core/jni/android/graphics/BitmapFactory.cpp +++ b/core/jni/android/graphics/BitmapFactory.cpp @@ -174,13 +174,12 @@ public: 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 5ea501e5fefd..90cc7bb72bfa 100644 --- a/core/jni/android/graphics/Graphics.cpp +++ b/core/jni/android/graphics/Graphics.cpp @@ -645,7 +645,7 @@ bool RecyclingClippingPixelAllocator::allocPixelRef(SkBitmap* bitmap) { 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 f9f6bf7dbcab..b32be736533b 100644 --- a/rs/jni/android_renderscript_RenderScript.cpp +++ b/rs/jni/android_renderscript_RenderScript.cpp @@ -1328,7 +1328,7 @@ nAllocationCreateFromBitmap(JNIEnv *_env, jobject _this, jlong con, jlong type, 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 @@ nAllocationCubeCreateFromBitmap(JNIEnv *_env, jobject _this, jlong con, jlong ty 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 @@ nAllocationCopyFromBitmap(JNIEnv *_env, jobject _this, jlong con, jlong alloc, j 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 @@ nAllocationCopyToBitmap(JNIEnv *_env, jobject _this, jlong con, jlong alloc, job 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(); } |