diff options
author | Jason Sams <rjsams@android.com> | 2009-07-28 12:02:16 -0700 |
---|---|---|
committer | Jason Sams <rjsams@android.com> | 2009-07-28 12:02:16 -0700 |
commit | b0ec1b46d6f5b5612e33fe43a828abea79b87a00 (patch) | |
tree | 3bf6193634273ec0cbf2e6a024f8afb315fb2f61 /graphics/jni | |
parent | 8af858e9b6577d074c5427e601b6418d288fdb9d (diff) | |
download | frameworks_base-b0ec1b46d6f5b5612e33fe43a828abea79b87a00.zip frameworks_base-b0ec1b46d6f5b5612e33fe43a828abea79b87a00.tar.gz frameworks_base-b0ec1b46d6f5b5612e33fe43a828abea79b87a00.tar.bz2 |
Add "boxed" bitmap uploads which simply place a non-pow2 bitmap into the smallest larger pow texture. The added space is filled black.
Diffstat (limited to 'graphics/jni')
-rw-r--r-- | graphics/jni/android_renderscript_RenderScript.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/graphics/jni/android_renderscript_RenderScript.cpp b/graphics/jni/android_renderscript_RenderScript.cpp index 573610c..6f781a0 100644 --- a/graphics/jni/android_renderscript_RenderScript.cpp +++ b/graphics/jni/android_renderscript_RenderScript.cpp @@ -291,6 +291,29 @@ nAllocationCreateFromBitmap(JNIEnv *_env, jobject _this, jint dstFmt, jboolean g return 0; } +static int +nAllocationCreateFromBitmapBoxed(JNIEnv *_env, jobject _this, jint dstFmt, jboolean genMips, jobject jbitmap) +{ + RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); + SkBitmap const * nativeBitmap = + (SkBitmap const *)_env->GetIntField(jbitmap, gNativeBitmapID); + const SkBitmap& bitmap(*nativeBitmap); + SkBitmap::Config config = bitmap.getConfig(); + + RsElementPredefined e = SkBitmapToPredefined(config); + + if (e != RS_ELEMENT_USER_U8) { + bitmap.lockPixels(); + const int w = bitmap.width(); + const int h = bitmap.height(); + const void* ptr = bitmap.getPixels(); + jint id = (jint)rsAllocationCreateFromBitmapBoxed(w, h, (RsElementPredefined)dstFmt, e, genMips, ptr); + bitmap.unlockPixels(); + return id; + } + return 0; +} + static void nAllocationDestroy(JNIEnv *_env, jobject _this, jint a) @@ -994,6 +1017,7 @@ static JNINativeMethod methods[] = { {"nAllocationCreatePredefSized", "(II)I", (void*)nAllocationCreatePredefSized }, {"nAllocationCreateSized", "(II)I", (void*)nAllocationCreateSized }, {"nAllocationCreateFromBitmap", "(IZLandroid/graphics/Bitmap;)I", (void*)nAllocationCreateFromBitmap }, +{"nAllocationCreateFromBitmapBoxed","(IZLandroid/graphics/Bitmap;)I", (void*)nAllocationCreateFromBitmapBoxed }, {"nAllocationUploadToTexture", "(II)V", (void*)nAllocationUploadToTexture }, {"nAllocationDestroy", "(I)V", (void*)nAllocationDestroy }, {"nAllocationData", "(I[I)V", (void*)nAllocationData_i }, |