summaryrefslogtreecommitdiffstats
path: root/native
diff options
context:
space:
mode:
authorJohn Reck <jreck@google.com>2015-04-20 22:07:42 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2015-04-20 22:07:45 +0000
commit8222a7ec81552276de1814541201c424b392d90b (patch)
treee6d3ab0569338f3ade22f973019e6d7c7d45a13b /native
parent2eec3d14249640988ad6f89c49e6ea155f3ec744 (diff)
parentedc22fba5921f5c2d3502727e707f959b8c3a460 (diff)
downloadframeworks_base-8222a7ec81552276de1814541201c424b392d90b.zip
frameworks_base-8222a7ec81552276de1814541201c424b392d90b.tar.gz
frameworks_base-8222a7ec81552276de1814541201c424b392d90b.tar.bz2
Merge "Revert "Change how Java Bitmaps are accessed in a few places""
Diffstat (limited to 'native')
-rw-r--r--native/graphics/jni/bitmap.cpp35
1 files changed, 17 insertions, 18 deletions
diff --git a/native/graphics/jni/bitmap.cpp b/native/graphics/jni/bitmap.cpp
index 0521833..ddb01a0 100644
--- a/native/graphics/jni/bitmap.cpp
+++ b/native/graphics/jni/bitmap.cpp
@@ -27,16 +27,18 @@ int AndroidBitmap_getInfo(JNIEnv* env, jobject jbitmap,
return ANDROID_BITMAP_RESULT_BAD_PARAMETER;
}
- SkBitmap bm;
- GraphicsJNI::getSkBitmap(env, jbitmap, &bm);
+ SkBitmap* bm = GraphicsJNI::getSkBitmap(env, jbitmap);
+ if (NULL == bm) {
+ return ANDROID_BITMAP_RESULT_JNI_EXCEPTION;
+ }
if (info) {
- info->width = bm.width();
- info->height = bm.height();
- info->stride = bm.rowBytes();
+ info->width = bm->width();
+ info->height = bm->height();
+ info->stride = bm->rowBytes();
info->flags = 0;
- switch (bm.colorType()) {
+ switch (bm->colorType()) {
case kN32_SkColorType:
info->format = ANDROID_BITMAP_FORMAT_RGBA_8888;
break;
@@ -62,18 +64,17 @@ int AndroidBitmap_lockPixels(JNIEnv* env, jobject jbitmap, void** addrPtr) {
return ANDROID_BITMAP_RESULT_BAD_PARAMETER;
}
- SkPixelRef* pixelRef = GraphicsJNI::getSkPixelRef(env, jbitmap);
- if (!pixelRef) {
+ SkBitmap* bm = GraphicsJNI::getSkBitmap(env, jbitmap);
+ if (NULL == bm) {
return ANDROID_BITMAP_RESULT_JNI_EXCEPTION;
}
- pixelRef->lockPixels();
- void* addr = pixelRef->pixels();
+ bm->lockPixels();
+ void* addr = bm->getPixels();
if (NULL == addr) {
- pixelRef->unlockPixels();
+ bm->unlockPixels();
return ANDROID_BITMAP_RESULT_ALLOCATION_FAILED;
}
- pixelRef->ref();
if (addrPtr) {
*addrPtr = addr;
@@ -86,8 +87,8 @@ int AndroidBitmap_unlockPixels(JNIEnv* env, jobject jbitmap) {
return ANDROID_BITMAP_RESULT_BAD_PARAMETER;
}
- SkPixelRef* pixelRef = GraphicsJNI::getSkPixelRef(env, jbitmap);
- if (!pixelRef) {
+ SkBitmap* bm = GraphicsJNI::getSkBitmap(env, jbitmap);
+ if (NULL == bm) {
return ANDROID_BITMAP_RESULT_JNI_EXCEPTION;
}
@@ -95,11 +96,9 @@ int AndroidBitmap_unlockPixels(JNIEnv* env, jobject jbitmap) {
// bitmaps. Note that this will slow down read-only accesses to the
// bitmaps, but the NDK methods are primarily intended to be used for
// writes.
- pixelRef->notifyPixelsChanged();
-
- pixelRef->unlockPixels();
- pixelRef->unref();
+ bm->notifyPixelsChanged();
+ bm->unlockPixels();
return ANDROID_BITMAP_RESULT_SUCCESS;
}