summaryrefslogtreecommitdiffstats
path: root/core/jni
diff options
context:
space:
mode:
authorJohn Reck <jreck@google.com>2015-05-04 14:34:41 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2015-05-04 14:34:52 +0000
commit05dc201ff64f6324c2726a8841af7021e7071b97 (patch)
treee3d4dcbeb60a01cf2f4cf7f255ef4fa3ad11c05a /core/jni
parent1641c0cb0b6baf313c82846fe4f64007078c604f (diff)
parent7c103a36f60b690e3fe83c40210e1cb0c76bba43 (diff)
downloadframeworks_base-05dc201ff64f6324c2726a8841af7021e7071b97.zip
frameworks_base-05dc201ff64f6324c2726a8841af7021e7071b97.tar.gz
frameworks_base-05dc201ff64f6324c2726a8841af7021e7071b97.tar.bz2
Merge "Remove Bitmap#getSkBitmap" into mnc-dev
Diffstat (limited to 'core/jni')
-rw-r--r--core/jni/android/graphics/NinePatch.cpp45
-rw-r--r--core/jni/android_graphics_Canvas.cpp42
-rw-r--r--core/jni/android_view_DisplayListCanvas.cpp8
3 files changed, 51 insertions, 44 deletions
diff --git a/core/jni/android/graphics/NinePatch.cpp b/core/jni/android/graphics/NinePatch.cpp
index 3f8bfe2..348b0ec 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, jlong, jbyteArray obj) {
+ static jlong validateNinePatchChunk(JNIEnv* env, jobject, 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,
- jlong bitmapHandle, jlong chunkHandle, jlong paintHandle,
+ jobject jbitmap, 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,
- jlong bitmapHandle, jlong chunkHandle, jlong paintHandle,
+ jobject jbitmap, 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, jlong bitmapHandle,
+ static jlong getTransparentRegion(JNIEnv* env, jobject, jobject jbitmap,
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, &region);
+ NinePatch_Draw(NULL, bounds, bitmap, *chunk, NULL, &region);
return reinterpret_cast<jlong>(region);
}
@@ -176,13 +176,16 @@ public:
/////////////////////////////////////////////////////////////////////////////////////////
static JNINativeMethod gNinePatchMethods[] = {
- { "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 }
+ { "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 }
};
int register_android_graphics_NinePatch(JNIEnv* env) {
diff --git a/core/jni/android_graphics_Canvas.cpp b/core/jni/android_graphics_Canvas.cpp
index 50a1069..9b5fb3a 100644
--- a/core/jni/android_graphics_Canvas.cpp
+++ b/core/jni/android_graphics_Canvas.cpp
@@ -318,11 +318,12 @@ static void drawVertices(JNIEnv* env, jobject, jlong canvasHandle,
indices, indexCount, *paint);
}
-static void drawBitmap(JNIEnv* env, jobject jcanvas, jlong canvasHandle, jlong bitmapHandle,
+static void drawBitmap(JNIEnv* env, jobject jcanvas, jlong canvasHandle, jobject jbitmap,
jfloat left, jfloat top, jlong paintHandle, jint canvasDensity,
jint screenDensity, jint bitmapDensity) {
Canvas* canvas = get_canvas(canvasHandle);
- const SkBitmap* bitmap = reinterpret_cast<SkBitmap*>(bitmapHandle);
+ SkBitmap bitmap;
+ GraphicsJNI::getSkBitmap(env, jbitmap, &bitmap);
const Paint* paint = reinterpret_cast<Paint*>(paintHandle);
if (canvasDensity == bitmapDensity || canvasDensity == 0 || bitmapDensity == 0) {
@@ -332,9 +333,9 @@ static void drawBitmap(JNIEnv* env, jobject jcanvas, jlong canvasHandle, jlong b
filteredPaint = *paint;
}
filteredPaint.setFilterQuality(kLow_SkFilterQuality);
- canvas->drawBitmap(*bitmap, left, top, &filteredPaint);
+ canvas->drawBitmap(bitmap, left, top, &filteredPaint);
} else {
- canvas->drawBitmap(*bitmap, left, top, paint);
+ canvas->drawBitmap(bitmap, left, top, paint);
}
} else {
canvas->save(SkCanvas::kMatrixClip_SaveFlag);
@@ -348,37 +349,39 @@ static void drawBitmap(JNIEnv* env, jobject jcanvas, jlong canvasHandle, jlong b
}
filteredPaint.setFilterQuality(kLow_SkFilterQuality);
- canvas->drawBitmap(*bitmap, 0, 0, &filteredPaint);
+ canvas->drawBitmap(bitmap, 0, 0, &filteredPaint);
canvas->restore();
}
}
-static void drawBitmapMatrix(JNIEnv* env, jobject, jlong canvasHandle, jlong bitmapHandle,
+static void drawBitmapMatrix(JNIEnv* env, jobject, jlong canvasHandle, jobject jbitmap,
jlong matrixHandle, jlong paintHandle) {
- const SkBitmap* bitmap = reinterpret_cast<SkBitmap*>(bitmapHandle);
const SkMatrix* matrix = reinterpret_cast<SkMatrix*>(matrixHandle);
const Paint* paint = reinterpret_cast<Paint*>(paintHandle);
- get_canvas(canvasHandle)->drawBitmap(*bitmap, *matrix, paint);
+ SkBitmap bitmap;
+ GraphicsJNI::getSkBitmap(env, jbitmap, &bitmap);
+ get_canvas(canvasHandle)->drawBitmap(bitmap, *matrix, paint);
}
-static void drawBitmapRect(JNIEnv* env, jobject, jlong canvasHandle, jlong bitmapHandle,
+static void drawBitmapRect(JNIEnv* env, jobject, jlong canvasHandle, jobject jbitmap,
float srcLeft, float srcTop, float srcRight, float srcBottom,
float dstLeft, float dstTop, float dstRight, float dstBottom,
jlong paintHandle, jint screenDensity, jint bitmapDensity) {
Canvas* canvas = get_canvas(canvasHandle);
- const SkBitmap* bitmap = reinterpret_cast<SkBitmap*>(bitmapHandle);
const Paint* paint = reinterpret_cast<Paint*>(paintHandle);
+ SkBitmap bitmap;
+ GraphicsJNI::getSkBitmap(env, jbitmap, &bitmap);
if (screenDensity != 0 && screenDensity != bitmapDensity) {
Paint filteredPaint;
if (paint) {
filteredPaint = *paint;
}
filteredPaint.setFilterQuality(kLow_SkFilterQuality);
- canvas->drawBitmap(*bitmap, srcLeft, srcTop, srcRight, srcBottom,
+ canvas->drawBitmap(bitmap, srcLeft, srcTop, srcRight, srcBottom,
dstLeft, dstTop, dstRight, dstBottom, &filteredPaint);
} else {
- canvas->drawBitmap(*bitmap, srcLeft, srcTop, srcRight, srcBottom,
+ canvas->drawBitmap(bitmap, srcLeft, srcTop, srcRight, srcBottom,
dstLeft, dstTop, dstRight, dstBottom, paint);
}
}
@@ -406,16 +409,17 @@ static void drawBitmapArray(JNIEnv* env, jobject, jlong canvasHandle,
get_canvas(canvasHandle)->drawBitmap(bitmap, x, y, paint);
}
-static void drawBitmapMesh(JNIEnv* env, jobject, jlong canvasHandle, jlong bitmapHandle,
+static void drawBitmapMesh(JNIEnv* env, jobject, jlong canvasHandle, jobject jbitmap,
jint meshWidth, jint meshHeight, jfloatArray jverts,
jint vertIndex, jintArray jcolors, jint colorIndex, jlong paintHandle) {
const int ptCount = (meshWidth + 1) * (meshHeight + 1);
AutoJavaFloatArray vertA(env, jverts, vertIndex + (ptCount << 1));
AutoJavaIntArray colorA(env, jcolors, colorIndex + ptCount);
- const SkBitmap* bitmap = reinterpret_cast<SkBitmap*>(bitmapHandle);
const Paint* paint = reinterpret_cast<Paint*>(paintHandle);
- get_canvas(canvasHandle)->drawBitmapMesh(*bitmap, meshWidth, meshHeight,
+ SkBitmap bitmap;
+ GraphicsJNI::getSkBitmap(env, jbitmap, &bitmap);
+ get_canvas(canvasHandle)->drawBitmapMesh(bitmap, meshWidth, meshHeight,
vertA.ptr(), colorA.ptr(), paint);
}
@@ -700,11 +704,11 @@ static JNINativeMethod gMethods[] = {
{"native_drawArc","(JFFFFFFZJ)V", (void*) CanvasJNI::drawArc},
{"native_drawPath","(JJJ)V", (void*) CanvasJNI::drawPath},
{"nativeDrawVertices", "(JII[FI[FI[II[SIIJ)V", (void*)CanvasJNI::drawVertices},
- {"native_drawBitmap","(JJFFJIII)V", (void*) CanvasJNI::drawBitmap},
- {"nativeDrawBitmapMatrix", "(JJJJ)V", (void*)CanvasJNI::drawBitmapMatrix},
- {"native_drawBitmap","(JJFFFFFFFFJII)V", (void*) CanvasJNI::drawBitmapRect},
+ {"native_drawBitmap","(JLandroid/graphics/Bitmap;FFJIII)V", (void*) CanvasJNI::drawBitmap},
+ {"nativeDrawBitmapMatrix", "(JLandroid/graphics/Bitmap;JJ)V", (void*)CanvasJNI::drawBitmapMatrix},
+ {"native_drawBitmap","(JLandroid/graphics/Bitmap;FFFFFFFFJII)V", (void*) CanvasJNI::drawBitmapRect},
{"native_drawBitmap", "(J[IIIFFIIZJ)V", (void*)CanvasJNI::drawBitmapArray},
- {"nativeDrawBitmapMesh", "(JJII[FI[IIJ)V", (void*)CanvasJNI::drawBitmapMesh},
+ {"nativeDrawBitmapMesh", "(JLandroid/graphics/Bitmap;II[FI[IIJ)V", (void*)CanvasJNI::drawBitmapMesh},
{"native_drawText","(J[CIIFFIJJ)V", (void*) CanvasJNI::drawTextChars},
{"native_drawText","(JLjava/lang/String;IIFFIJJ)V", (void*) CanvasJNI::drawTextString},
{"native_drawTextRun","(J[CIIIIFFZJJ)V", (void*) CanvasJNI::drawTextRunChars},
diff --git a/core/jni/android_view_DisplayListCanvas.cpp b/core/jni/android_view_DisplayListCanvas.cpp
index a362684..39449b0 100644
--- a/core/jni/android_view_DisplayListCanvas.cpp
+++ b/core/jni/android_view_DisplayListCanvas.cpp
@@ -132,10 +132,10 @@ static jint android_view_DisplayListCanvas_getMaxTextureHeight(JNIEnv* env, jobj
// ----------------------------------------------------------------------------
static void android_view_DisplayListCanvas_drawPatch(JNIEnv* env, jobject clazz,
- jlong rendererPtr, jlong bitmapPtr, jlong patchPtr,
+ jlong rendererPtr, jobject jbitmap, jlong patchPtr,
float left, float top, float right, float bottom, jlong paintPtr) {
- SkBitmap* bitmap = reinterpret_cast<SkBitmap*>(bitmapPtr);
-
+ SkBitmap bitmap;
+ GraphicsJNI::getSkBitmap(env, jbitmap, &bitmap);
DisplayListCanvas* renderer = reinterpret_cast<DisplayListCanvas*>(rendererPtr);
Res_png_9patch* patch = reinterpret_cast<Res_png_9patch*>(patchPtr);
Paint* paint = reinterpret_cast<Paint*>(paintPtr);
@@ -273,7 +273,7 @@ static JNINativeMethod gMethods[] = {
{ "nCallDrawGLFunction", "(JJ)V", (void*) android_view_DisplayListCanvas_callDrawGLFunction },
- { "nDrawPatch", "(JJJFFFFJ)V", (void*) android_view_DisplayListCanvas_drawPatch },
+ { "nDrawPatch", "(JLandroid/graphics/Bitmap;JFFFFJ)V", (void*) android_view_DisplayListCanvas_drawPatch },
{ "nDrawRects", "(JJJ)V", (void*) android_view_DisplayListCanvas_drawRegionAsRects },
{ "nDrawRoundRect", "(JJJJJJJJ)V", (void*) android_view_DisplayListCanvas_drawRoundRectProps },