diff options
author | Jack Palevich <> | 2009-03-24 18:31:57 -0700 |
---|---|---|
committer | The Android Open Source Project <initial-contribution@android.com> | 2009-03-24 18:31:57 -0700 |
commit | c8405b6d02306d4cba4a169a4c24d7791dbaa0b4 (patch) | |
tree | f0685daf9db7063258560fb73d34aa33e7ca6c23 /core/jni | |
parent | 4ad62a4538a3845af7d88db381084699bb94b31b (diff) | |
download | frameworks_base-c8405b6d02306d4cba4a169a4c24d7791dbaa0b4.zip frameworks_base-c8405b6d02306d4cba4a169a4c24d7791dbaa0b4.tar.gz frameworks_base-c8405b6d02306d4cba4a169a4c24d7791dbaa0b4.tar.bz2 |
Automated import from //branches/cupcake/...@141857,141857
Diffstat (limited to 'core/jni')
-rw-r--r-- | core/jni/android/opengl/util.cpp | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/core/jni/android/opengl/util.cpp b/core/jni/android/opengl/util.cpp index a1059e5..41044db 100644 --- a/core/jni/android/opengl/util.cpp +++ b/core/jni/android/opengl/util.cpp @@ -599,6 +599,44 @@ static int getInternalFormat(SkBitmap::Config config) } } +static int getType(SkBitmap::Config config) +{ + switch(config) { + case SkBitmap::kA8_Config: + return GL_UNSIGNED_BYTE; + case SkBitmap::kARGB_4444_Config: + return GL_UNSIGNED_SHORT_4_4_4_4; + case SkBitmap::kARGB_8888_Config: + return GL_UNSIGNED_BYTE; + case SkBitmap::kIndex8_Config: + return -1; // No type for compressed data. + case SkBitmap::kRGB_565_Config: + return GL_UNSIGNED_SHORT_5_6_5; + default: + return -1; + } +} + +static jint util_getInternalFormat(JNIEnv *env, jclass clazz, + jobject jbitmap) +{ + SkBitmap const * nativeBitmap = + (SkBitmap const *)env->GetIntField(jbitmap, nativeBitmapID); + const SkBitmap& bitmap(*nativeBitmap); + SkBitmap::Config config = bitmap.getConfig(); + return getInternalFormat(config); +} + +static jint util_getType(JNIEnv *env, jclass clazz, + jobject jbitmap) +{ + SkBitmap const * nativeBitmap = + (SkBitmap const *)env->GetIntField(jbitmap, nativeBitmapID); + const SkBitmap& bitmap(*nativeBitmap); + SkBitmap::Config config = bitmap.getConfig(); + return getType(config); +} + static jint util_texImage2D(JNIEnv *env, jclass clazz, jint target, jint level, jint internalformat, jobject jbitmap, jint type, jint border) @@ -610,6 +648,9 @@ static jint util_texImage2D(JNIEnv *env, jclass clazz, if (internalformat < 0) { internalformat = getInternalFormat(config); } + if (type < 0) { + type = getType(config); + } int err = checkFormat(config, internalformat, type); if (err) return err; @@ -694,6 +735,8 @@ static JNINativeMethod gVisiblityMethods[] = { static JNINativeMethod gUtilsMethods[] = { {"nativeClassInit", "()V", (void*)nativeUtilsClassInit }, + { "native_getInternalFormat", "(Landroid/graphics/Bitmap;)I", (void*) util_getInternalFormat }, + { "native_getType", "(Landroid/graphics/Bitmap;)I", (void*) util_getType }, { "native_texImage2D", "(IIILandroid/graphics/Bitmap;II)I", (void*)util_texImage2D }, { "native_texSubImage2D", "(IIIILandroid/graphics/Bitmap;II)I", (void*)util_texSubImage2D }, }; |