diff options
Diffstat (limited to 'core/jni/android/graphics/NinePatch.cpp')
-rw-r--r-- | core/jni/android/graphics/NinePatch.cpp | 45 |
1 files changed, 21 insertions, 24 deletions
diff --git a/core/jni/android/graphics/NinePatch.cpp b/core/jni/android/graphics/NinePatch.cpp index 348b0ec..3f8bfe2 100644 --- a/core/jni/android/graphics/NinePatch.cpp +++ b/core/jni/android/graphics/NinePatch.cpp @@ -64,7 +64,7 @@ public: return JNI_FALSE; } - static jlong validateNinePatchChunk(JNIEnv* env, jobject, jbyteArray obj) { + static jlong validateNinePatchChunk(JNIEnv* env, jobject, jlong, jbyteArray obj) { size_t chunkSize = env->GetArrayLength(obj); if (chunkSize < (int) (sizeof(Res_png_9patch))) { jniThrowRuntimeException(env, "Array too small for chunk."); @@ -88,13 +88,13 @@ public: } } - static void draw(JNIEnv* env, SkCanvas* canvas, SkRect& bounds, const SkBitmap& bitmap, + static void draw(JNIEnv* env, SkCanvas* canvas, SkRect& bounds, const SkBitmap* bitmap, Res_png_9patch* chunk, const SkPaint* paint, jint destDensity, jint srcDensity) { if (destDensity == srcDensity || destDensity == 0 || srcDensity == 0) { ALOGV("Drawing unscaled 9-patch: (%g,%g)-(%g,%g)", SkScalarToFloat(bounds.fLeft), SkScalarToFloat(bounds.fTop), SkScalarToFloat(bounds.fRight), SkScalarToFloat(bounds.fBottom)); - NinePatch_Draw(canvas, bounds, bitmap, *chunk, paint, NULL); + NinePatch_Draw(canvas, bounds, *bitmap, *chunk, paint, NULL); } else { canvas->save(); @@ -111,25 +111,25 @@ public: SkScalarToFloat(bounds.fRight), SkScalarToFloat(bounds.fBottom), srcDensity, destDensity); - NinePatch_Draw(canvas, bounds, bitmap, *chunk, paint, NULL); + NinePatch_Draw(canvas, bounds, *bitmap, *chunk, paint, NULL); canvas->restore(); } } static void drawF(JNIEnv* env, jobject, jlong canvasHandle, jobject boundsRectF, - jobject jbitmap, jlong chunkHandle, jlong paintHandle, + jlong bitmapHandle, jlong chunkHandle, jlong paintHandle, jint destDensity, jint srcDensity) { SkCanvas* canvas = reinterpret_cast<Canvas*>(canvasHandle)->asSkCanvas(); + const SkBitmap* bitmap = reinterpret_cast<SkBitmap*>(bitmapHandle); Res_png_9patch* chunk = reinterpret_cast<Res_png_9patch*>(chunkHandle); const Paint* paint = reinterpret_cast<Paint*>(paintHandle); SkASSERT(canvas); SkASSERT(boundsRectF); + SkASSERT(bitmap); SkASSERT(chunk); // paint is optional - SkBitmap bitmap; - GraphicsJNI::getSkBitmap(env, jbitmap, &bitmap); SkRect bounds; GraphicsJNI::jrectf_to_rect(env, boundsRectF, &bounds); @@ -137,36 +137,36 @@ public: } static void drawI(JNIEnv* env, jobject, jlong canvasHandle, jobject boundsRect, - jobject jbitmap, jlong chunkHandle, jlong paintHandle, + jlong bitmapHandle, jlong chunkHandle, jlong paintHandle, jint destDensity, jint srcDensity) { SkCanvas* canvas = reinterpret_cast<Canvas*>(canvasHandle)->asSkCanvas(); + const SkBitmap* bitmap = reinterpret_cast<SkBitmap*>(bitmapHandle); Res_png_9patch* chunk = reinterpret_cast<Res_png_9patch*>(chunkHandle); const Paint* paint = reinterpret_cast<Paint*>(paintHandle); SkASSERT(canvas); SkASSERT(boundsRect); + SkASSERT(bitmap); SkASSERT(chunk); // paint is optional - SkBitmap bitmap; - GraphicsJNI::getSkBitmap(env, jbitmap, &bitmap); SkRect bounds; GraphicsJNI::jrect_to_rect(env, boundsRect, &bounds); draw(env, canvas, bounds, bitmap, chunk, paint, destDensity, srcDensity); } - static jlong getTransparentRegion(JNIEnv* env, jobject, jobject jbitmap, + static jlong getTransparentRegion(JNIEnv* env, jobject, jlong bitmapHandle, jlong chunkHandle, jobject boundsRect) { + const SkBitmap* bitmap = reinterpret_cast<SkBitmap*>(bitmapHandle); Res_png_9patch* chunk = reinterpret_cast<Res_png_9patch*>(chunkHandle); + SkASSERT(bitmap); SkASSERT(chunk); SkASSERT(boundsRect); - SkBitmap bitmap; - GraphicsJNI::getSkBitmap(env, jbitmap, &bitmap); SkRect bounds; GraphicsJNI::jrect_to_rect(env, boundsRect, &bounds); SkRegion* region = NULL; - NinePatch_Draw(NULL, bounds, bitmap, *chunk, NULL, ®ion); + NinePatch_Draw(NULL, bounds, *bitmap, *chunk, NULL, ®ion); return reinterpret_cast<jlong>(region); } @@ -176,16 +176,13 @@ public: ///////////////////////////////////////////////////////////////////////////////////////// static JNINativeMethod gNinePatchMethods[] = { - { "isNinePatchChunk", "([B)Z", (void*) SkNinePatchGlue::isNinePatchChunk }, - { "validateNinePatchChunk", "([B)J", - (void*) SkNinePatchGlue::validateNinePatchChunk }, - { "nativeFinalize", "(J)V", (void*) SkNinePatchGlue::finalize }, - { "nativeDraw", "(JLandroid/graphics/RectF;Landroid/graphics/Bitmap;JJII)V", - (void*) SkNinePatchGlue::drawF }, - { "nativeDraw", "(JLandroid/graphics/Rect;Landroid/graphics/Bitmap;JJII)V", - (void*) SkNinePatchGlue::drawI }, - { "nativeGetTransparentRegion", "(Landroid/graphics/Bitmap;JLandroid/graphics/Rect;)J", - (void*) SkNinePatchGlue::getTransparentRegion } + { "isNinePatchChunk", "([B)Z", (void*) SkNinePatchGlue::isNinePatchChunk }, + { "validateNinePatchChunk", "(J[B)J", (void*) SkNinePatchGlue::validateNinePatchChunk }, + { "nativeFinalize", "(J)V", (void*) SkNinePatchGlue::finalize }, + { "nativeDraw", "(JLandroid/graphics/RectF;JJJII)V", (void*) SkNinePatchGlue::drawF }, + { "nativeDraw", "(JLandroid/graphics/Rect;JJJII)V", (void*) SkNinePatchGlue::drawI }, + { "nativeGetTransparentRegion", "(JJLandroid/graphics/Rect;)J", + (void*) SkNinePatchGlue::getTransparentRegion } }; int register_android_graphics_NinePatch(JNIEnv* env) { |