summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Andy McFadden <fadden@android.com> 2011-02-08 12:25:47 -0800
committer Andy McFadden <fadden@android.com> 2011-02-08 14:23:59 -0800
commit90f4c18a868aa921feae953e380a2f9f6a4ade38 (patch)
tree26d2fbb43aee9bf4831191c3e3897f741961cf74
parent8b166b47946fca251e35ff2078362f728286e531 (diff)
Use JNI helper function to get buffer address
This replaces the Get/Release sequence with a call to jniGetNonMovableArrayElements. Bug 3409356 Change-Id: I847fd67ac71d904fef0c807ac25a29f802e6cd45
-rw-r--r--core/jni/android/graphics/Graphics.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/core/jni/android/graphics/Graphics.cpp b/core/jni/android/graphics/Graphics.cpp
index 48ff5ed2769b..6fedde2e8139 100644
--- a/core/jni/android/graphics/Graphics.cpp
+++ b/core/jni/android/graphics/Graphics.cpp
@@ -502,6 +502,8 @@ void AndroidPixelRef::globalUnref() {
///////////////////////////////////////////////////////////////////////////////
+extern "C" jbyte* jniGetNonMovableArrayElements(C_JNIEnv* env, jarray arrayObj);
+
jbyteArray GraphicsJNI::allocateJavaPixelRef(JNIEnv* env, SkBitmap* bitmap,
SkColorTable* ctable) {
Sk64 size64 = bitmap->getSize64();
@@ -514,8 +516,8 @@ jbyteArray GraphicsJNI::allocateJavaPixelRef(JNIEnv* env, SkBitmap* bitmap,
size_t size = size64.get32();
jbyteArray arrayObj = env->NewByteArray(size);
if (arrayObj) {
- jbyte *addr = env->GetByteArrayElements(arrayObj, NULL);
- env->ReleaseByteArrayElements(arrayObj, addr, 0);
+ // TODO: make this work without jniGetNonMovableArrayElements
+ jbyte* addr = jniGetNonMovableArrayElements(&env->functions, arrayObj);
if (addr) {
SkPixelRef* pr = new AndroidPixelRef(env, (void*) addr, size, arrayObj, ctable);
bitmap->setPixelRef(pr)->unref();