diff options
author | Tim Murray <timmurray@google.com> | 2012-12-04 17:59:29 -0800 |
---|---|---|
committer | Tim Murray <timmurray@google.com> | 2012-12-04 18:27:07 -0800 |
commit | a314551d69098537337c970da615a8f8af58e1f1 (patch) | |
tree | 608b65ccb3d7f5324d57c907c7a80fec46faddc6 /graphics/jni | |
parent | 43cdf6d6795424e93ef232570ab8bbd9ae912041 (diff) | |
download | frameworks_base-a314551d69098537337c970da615a8f8af58e1f1.zip frameworks_base-a314551d69098537337c970da615a8f8af58e1f1.tar.gz frameworks_base-a314551d69098537337c970da615a8f8af58e1f1.tar.bz2 |
Add support for Bitmap-backed Allocations in Java.
Change-Id: Iab38a275aa6cdac91c76fa0d134fbc1e8f387913
Bug: 7256604
Diffstat (limited to 'graphics/jni')
-rw-r--r-- | graphics/jni/android_renderscript_RenderScript.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/graphics/jni/android_renderscript_RenderScript.cpp b/graphics/jni/android_renderscript_RenderScript.cpp index eddd3c0..b320e4b 100644 --- a/graphics/jni/android_renderscript_RenderScript.cpp +++ b/graphics/jni/android_renderscript_RenderScript.cpp @@ -539,6 +539,22 @@ nAllocationCreateFromBitmap(JNIEnv *_env, jobject _this, RsContext con, jint typ } static int +nAllocationCreateBitmapBackedAllocation(JNIEnv *_env, jobject _this, RsContext con, jint type, jint mip, jobject jbitmap, jint usage) +{ + SkBitmap const * nativeBitmap = + (SkBitmap const *)_env->GetIntField(jbitmap, gNativeBitmapID); + const SkBitmap& bitmap(*nativeBitmap); + + bitmap.lockPixels(); + const void* ptr = bitmap.getPixels(); + jint id = (jint)rsAllocationCreateTyped(con, + (RsType)type, (RsAllocationMipmapControl)mip, + (uint32_t)usage, (size_t)ptr); + bitmap.unlockPixels(); + return id; +} + +static int nAllocationCubeCreateFromBitmap(JNIEnv *_env, jobject _this, RsContext con, jint type, jint mip, jobject jbitmap, jint usage) { SkBitmap const * nativeBitmap = @@ -1443,6 +1459,7 @@ static JNINativeMethod methods[] = { {"rsnAllocationCreateTyped", "(IIIII)I", (void*)nAllocationCreateTyped }, {"rsnAllocationCreateFromBitmap", "(IIILandroid/graphics/Bitmap;I)I", (void*)nAllocationCreateFromBitmap }, +{"rsnAllocationCreateBitmapBackedAllocation", "(IIILandroid/graphics/Bitmap;I)I", (void*)nAllocationCreateBitmapBackedAllocation }, {"rsnAllocationCubeCreateFromBitmap","(IIILandroid/graphics/Bitmap;I)I", (void*)nAllocationCubeCreateFromBitmap }, {"rsnAllocationCopyFromBitmap", "(IILandroid/graphics/Bitmap;)V", (void*)nAllocationCopyFromBitmap }, |