Merge "Use long to store pointers in GLES_JNI/EGL classes"

This commit is contained in:
Narayan Kamath
2014-02-11 15:39:04 +00:00
committed by Gerrit Code Review
6 changed files with 113 additions and 90 deletions

View File

@@ -50,36 +50,41 @@ static jfieldID gBitmap_NativeBitmapFieldID;
static inline EGLDisplay getDisplay(JNIEnv* env, jobject o) { static inline EGLDisplay getDisplay(JNIEnv* env, jobject o) {
if (!o) return EGL_NO_DISPLAY; if (!o) return EGL_NO_DISPLAY;
return (EGLDisplay)env->GetIntField(o, gDisplay_EGLDisplayFieldID); return (EGLDisplay)env->GetLongField(o, gDisplay_EGLDisplayFieldID);
} }
static inline EGLSurface getSurface(JNIEnv* env, jobject o) { static inline EGLSurface getSurface(JNIEnv* env, jobject o) {
if (!o) return EGL_NO_SURFACE; if (!o) return EGL_NO_SURFACE;
return (EGLSurface)env->GetIntField(o, gSurface_EGLSurfaceFieldID); return (EGLSurface)env->GetLongField(o, gSurface_EGLSurfaceFieldID);
} }
static inline EGLContext getContext(JNIEnv* env, jobject o) { static inline EGLContext getContext(JNIEnv* env, jobject o) {
if (!o) return EGL_NO_CONTEXT; if (!o) return EGL_NO_CONTEXT;
return (EGLContext)env->GetIntField(o, gContext_EGLContextFieldID); return (EGLContext)env->GetLongField(o, gContext_EGLContextFieldID);
} }
static inline EGLConfig getConfig(JNIEnv* env, jobject o) { static inline EGLConfig getConfig(JNIEnv* env, jobject o) {
if (!o) return 0; if (!o) return 0;
return (EGLConfig)env->GetIntField(o, gConfig_EGLConfigFieldID); return (EGLConfig)env->GetLongField(o, gConfig_EGLConfigFieldID);
} }
static inline jboolean EglBoolToJBool(EGLBoolean eglBool) {
return eglBool == EGL_TRUE ? JNI_TRUE : JNI_FALSE;
}
static void nativeClassInit(JNIEnv *_env, jclass eglImplClass) static void nativeClassInit(JNIEnv *_env, jclass eglImplClass)
{ {
jclass config_class = _env->FindClass("com/google/android/gles_jni/EGLConfigImpl"); jclass config_class = _env->FindClass("com/google/android/gles_jni/EGLConfigImpl");
gConfig_class = (jclass) _env->NewGlobalRef(config_class); gConfig_class = (jclass) _env->NewGlobalRef(config_class);
gConfig_ctorID = _env->GetMethodID(gConfig_class, "<init>", "(I)V"); gConfig_ctorID = _env->GetMethodID(gConfig_class, "<init>", "(J)V");
gConfig_EGLConfigFieldID = _env->GetFieldID(gConfig_class, "mEGLConfig", "I"); gConfig_EGLConfigFieldID = _env->GetFieldID(gConfig_class, "mEGLConfig", "J");
jclass display_class = _env->FindClass("com/google/android/gles_jni/EGLDisplayImpl"); jclass display_class = _env->FindClass("com/google/android/gles_jni/EGLDisplayImpl");
gDisplay_EGLDisplayFieldID = _env->GetFieldID(display_class, "mEGLDisplay", "I"); gDisplay_EGLDisplayFieldID = _env->GetFieldID(display_class, "mEGLDisplay", "J");
jclass context_class = _env->FindClass("com/google/android/gles_jni/EGLContextImpl"); jclass context_class = _env->FindClass("com/google/android/gles_jni/EGLContextImpl");
gContext_EGLContextFieldID = _env->GetFieldID(context_class, "mEGLContext", "I"); gContext_EGLContextFieldID = _env->GetFieldID(context_class, "mEGLContext", "J");
jclass surface_class = _env->FindClass("com/google/android/gles_jni/EGLSurfaceImpl"); jclass surface_class = _env->FindClass("com/google/android/gles_jni/EGLSurfaceImpl");
gSurface_EGLSurfaceFieldID = _env->GetFieldID(surface_class, "mEGLSurface", "I"); gSurface_EGLSurfaceFieldID = _env->GetFieldID(surface_class, "mEGLSurface", "J");
gSurface_NativePixelRefFieldID = _env->GetFieldID(surface_class, "mNativePixelRef", "I"); gSurface_NativePixelRefFieldID = _env->GetFieldID(surface_class, "mNativePixelRef", "J");
jclass bitmap_class = _env->FindClass("android/graphics/Bitmap"); jclass bitmap_class = _env->FindClass("android/graphics/Bitmap");
gBitmap_NativeBitmapFieldID = _env->GetFieldID(bitmap_class, "mNativeBitmap", "J"); gBitmap_NativeBitmapFieldID = _env->GetFieldID(bitmap_class, "mNativeBitmap", "J");
@@ -123,7 +128,7 @@ static jboolean jni_eglInitialize(JNIEnv *_env, jobject _this, jobject display,
} }
EGLDisplay dpy = getDisplay(_env, display); EGLDisplay dpy = getDisplay(_env, display);
jboolean success = eglInitialize(dpy, NULL, NULL); EGLBoolean success = eglInitialize(dpy, NULL, NULL);
if (success && major_minor) { if (success && major_minor) {
int len = _env->GetArrayLength(major_minor); int len = _env->GetArrayLength(major_minor);
if (len) { if (len) {
@@ -134,7 +139,7 @@ static jboolean jni_eglInitialize(JNIEnv *_env, jobject _this, jobject display,
_env->ReleasePrimitiveArrayCritical(major_minor, base, JNI_ABORT); _env->ReleasePrimitiveArrayCritical(major_minor, base, JNI_ABORT);
} }
} }
return success; return EglBoolToJBool(success);
} }
static jboolean jni_eglQueryContext(JNIEnv *_env, jobject _this, jobject display, static jboolean jni_eglQueryContext(JNIEnv *_env, jobject _this, jobject display,
@@ -146,14 +151,14 @@ static jboolean jni_eglQueryContext(JNIEnv *_env, jobject _this, jobject display
} }
EGLDisplay dpy = getDisplay(_env, display); EGLDisplay dpy = getDisplay(_env, display);
EGLContext ctx = getContext(_env, context); EGLContext ctx = getContext(_env, context);
jboolean success = JNI_FALSE; EGLBoolean success = EGL_FALSE;
int len = _env->GetArrayLength(value); int len = _env->GetArrayLength(value);
if (len) { if (len) {
jint* base = (jint *)_env->GetPrimitiveArrayCritical(value, (jboolean *)0); jint* base = (jint *)_env->GetPrimitiveArrayCritical(value, (jboolean *)0);
success = eglQueryContext(dpy, ctx, attribute, base); success = eglQueryContext(dpy, ctx, attribute, base);
_env->ReleasePrimitiveArrayCritical(value, base, JNI_ABORT); _env->ReleasePrimitiveArrayCritical(value, base, JNI_ABORT);
} }
return success; return EglBoolToJBool(success);
} }
static jboolean jni_eglQuerySurface(JNIEnv *_env, jobject _this, jobject display, static jboolean jni_eglQuerySurface(JNIEnv *_env, jobject _this, jobject display,
@@ -166,14 +171,14 @@ static jboolean jni_eglQuerySurface(JNIEnv *_env, jobject _this, jobject display
EGLDisplay dpy = getDisplay(_env, display); EGLDisplay dpy = getDisplay(_env, display);
EGLContext sur = getSurface(_env, surface); EGLContext sur = getSurface(_env, surface);
jboolean success = JNI_FALSE; EGLBoolean success = EGL_FALSE;
int len = _env->GetArrayLength(value); int len = _env->GetArrayLength(value);
if (len) { if (len) {
jint* base = (jint *)_env->GetPrimitiveArrayCritical(value, (jboolean *)0); jint* base = (jint *)_env->GetPrimitiveArrayCritical(value, (jboolean *)0);
success = eglQuerySurface(dpy, sur, attribute, base); success = eglQuerySurface(dpy, sur, attribute, base);
_env->ReleasePrimitiveArrayCritical(value, base, JNI_ABORT); _env->ReleasePrimitiveArrayCritical(value, base, JNI_ABORT);
} }
return success; return EglBoolToJBool(success);
} }
static jint jni_getInitCount(JNIEnv *_env, jobject _clazz, jobject display) { static jint jni_getInitCount(JNIEnv *_env, jobject _clazz, jobject display) {
@@ -183,7 +188,7 @@ static jint jni_getInitCount(JNIEnv *_env, jobject _clazz, jobject display) {
} }
static jboolean jni_eglReleaseThread(JNIEnv *_env, jobject _this) { static jboolean jni_eglReleaseThread(JNIEnv *_env, jobject _this) {
return eglReleaseThread(); return EglBoolToJBool(eglReleaseThread());
} }
static jboolean jni_eglChooseConfig(JNIEnv *_env, jobject _this, jobject display, static jboolean jni_eglChooseConfig(JNIEnv *_env, jobject _this, jobject display,
@@ -196,7 +201,7 @@ static jboolean jni_eglChooseConfig(JNIEnv *_env, jobject _this, jobject display
return JNI_FALSE; return JNI_FALSE;
} }
EGLDisplay dpy = getDisplay(_env, display); EGLDisplay dpy = getDisplay(_env, display);
jboolean success = JNI_FALSE; EGLBoolean success = EGL_FALSE;
if (configs == NULL) { if (configs == NULL) {
config_size = 0; config_size = 0;
@@ -214,14 +219,14 @@ static jboolean jni_eglChooseConfig(JNIEnv *_env, jobject _this, jobject display
if (success && configs!=NULL) { if (success && configs!=NULL) {
for (int i=0 ; i<num ; i++) { for (int i=0 ; i<num ; i++) {
jobject obj = _env->NewObject(gConfig_class, gConfig_ctorID, (jint)nativeConfigs[i]); jobject obj = _env->NewObject(gConfig_class, gConfig_ctorID, reinterpret_cast<jlong>(nativeConfigs[i]));
_env->SetObjectArrayElement(configs, i, obj); _env->SetObjectArrayElement(configs, i, obj);
} }
} }
return success; return EglBoolToJBool(success);
} }
static jint jni_eglCreateContext(JNIEnv *_env, jobject _this, jobject display, static jlong jni_eglCreateContext(JNIEnv *_env, jobject _this, jobject display,
jobject config, jobject share_context, jintArray attrib_list) { jobject config, jobject share_context, jintArray attrib_list) {
if (display == NULL || config == NULL || share_context == NULL if (display == NULL || config == NULL || share_context == NULL
|| !validAttribList(_env, attrib_list)) { || !validAttribList(_env, attrib_list)) {
@@ -234,10 +239,10 @@ static jint jni_eglCreateContext(JNIEnv *_env, jobject _this, jobject display,
jint* base = beginNativeAttribList(_env, attrib_list); jint* base = beginNativeAttribList(_env, attrib_list);
EGLContext ctx = eglCreateContext(dpy, cnf, shr, base); EGLContext ctx = eglCreateContext(dpy, cnf, shr, base);
endNativeAttributeList(_env, attrib_list, base); endNativeAttributeList(_env, attrib_list, base);
return (jint)ctx; return reinterpret_cast<jlong>(ctx);
} }
static jint jni_eglCreatePbufferSurface(JNIEnv *_env, jobject _this, jobject display, static jlong jni_eglCreatePbufferSurface(JNIEnv *_env, jobject _this, jobject display,
jobject config, jintArray attrib_list) { jobject config, jintArray attrib_list) {
if (display == NULL || config == NULL if (display == NULL || config == NULL
|| !validAttribList(_env, attrib_list)) { || !validAttribList(_env, attrib_list)) {
@@ -249,7 +254,7 @@ static jint jni_eglCreatePbufferSurface(JNIEnv *_env, jobject _this, jobject dis
jint* base = beginNativeAttribList(_env, attrib_list); jint* base = beginNativeAttribList(_env, attrib_list);
EGLSurface sur = eglCreatePbufferSurface(dpy, cnf, base); EGLSurface sur = eglCreatePbufferSurface(dpy, cnf, base);
endNativeAttributeList(_env, attrib_list, base); endNativeAttributeList(_env, attrib_list, base);
return (jint)sur; return reinterpret_cast<jlong>(sur);
} }
static PixelFormat convertPixelFormat(SkBitmap::Config format) static PixelFormat convertPixelFormat(SkBitmap::Config format)
@@ -300,15 +305,15 @@ static void jni_eglCreatePixmapSurface(JNIEnv *_env, jobject _this, jobject out_
endNativeAttributeList(_env, attrib_list, base); endNativeAttributeList(_env, attrib_list, base);
if (sur != EGL_NO_SURFACE) { if (sur != EGL_NO_SURFACE) {
_env->SetIntField(out_sur, gSurface_EGLSurfaceFieldID, (int)sur); _env->SetLongField(out_sur, gSurface_EGLSurfaceFieldID, reinterpret_cast<jlong>(sur));
_env->SetIntField(out_sur, gSurface_NativePixelRefFieldID, (int)ref); _env->SetLongField(out_sur, gSurface_NativePixelRefFieldID, reinterpret_cast<jlong>(ref));
} else { } else {
ref->unlockPixels(); ref->unlockPixels();
SkSafeUnref(ref); SkSafeUnref(ref);
} }
} }
static jint jni_eglCreateWindowSurface(JNIEnv *_env, jobject _this, jobject display, static jlong jni_eglCreateWindowSurface(JNIEnv *_env, jobject _this, jobject display,
jobject config, jobject native_window, jintArray attrib_list) { jobject config, jobject native_window, jintArray attrib_list) {
if (display == NULL || config == NULL if (display == NULL || config == NULL
|| !validAttribList(_env, attrib_list)) { || !validAttribList(_env, attrib_list)) {
@@ -332,15 +337,15 @@ not_valid_surface:
jint* base = beginNativeAttribList(_env, attrib_list); jint* base = beginNativeAttribList(_env, attrib_list);
EGLSurface sur = eglCreateWindowSurface(dpy, cnf, window.get(), base); EGLSurface sur = eglCreateWindowSurface(dpy, cnf, window.get(), base);
endNativeAttributeList(_env, attrib_list, base); endNativeAttributeList(_env, attrib_list, base);
return (jint)sur; return reinterpret_cast<jlong>(sur);
} }
static jint jni_eglCreateWindowSurfaceTexture(JNIEnv *_env, jobject _this, jobject display, static jlong jni_eglCreateWindowSurfaceTexture(JNIEnv *_env, jobject _this, jobject display,
jobject config, jobject native_window, jintArray attrib_list) { jobject config, jobject native_window, jintArray attrib_list) {
if (display == NULL || config == NULL if (display == NULL || config == NULL
|| !validAttribList(_env, attrib_list)) { || !validAttribList(_env, attrib_list)) {
jniThrowException(_env, "java/lang/IllegalArgumentException", NULL); jniThrowException(_env, "java/lang/IllegalArgumentException", NULL);
return JNI_FALSE; return 0;
} }
EGLDisplay dpy = getDisplay(_env, display); EGLDisplay dpy = getDisplay(_env, display);
EGLContext cnf = getConfig(_env, config); EGLContext cnf = getConfig(_env, config);
@@ -360,7 +365,7 @@ not_valid_surface:
jint* base = beginNativeAttribList(_env, attrib_list); jint* base = beginNativeAttribList(_env, attrib_list);
EGLSurface sur = eglCreateWindowSurface(dpy, cnf, window.get(), base); EGLSurface sur = eglCreateWindowSurface(dpy, cnf, window.get(), base);
endNativeAttributeList(_env, attrib_list, base); endNativeAttributeList(_env, attrib_list, base);
return (jint)sur; return reinterpret_cast<jlong>(sur);
} }
static jboolean jni_eglGetConfigAttrib(JNIEnv *_env, jobject _this, jobject display, static jboolean jni_eglGetConfigAttrib(JNIEnv *_env, jobject _this, jobject display,
@@ -372,13 +377,13 @@ static jboolean jni_eglGetConfigAttrib(JNIEnv *_env, jobject _this, jobject disp
} }
EGLDisplay dpy = getDisplay(_env, display); EGLDisplay dpy = getDisplay(_env, display);
EGLContext cnf = getConfig(_env, config); EGLContext cnf = getConfig(_env, config);
jboolean success = JNI_FALSE; EGLBoolean success = EGL_FALSE;
jint localValue; jint localValue;
success = eglGetConfigAttrib(dpy, cnf, attribute, &localValue); success = eglGetConfigAttrib(dpy, cnf, attribute, &localValue);
if (success) { if (success) {
_env->SetIntArrayRegion(value, 0, 1, &localValue); _env->SetIntArrayRegion(value, 0, 1, &localValue);
} }
return success; return EglBoolToJBool(success);
} }
static jboolean jni_eglGetConfigs(JNIEnv *_env, jobject _this, jobject display, static jboolean jni_eglGetConfigs(JNIEnv *_env, jobject _this, jobject display,
@@ -389,7 +394,7 @@ static jboolean jni_eglGetConfigs(JNIEnv *_env, jobject _this, jobject display,
return JNI_FALSE; return JNI_FALSE;
} }
EGLDisplay dpy = getDisplay(_env, display); EGLDisplay dpy = getDisplay(_env, display);
jboolean success = JNI_FALSE; EGLBoolean success = EGL_FALSE;
if (configs == NULL) { if (configs == NULL) {
config_size = 0; config_size = 0;
} }
@@ -401,11 +406,11 @@ static jboolean jni_eglGetConfigs(JNIEnv *_env, jobject _this, jobject display,
} }
if (success && configs) { if (success && configs) {
for (int i=0 ; i<num ; i++) { for (int i=0 ; i<num ; i++) {
jobject obj = _env->NewObject(gConfig_class, gConfig_ctorID, (jint)nativeConfigs[i]); jobject obj = _env->NewObject(gConfig_class, gConfig_ctorID, reinterpret_cast<jlong>(nativeConfigs[i]));
_env->SetObjectArrayElement(configs, i, obj); _env->SetObjectArrayElement(configs, i, obj);
} }
} }
return success; return EglBoolToJBool(success);
} }
static jint jni_eglGetError(JNIEnv *_env, jobject _this) { static jint jni_eglGetError(JNIEnv *_env, jobject _this) {
@@ -413,20 +418,20 @@ static jint jni_eglGetError(JNIEnv *_env, jobject _this) {
return error; return error;
} }
static jint jni_eglGetCurrentContext(JNIEnv *_env, jobject _this) { static jlong jni_eglGetCurrentContext(JNIEnv *_env, jobject _this) {
return (jint)eglGetCurrentContext(); return reinterpret_cast<jlong>(eglGetCurrentContext());
} }
static jint jni_eglGetCurrentDisplay(JNIEnv *_env, jobject _this) { static jlong jni_eglGetCurrentDisplay(JNIEnv *_env, jobject _this) {
return (jint)eglGetCurrentDisplay(); return reinterpret_cast<jlong>(eglGetCurrentDisplay());
} }
static jint jni_eglGetCurrentSurface(JNIEnv *_env, jobject _this, jint readdraw) { static jlong jni_eglGetCurrentSurface(JNIEnv *_env, jobject _this, jint readdraw) {
if ((readdraw != EGL_READ) && (readdraw != EGL_DRAW)) { if ((readdraw != EGL_READ) && (readdraw != EGL_DRAW)) {
jniThrowException(_env, "java/lang/IllegalArgumentException", NULL); jniThrowException(_env, "java/lang/IllegalArgumentException", NULL);
return 0; return 0;
} }
return (jint)eglGetCurrentSurface(readdraw); return reinterpret_cast<jlong>(eglGetCurrentSurface(readdraw));
} }
static jboolean jni_eglDestroyContext(JNIEnv *_env, jobject _this, jobject display, jobject context) { static jboolean jni_eglDestroyContext(JNIEnv *_env, jobject _this, jobject display, jobject context) {
@@ -436,7 +441,7 @@ static jboolean jni_eglDestroyContext(JNIEnv *_env, jobject _this, jobject displ
} }
EGLDisplay dpy = getDisplay(_env, display); EGLDisplay dpy = getDisplay(_env, display);
EGLContext ctx = getContext(_env, context); EGLContext ctx = getContext(_env, context);
return eglDestroyContext(dpy, ctx); return EglBoolToJBool(eglDestroyContext(dpy, ctx));
} }
static jboolean jni_eglDestroySurface(JNIEnv *_env, jobject _this, jobject display, jobject surface) { static jboolean jni_eglDestroySurface(JNIEnv *_env, jobject _this, jobject display, jobject surface) {
@@ -448,18 +453,18 @@ static jboolean jni_eglDestroySurface(JNIEnv *_env, jobject _this, jobject displ
EGLSurface sur = getSurface(_env, surface); EGLSurface sur = getSurface(_env, surface);
if (sur) { if (sur) {
SkPixelRef* ref = (SkPixelRef*)(_env->GetIntField(surface, SkPixelRef* ref = (SkPixelRef*)(_env->GetLongField(surface,
gSurface_NativePixelRefFieldID)); gSurface_NativePixelRefFieldID));
if (ref) { if (ref) {
ref->unlockPixels(); ref->unlockPixels();
SkSafeUnref(ref); SkSafeUnref(ref);
} }
} }
return eglDestroySurface(dpy, sur); return EglBoolToJBool(eglDestroySurface(dpy, sur));
} }
static jint jni_eglGetDisplay(JNIEnv *_env, jobject _this, jobject native_display) { static jlong jni_eglGetDisplay(JNIEnv *_env, jobject _this, jobject native_display) {
return (jint)eglGetDisplay(EGL_DEFAULT_DISPLAY); return reinterpret_cast<jlong>(eglGetDisplay(EGL_DEFAULT_DISPLAY));
} }
static jboolean jni_eglMakeCurrent(JNIEnv *_env, jobject _this, jobject display, jobject draw, jobject read, jobject context) { static jboolean jni_eglMakeCurrent(JNIEnv *_env, jobject _this, jobject display, jobject draw, jobject read, jobject context) {
@@ -471,7 +476,7 @@ static jboolean jni_eglMakeCurrent(JNIEnv *_env, jobject _this, jobject display,
EGLSurface sdr = getSurface(_env, draw); EGLSurface sdr = getSurface(_env, draw);
EGLSurface srd = getSurface(_env, read); EGLSurface srd = getSurface(_env, read);
EGLContext ctx = getContext(_env, context); EGLContext ctx = getContext(_env, context);
return eglMakeCurrent(dpy, sdr, srd, ctx); return EglBoolToJBool(eglMakeCurrent(dpy, sdr, srd, ctx));
} }
static jstring jni_eglQueryString(JNIEnv *_env, jobject _this, jobject display, jint name) { static jstring jni_eglQueryString(JNIEnv *_env, jobject _this, jobject display, jint name) {
@@ -491,7 +496,7 @@ static jboolean jni_eglSwapBuffers(JNIEnv *_env, jobject _this, jobject display,
} }
EGLDisplay dpy = getDisplay(_env, display); EGLDisplay dpy = getDisplay(_env, display);
EGLSurface sur = getSurface(_env, surface); EGLSurface sur = getSurface(_env, surface);
return eglSwapBuffers(dpy, sur); return EglBoolToJBool(eglSwapBuffers(dpy, sur));
} }
static jboolean jni_eglTerminate(JNIEnv *_env, jobject _this, jobject display) { static jboolean jni_eglTerminate(JNIEnv *_env, jobject _this, jobject display) {
@@ -500,7 +505,7 @@ static jboolean jni_eglTerminate(JNIEnv *_env, jobject _this, jobject display) {
return JNI_FALSE; return JNI_FALSE;
} }
EGLDisplay dpy = getDisplay(_env, display); EGLDisplay dpy = getDisplay(_env, display);
return eglTerminate(dpy); return EglBoolToJBool(eglTerminate(dpy));
} }
static jboolean jni_eglCopyBuffers(JNIEnv *_env, jobject _this, jobject display, static jboolean jni_eglCopyBuffers(JNIEnv *_env, jobject _this, jobject display,
@@ -514,11 +519,11 @@ static jboolean jni_eglCopyBuffers(JNIEnv *_env, jobject _this, jobject display,
} }
static jboolean jni_eglWaitGL(JNIEnv *_env, jobject _this) { static jboolean jni_eglWaitGL(JNIEnv *_env, jobject _this) {
return eglWaitGL(); return EglBoolToJBool(eglWaitGL());
} }
static jboolean jni_eglWaitNative(JNIEnv *_env, jobject _this, jint engine, jobject bindTarget) { static jboolean jni_eglWaitNative(JNIEnv *_env, jobject _this, jint engine, jobject bindTarget) {
return eglWaitNative(engine); return EglBoolToJBool(eglWaitNative(engine));
} }
@@ -540,21 +545,21 @@ static JNINativeMethod methods[] = {
{"eglReleaseThread","()Z", (void*)jni_eglReleaseThread }, {"eglReleaseThread","()Z", (void*)jni_eglReleaseThread },
{"getInitCount", "(" DISPLAY ")I", (void*)jni_getInitCount }, {"getInitCount", "(" DISPLAY ")I", (void*)jni_getInitCount },
{"eglChooseConfig", "(" DISPLAY "[I[" CONFIG "I[I)Z", (void*)jni_eglChooseConfig }, {"eglChooseConfig", "(" DISPLAY "[I[" CONFIG "I[I)Z", (void*)jni_eglChooseConfig },
{"_eglCreateContext","(" DISPLAY CONFIG CONTEXT "[I)I", (void*)jni_eglCreateContext }, {"_eglCreateContext","(" DISPLAY CONFIG CONTEXT "[I)J", (void*)jni_eglCreateContext },
{"eglGetConfigs", "(" DISPLAY "[" CONFIG "I[I)Z", (void*)jni_eglGetConfigs }, {"eglGetConfigs", "(" DISPLAY "[" CONFIG "I[I)Z", (void*)jni_eglGetConfigs },
{"eglTerminate", "(" DISPLAY ")Z", (void*)jni_eglTerminate }, {"eglTerminate", "(" DISPLAY ")Z", (void*)jni_eglTerminate },
{"eglCopyBuffers", "(" DISPLAY SURFACE OBJECT ")Z", (void*)jni_eglCopyBuffers }, {"eglCopyBuffers", "(" DISPLAY SURFACE OBJECT ")Z", (void*)jni_eglCopyBuffers },
{"eglWaitNative", "(I" OBJECT ")Z", (void*)jni_eglWaitNative }, {"eglWaitNative", "(I" OBJECT ")Z", (void*)jni_eglWaitNative },
{"eglGetError", "()I", (void*)jni_eglGetError }, {"eglGetError", "()I", (void*)jni_eglGetError },
{"eglGetConfigAttrib", "(" DISPLAY CONFIG "I[I)Z", (void*)jni_eglGetConfigAttrib }, {"eglGetConfigAttrib", "(" DISPLAY CONFIG "I[I)Z", (void*)jni_eglGetConfigAttrib },
{"_eglGetDisplay", "(" OBJECT ")I", (void*)jni_eglGetDisplay }, {"_eglGetDisplay", "(" OBJECT ")J", (void*)jni_eglGetDisplay },
{"_eglGetCurrentContext", "()I", (void*)jni_eglGetCurrentContext }, {"_eglGetCurrentContext", "()J", (void*)jni_eglGetCurrentContext },
{"_eglGetCurrentDisplay", "()I", (void*)jni_eglGetCurrentDisplay }, {"_eglGetCurrentDisplay", "()J", (void*)jni_eglGetCurrentDisplay },
{"_eglGetCurrentSurface", "(I)I", (void*)jni_eglGetCurrentSurface }, {"_eglGetCurrentSurface", "(I)J", (void*)jni_eglGetCurrentSurface },
{"_eglCreatePbufferSurface","(" DISPLAY CONFIG "[I)I", (void*)jni_eglCreatePbufferSurface }, {"_eglCreatePbufferSurface","(" DISPLAY CONFIG "[I)J", (void*)jni_eglCreatePbufferSurface },
{"_eglCreatePixmapSurface", "(" SURFACE DISPLAY CONFIG OBJECT "[I)V", (void*)jni_eglCreatePixmapSurface }, {"_eglCreatePixmapSurface", "(" SURFACE DISPLAY CONFIG OBJECT "[I)V", (void*)jni_eglCreatePixmapSurface },
{"_eglCreateWindowSurface", "(" DISPLAY CONFIG OBJECT "[I)I", (void*)jni_eglCreateWindowSurface }, {"_eglCreateWindowSurface", "(" DISPLAY CONFIG OBJECT "[I)J", (void*)jni_eglCreateWindowSurface },
{"_eglCreateWindowSurfaceTexture", "(" DISPLAY CONFIG OBJECT "[I)I", (void*)jni_eglCreateWindowSurfaceTexture }, {"_eglCreateWindowSurfaceTexture", "(" DISPLAY CONFIG OBJECT "[I)J", (void*)jni_eglCreateWindowSurfaceTexture },
{"eglDestroyContext", "(" DISPLAY CONTEXT ")Z", (void*)jni_eglDestroyContext }, {"eglDestroyContext", "(" DISPLAY CONTEXT ")Z", (void*)jni_eglDestroyContext },
{"eglDestroySurface", "(" DISPLAY SURFACE ")Z", (void*)jni_eglDestroySurface }, {"eglDestroySurface", "(" DISPLAY SURFACE ")Z", (void*)jni_eglDestroySurface },
{"eglMakeCurrent", "(" DISPLAY SURFACE SURFACE CONTEXT")Z", (void*)jni_eglMakeCurrent }, {"eglMakeCurrent", "(" DISPLAY SURFACE SURFACE CONTEXT")Z", (void*)jni_eglMakeCurrent },

View File

@@ -19,13 +19,13 @@ package com.google.android.gles_jni;
import javax.microedition.khronos.egl.*; import javax.microedition.khronos.egl.*;
public class EGLConfigImpl extends EGLConfig { public class EGLConfigImpl extends EGLConfig {
private int mEGLConfig; private long mEGLConfig;
EGLConfigImpl(int config) { EGLConfigImpl(long config) {
mEGLConfig = config; mEGLConfig = config;
} }
int get() { long get() {
return mEGLConfig; return mEGLConfig;
} }
} }

View File

@@ -21,13 +21,13 @@ import javax.microedition.khronos.opengles.GL;
public class EGLContextImpl extends EGLContext { public class EGLContextImpl extends EGLContext {
private GLImpl mGLContext; private GLImpl mGLContext;
int mEGLContext; long mEGLContext;
public EGLContextImpl(int ctx) { public EGLContextImpl(long ctx) {
mEGLContext = ctx; mEGLContext = ctx;
mGLContext = new GLImpl(); mGLContext = new GLImpl();
} }
@Override @Override
public GL getGL() { public GL getGL() {
return mGLContext; return mGLContext;
@@ -45,6 +45,12 @@ public class EGLContextImpl extends EGLContext {
@Override @Override
public int hashCode() { public int hashCode() {
return mEGLContext; /*
* Based on the algorithm suggested in
* http://developer.android.com/reference/java/lang/Object.html
*/
int result = 17;
result = 31 * result + (int) (mEGLContext ^ (mEGLContext >>> 32));
return result;
} }
} }

View File

@@ -19,9 +19,9 @@ package com.google.android.gles_jni;
import javax.microedition.khronos.egl.*; import javax.microedition.khronos.egl.*;
public class EGLDisplayImpl extends EGLDisplay { public class EGLDisplayImpl extends EGLDisplay {
int mEGLDisplay; long mEGLDisplay;
public EGLDisplayImpl(int dpy) { public EGLDisplayImpl(long dpy) {
mEGLDisplay = dpy; mEGLDisplay = dpy;
} }
@@ -38,6 +38,12 @@ public class EGLDisplayImpl extends EGLDisplay {
@Override @Override
public int hashCode() { public int hashCode() {
return mEGLDisplay; /*
* Based on the algorithm suggested in
* http://developer.android.com/reference/java/lang/Object.html
*/
int result = 17;
result = 31 * result + (int) (mEGLDisplay ^ (mEGLDisplay >>> 32));
return result;
} }
} }

View File

@@ -51,7 +51,7 @@ public class EGLImpl implements EGL10 {
public static native int getInitCount(EGLDisplay display); public static native int getInitCount(EGLDisplay display);
public EGLContext eglCreateContext(EGLDisplay display, EGLConfig config, EGLContext share_context, int[] attrib_list) { public EGLContext eglCreateContext(EGLDisplay display, EGLConfig config, EGLContext share_context, int[] attrib_list) {
int eglContextId = _eglCreateContext(display, config, share_context, attrib_list); long eglContextId = _eglCreateContext(display, config, share_context, attrib_list);
if (eglContextId == 0) { if (eglContextId == 0) {
return EGL10.EGL_NO_CONTEXT; return EGL10.EGL_NO_CONTEXT;
} }
@@ -59,7 +59,7 @@ public class EGLImpl implements EGL10 {
} }
public EGLSurface eglCreatePbufferSurface(EGLDisplay display, EGLConfig config, int[] attrib_list) { public EGLSurface eglCreatePbufferSurface(EGLDisplay display, EGLConfig config, int[] attrib_list) {
int eglSurfaceId = _eglCreatePbufferSurface(display, config, attrib_list); long eglSurfaceId = _eglCreatePbufferSurface(display, config, attrib_list);
if (eglSurfaceId == 0) { if (eglSurfaceId == 0) {
return EGL10.EGL_NO_SURFACE; return EGL10.EGL_NO_SURFACE;
} }
@@ -87,7 +87,7 @@ public class EGLImpl implements EGL10 {
sur = (Surface) native_window; sur = (Surface) native_window;
} }
int eglSurfaceId; long eglSurfaceId;
if (sur != null) { if (sur != null) {
eglSurfaceId = _eglCreateWindowSurface(display, config, sur, attrib_list); eglSurfaceId = _eglCreateWindowSurface(display, config, sur, attrib_list);
} else if (native_window instanceof SurfaceTexture) { } else if (native_window instanceof SurfaceTexture) {
@@ -106,7 +106,7 @@ public class EGLImpl implements EGL10 {
} }
public synchronized EGLDisplay eglGetDisplay(Object native_display) { public synchronized EGLDisplay eglGetDisplay(Object native_display) {
int value = _eglGetDisplay(native_display); long value = _eglGetDisplay(native_display);
if (value == 0) { if (value == 0) {
return EGL10.EGL_NO_DISPLAY; return EGL10.EGL_NO_DISPLAY;
} }
@@ -116,7 +116,7 @@ public class EGLImpl implements EGL10 {
} }
public synchronized EGLContext eglGetCurrentContext() { public synchronized EGLContext eglGetCurrentContext() {
int value = _eglGetCurrentContext(); long value = _eglGetCurrentContext();
if (value == 0) { if (value == 0) {
return EGL10.EGL_NO_CONTEXT; return EGL10.EGL_NO_CONTEXT;
} }
@@ -126,7 +126,7 @@ public class EGLImpl implements EGL10 {
} }
public synchronized EGLDisplay eglGetCurrentDisplay() { public synchronized EGLDisplay eglGetCurrentDisplay() {
int value = _eglGetCurrentDisplay(); long value = _eglGetCurrentDisplay();
if (value == 0) { if (value == 0) {
return EGL10.EGL_NO_DISPLAY; return EGL10.EGL_NO_DISPLAY;
} }
@@ -136,7 +136,7 @@ public class EGLImpl implements EGL10 {
} }
public synchronized EGLSurface eglGetCurrentSurface(int readdraw) { public synchronized EGLSurface eglGetCurrentSurface(int readdraw) {
int value = _eglGetCurrentSurface(readdraw); long value = _eglGetCurrentSurface(readdraw);
if (value == 0) { if (value == 0) {
return EGL10.EGL_NO_SURFACE; return EGL10.EGL_NO_SURFACE;
} }
@@ -145,15 +145,15 @@ public class EGLImpl implements EGL10 {
return mSurface; return mSurface;
} }
private native int _eglCreateContext(EGLDisplay display, EGLConfig config, EGLContext share_context, int[] attrib_list); private native long _eglCreateContext(EGLDisplay display, EGLConfig config, EGLContext share_context, int[] attrib_list);
private native int _eglCreatePbufferSurface(EGLDisplay display, EGLConfig config, int[] attrib_list); private native long _eglCreatePbufferSurface(EGLDisplay display, EGLConfig config, int[] attrib_list);
private native void _eglCreatePixmapSurface(EGLSurface sur, EGLDisplay display, EGLConfig config, Object native_pixmap, int[] attrib_list); private native void _eglCreatePixmapSurface(EGLSurface sur, EGLDisplay display, EGLConfig config, Object native_pixmap, int[] attrib_list);
private native int _eglCreateWindowSurface(EGLDisplay display, EGLConfig config, Object native_window, int[] attrib_list); private native long _eglCreateWindowSurface(EGLDisplay display, EGLConfig config, Object native_window, int[] attrib_list);
private native int _eglCreateWindowSurfaceTexture(EGLDisplay display, EGLConfig config, Object native_window, int[] attrib_list); private native long _eglCreateWindowSurfaceTexture(EGLDisplay display, EGLConfig config, Object native_window, int[] attrib_list);
private native int _eglGetDisplay(Object native_display); private native long _eglGetDisplay(Object native_display);
private native int _eglGetCurrentContext(); private native long _eglGetCurrentContext();
private native int _eglGetCurrentDisplay(); private native long _eglGetCurrentDisplay();
private native int _eglGetCurrentSurface(int readdraw); private native long _eglGetCurrentSurface(int readdraw);
native private static void _nativeClassInit(); native private static void _nativeClassInit();
static { _nativeClassInit(); } static { _nativeClassInit(); }

View File

@@ -19,13 +19,13 @@ package com.google.android.gles_jni;
import javax.microedition.khronos.egl.*; import javax.microedition.khronos.egl.*;
public class EGLSurfaceImpl extends EGLSurface { public class EGLSurfaceImpl extends EGLSurface {
int mEGLSurface; long mEGLSurface;
private int mNativePixelRef; private long mNativePixelRef;
public EGLSurfaceImpl() { public EGLSurfaceImpl() {
mEGLSurface = 0; mEGLSurface = 0;
mNativePixelRef = 0; mNativePixelRef = 0;
} }
public EGLSurfaceImpl(int surface) { public EGLSurfaceImpl(long surface) {
mEGLSurface = surface; mEGLSurface = surface;
mNativePixelRef = 0; mNativePixelRef = 0;
} }
@@ -43,6 +43,12 @@ public class EGLSurfaceImpl extends EGLSurface {
@Override @Override
public int hashCode() { public int hashCode() {
return mEGLSurface; /*
* Based on the algorithm suggested in
* http://developer.android.com/reference/java/lang/Object.html
*/
int result = 17;
result = 31 * result + (int) (mEGLSurface ^ (mEGLSurface >>> 32));
return result;
} }
} }