diff options
Diffstat (limited to 'core/jni/android/opengl/util.cpp')
-rw-r--r-- | core/jni/android/opengl/util.cpp | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/core/jni/android/opengl/util.cpp b/core/jni/android/opengl/util.cpp index 5c2d0d0..461507f 100644 --- a/core/jni/android/opengl/util.cpp +++ b/core/jni/android/opengl/util.cpp @@ -16,7 +16,6 @@ #include "jni.h" #include "JNIHelp.h" -#include "GraphicsJNI.h" #include <math.h> #include <stdio.h> @@ -150,6 +149,10 @@ int visibilityTest(float* pWS, float* pPositions, int positionsLength, return result; } +static void doThrowIAE(JNIEnv* env, const char* msg) { + jniThrowException(env, "java/lang/IllegalArgumentException", msg); +} + template<class JArray, class T> class ArrayHelper { public: @@ -545,6 +548,14 @@ void util_multiplyMV(JNIEnv *env, jclass clazz, // --------------------------------------------------------------------------- +static jfieldID nativeBitmapID = 0; + +void nativeUtilsClassInit(JNIEnv *env, jclass clazz) +{ + jclass bitmapClass = env->FindClass("android/graphics/Bitmap"); + nativeBitmapID = env->GetFieldID(bitmapClass, "mNativeBitmap", "J"); +} + extern void setGLDebugLevel(int level); void setTracingLevel(JNIEnv *env, jclass clazz, jint level) { @@ -618,14 +629,16 @@ static int getType(SkColorType colorType) static jint util_getInternalFormat(JNIEnv *env, jclass clazz, jobject jbitmap) { - SkBitmap const * nativeBitmap = GraphicsJNI::getSkBitmap(env, jbitmap); + SkBitmap const * nativeBitmap = + (SkBitmap const *)env->GetLongField(jbitmap, nativeBitmapID); return getInternalFormat(nativeBitmap->colorType()); } static jint util_getType(JNIEnv *env, jclass clazz, jobject jbitmap) { - SkBitmap const * nativeBitmap = GraphicsJNI::getSkBitmap(env, jbitmap); + SkBitmap const * nativeBitmap = + (SkBitmap const *)env->GetLongField(jbitmap, nativeBitmapID); return getType(nativeBitmap->colorType()); } @@ -633,7 +646,8 @@ static jint util_texImage2D(JNIEnv *env, jclass clazz, jint target, jint level, jint internalformat, jobject jbitmap, jint type, jint border) { - SkBitmap const * nativeBitmap = GraphicsJNI::getSkBitmap(env, jbitmap); + SkBitmap const * nativeBitmap = + (SkBitmap const *)env->GetLongField(jbitmap, nativeBitmapID); const SkBitmap& bitmap(*nativeBitmap); SkColorType colorType = bitmap.colorType(); if (internalformat < 0) { @@ -680,7 +694,8 @@ static jint util_texSubImage2D(JNIEnv *env, jclass clazz, jint target, jint level, jint xoffset, jint yoffset, jobject jbitmap, jint format, jint type) { - SkBitmap const * nativeBitmap = GraphicsJNI::getSkBitmap(env, jbitmap); + SkBitmap const * nativeBitmap = + (SkBitmap const *)env->GetLongField(jbitmap, nativeBitmapID); const SkBitmap& bitmap(*nativeBitmap); SkColorType colorType = bitmap.colorType(); if (format < 0) { @@ -999,6 +1014,7 @@ static JNINativeMethod gVisibilityMethods[] = { }; 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 }, |