summaryrefslogtreecommitdiffstats
path: root/core/jni
diff options
context:
space:
mode:
authorRomain Guy <romainguy@google.com>2012-05-14 19:44:40 -0700
committerRomain Guy <romainguy@google.com>2012-05-14 19:44:40 -0700
commite651cc6239616a202f6e96ebc2ed93b4b8b3627c (patch)
tree7aa90f8cccc91555bd652d0a88a898a026cdc333 /core/jni
parent99a6ddd4cd8762654a575eb4ac3d0e5431d919b8 (diff)
downloadframeworks_base-e651cc6239616a202f6e96ebc2ed93b4b8b3627c.zip
frameworks_base-e651cc6239616a202f6e96ebc2ed93b4b8b3627c.tar.gz
frameworks_base-e651cc6239616a202f6e96ebc2ed93b4b8b3627c.tar.bz2
Remove all Dalvik allocations from Cavnas.drawBitmap(int[], ...)
Change-Id: Ie28538a2104d21154fdc78a56525e7403f08287d
Diffstat (limited to 'core/jni')
-rw-r--r--core/jni/android_view_GLES20Canvas.cpp23
1 files changed, 21 insertions, 2 deletions
diff --git a/core/jni/android_view_GLES20Canvas.cpp b/core/jni/android_view_GLES20Canvas.cpp
index 60929ac..d8ec656 100644
--- a/core/jni/android_view_GLES20Canvas.cpp
+++ b/core/jni/android_view_GLES20Canvas.cpp
@@ -326,8 +326,8 @@ static void android_view_GLES20Canvas_concatMatrix(JNIEnv* env, jobject clazz,
// ----------------------------------------------------------------------------
static void android_view_GLES20Canvas_drawBitmap(JNIEnv* env, jobject clazz,
- OpenGLRenderer* renderer, SkBitmap* bitmap, jbyteArray buffer, float left,
- float top, SkPaint* paint) {
+ OpenGLRenderer* renderer, SkBitmap* bitmap, jbyteArray buffer,
+ jfloat left, jfloat top, SkPaint* paint) {
// This object allows the renderer to allocate a global JNI ref to the buffer object.
JavaHeapBitmapRef bitmapRef(env, bitmap, buffer);
@@ -354,6 +354,24 @@ static void android_view_GLES20Canvas_drawBitmapMatrix(JNIEnv* env, jobject claz
renderer->drawBitmap(bitmap, matrix, paint);
}
+static void android_view_GLES20Canvas_drawBitmapData(JNIEnv* env, jobject clazz,
+ OpenGLRenderer* renderer, jintArray colors, jint offset, jint stride,
+ jfloat left, jfloat top, jint width, jint height, jboolean hasAlpha, SkPaint* paint) {
+ SkBitmap bitmap;
+ SkBitmap::Config config = hasAlpha ? SkBitmap::kARGB_8888_Config : SkBitmap::kRGB_565_Config;
+ bitmap.setConfig(config, width, height);
+
+ if (!bitmap.allocPixels()) {
+ return;
+ }
+
+ if (!GraphicsJNI::SetPixels(env, colors, offset, stride, 0, 0, width, height, bitmap)) {
+ return;
+ }
+
+ renderer->drawBitmapData(&bitmap, left, top, paint);
+}
+
static void android_view_GLES20Canvas_drawBitmapMesh(JNIEnv* env, jobject clazz,
OpenGLRenderer* renderer, SkBitmap* bitmap, jbyteArray buffer,
jint meshWidth, jint meshHeight, jfloatArray vertices, jint offset,
@@ -880,6 +898,7 @@ static JNINativeMethod gMethods[] = {
{ "nDrawBitmap", "(II[BFFI)V", (void*) android_view_GLES20Canvas_drawBitmap },
{ "nDrawBitmap", "(II[BFFFFFFFFI)V",(void*) android_view_GLES20Canvas_drawBitmapRect },
{ "nDrawBitmap", "(II[BII)V", (void*) android_view_GLES20Canvas_drawBitmapMatrix },
+ { "nDrawBitmap", "(I[IIIFFIIZI)V", (void*) android_view_GLES20Canvas_drawBitmapData },
{ "nDrawBitmapMesh", "(II[BII[FI[III)V",(void*) android_view_GLES20Canvas_drawBitmapMesh },