diff options
author | Elliott Hughes <enh@google.com> | 2011-04-12 17:50:45 -0700 |
---|---|---|
committer | Elliott Hughes <enh@google.com> | 2011-04-12 17:50:45 -0700 |
commit | cf6f7a0f006c0fcf59bb634cbe79f2a8500fd92a (patch) | |
tree | 14d3f7423253d6b14714b3f3b554c126eb20fd12 /core/jni/android/graphics/Graphics.cpp | |
parent | 83b61471c39fc4d5afc9f56c3ed771a14c8ad194 (diff) | |
download | frameworks_base-cf6f7a0f006c0fcf59bb634cbe79f2a8500fd92a.zip frameworks_base-cf6f7a0f006c0fcf59bb634cbe79f2a8500fd92a.tar.gz frameworks_base-cf6f7a0f006c0fcf59bb634cbe79f2a8500fd92a.tar.bz2 |
Don't allocate a raw object then call its constructor manually...
We can do this in one step.
Change-Id: Id6b70c83002038caf62fe89cc769eca54ae0c055
Diffstat (limited to 'core/jni/android/graphics/Graphics.cpp')
-rw-r--r-- | core/jni/android/graphics/Graphics.cpp | 37 |
1 files changed, 11 insertions, 26 deletions
diff --git a/core/jni/android/graphics/Graphics.cpp b/core/jni/android/graphics/Graphics.cpp index 6c28e65..64bd207 100644 --- a/core/jni/android/graphics/Graphics.cpp +++ b/core/jni/android/graphics/Graphics.cpp @@ -350,14 +350,10 @@ jobject GraphicsJNI::createBitmap(JNIEnv* env, SkBitmap* bitmap, jbyteArray buff SkASSERT(bitmap); SkASSERT(bitmap->pixelRef()); - jobject obj = env->AllocObject(gBitmap_class); - if (obj) { - env->CallVoidMethod(obj, gBitmap_constructorMethodID, - (jint)bitmap, buffer, isMutable, ninepatch, density); - if (hasException(env)) { - obj = NULL; - } - } + jobject obj = env->NewObject(gBitmap_class, gBitmap_constructorMethodID, + static_cast<jint>(reinterpret_cast<uintptr_t>(bitmap)), + buffer, isMutable, ninepatch, density); + hasException(env); // For the side effect of logging. return obj; } @@ -372,30 +368,19 @@ jobject GraphicsJNI::createBitmapRegionDecoder(JNIEnv* env, SkBitmapRegionDecode { SkASSERT(bitmap != NULL); - jobject obj = env->AllocObject(gBitmapRegionDecoder_class); - if (hasException(env)) { - obj = NULL; - return obj; - } - if (obj) { - env->CallVoidMethod(obj, gBitmapRegionDecoder_constructorMethodID, (jint)bitmap); - if (hasException(env)) { - obj = NULL; - } - } + jobject obj = env->NewObject(gBitmapRegionDecoder_class, + gBitmapRegionDecoder_constructorMethodID, + static_cast<jint>(reinterpret_cast<uintptr_t>(bitmap))); + hasException(env); // For the side effect of logging. return obj; } jobject GraphicsJNI::createRegion(JNIEnv* env, SkRegion* region) { SkASSERT(region != NULL); - jobject obj = env->AllocObject(gRegion_class); - if (obj) { - env->CallVoidMethod(obj, gRegion_constructorMethodID, (jint)region, 0); - if (hasException(env)) { - obj = NULL; - } - } + jobject obj = env->NewObject(gRegion_class, gRegion_constructorMethodID, + static_cast<jint>(reinterpret_cast<uintptr_t>(region)), 0); + hasException(env); // For the side effect of logging. return obj; } |