From edc22fba5921f5c2d3502727e707f959b8c3a460 Mon Sep 17 00:00:00 2001 From: John Reck Date: Mon, 20 Apr 2015 22:06:31 +0000 Subject: Revert "Change how Java Bitmaps are accessed in a few places" Bug: 20207616 This reverts commit a771b9861d11671c780092d35c0062eeefcf37c0. Change-Id: Ifd891cc075274a7986e987229e0fed5a04ed9ff0 --- native/graphics/jni/bitmap.cpp | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) (limited to 'native') 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; } -- cgit v1.1