diff options
author | Jason Sams <rjsams@android.com> | 2010-03-01 15:31:04 -0800 |
---|---|---|
committer | Jason Sams <rjsams@android.com> | 2010-03-01 15:31:04 -0800 |
commit | 8a64743f37ed35af7c2204acd18bb3d62d8f66d5 (patch) | |
tree | 13222fdd1021b6af52f78d1d3576b0139b724ee1 /graphics/jni | |
parent | c2908e60c9b021fb4bb69acff8d49981dd4dade8 (diff) | |
download | frameworks_base-8a64743f37ed35af7c2204acd18bb3d62d8f66d5.zip frameworks_base-8a64743f37ed35af7c2204acd18bb3d62d8f66d5.tar.gz frameworks_base-8a64743f37ed35af7c2204acd18bb3d62d8f66d5.tar.bz2 |
Add support for linking to a skia bitmap rather than always copying the data from the bitmap.
Diffstat (limited to 'graphics/jni')
-rw-r--r-- | graphics/jni/android_renderscript_RenderScript.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/graphics/jni/android_renderscript_RenderScript.cpp b/graphics/jni/android_renderscript_RenderScript.cpp index cb5a00e..d8e0393 100644 --- a/graphics/jni/android_renderscript_RenderScript.cpp +++ b/graphics/jni/android_renderscript_RenderScript.cpp @@ -501,6 +501,26 @@ nAllocationCreateFromBitmap(JNIEnv *_env, jobject _this, jint dstFmt, jboolean g return 0; } +static void ReleaseBitmapCallback(void *bmp) +{ + SkBitmap const * nativeBitmap = (SkBitmap const *)bmp; + nativeBitmap->unlockPixels(); +} + +static int +nAllocationCreateBitmapRef(JNIEnv *_env, jobject _this, jint type, jobject jbitmap) +{ + RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); + SkBitmap * nativeBitmap = + (SkBitmap *)_env->GetIntField(jbitmap, gNativeBitmapID); + + + nativeBitmap->lockPixels(); + void* ptr = nativeBitmap->getPixels(); + jint id = (jint)rsAllocationCreateBitmapRef(con, (RsType)type, ptr, nativeBitmap, ReleaseBitmapCallback); + return id; +} + static int nAllocationCreateFromAssetStream(JNIEnv *_env, jobject _this, jint dstFmt, jboolean genMips, jint native_asset) { @@ -1367,6 +1387,7 @@ static JNINativeMethod methods[] = { {"nAllocationCreateTyped", "(I)I", (void*)nAllocationCreateTyped }, {"nAllocationCreateFromBitmap", "(IZLandroid/graphics/Bitmap;)I", (void*)nAllocationCreateFromBitmap }, +{"nAllocationCreateBitmapRef", "(ILandroid/graphics/Bitmap;)I", (void*)nAllocationCreateBitmapRef }, {"nAllocationCreateFromBitmapBoxed","(IZLandroid/graphics/Bitmap;)I", (void*)nAllocationCreateFromBitmapBoxed }, {"nAllocationCreateFromAssetStream","(IZI)I", (void*)nAllocationCreateFromAssetStream }, {"nAllocationUploadToTexture", "(IZI)V", (void*)nAllocationUploadToTexture }, |