EGLImpl: eglCreateContext: properly handle shared_context

This commit is contained in:
Mis012
2024-06-22 14:19:31 +02:00
parent 92e2c06347
commit da90302946
3 changed files with 25 additions and 25 deletions

View File

@@ -9,45 +9,45 @@
// helpers from android source (TODO: either use GetIntArrayElements, or figure out if GetPrimitiveArrayCritical is superior and use it everywhere if so)
static jint* get_int_array_crit(JNIEnv *env, jintArray array) {
if (array != NULL) {
return (jint *)(*env)->GetPrimitiveArrayCritical(env, array, (jboolean *)0);
} else {
return(jint*) NULL; // FIXME - do apps expect us to use some default?
}
if (array != NULL) {
return (jint *)(*env)->GetPrimitiveArrayCritical(env, array, (jboolean *)0);
} else {
return (jint *)NULL; // FIXME - do apps expect us to use some default?
}
}
static void release_int_array_crit(JNIEnv *env, jintArray array, jint* base) {
if (array != NULL) {
(*env)->ReleasePrimitiveArrayCritical(env, array, base, JNI_ABORT);
}
if (array != NULL) {
(*env)->ReleasePrimitiveArrayCritical(env, array, base, JNI_ABORT);
}
}
// ---
static jlong* get_long_array_crit(JNIEnv *env, jlongArray array) {
if (array != NULL) {
return (jlong *)(*env)->GetPrimitiveArrayCritical(env, array, (jboolean *)0);
} else {
return(jlong*) NULL; // FIXME - do apps expect us to use some default?
}
if (array != NULL) {
return (jlong *)(*env)->GetPrimitiveArrayCritical(env, array, (jboolean *)0);
} else {
return(jlong*) NULL; // FIXME - do apps expect us to use some default?
}
}
static void release_long_array_crit(JNIEnv *env, jlongArray array, jlong* base) {
if (array != NULL) {
(*env)->ReleasePrimitiveArrayCritical(env, array, base, JNI_ABORT);
}
if (array != NULL) {
(*env)->ReleasePrimitiveArrayCritical(env, array, base, JNI_ABORT);
}
}
JNIEXPORT jlong JNICALL Java_com_google_android_gles_1jni_EGLImpl_native_1eglCreateContext(JNIEnv *env, jobject this, jlong egl_display, jlong egl_config, jobject share_context, jintArray attrib_list)
JNIEXPORT jlong JNICALL Java_com_google_android_gles_1jni_EGLImpl_native_1eglCreateContext(JNIEnv *env, jobject this, jlong egl_display, jlong egl_config, jlong share_context, jintArray attrib_list)
{
printf("env: %p, this: %p, egl_display: %p, egl_config: %p, share_context: %p, attrib_list: %p\n", env, this, _PTR(egl_display), _PTR(egl_config), share_context, attrib_list);
printf("env: %p, this: %p, egl_display: %p, egl_config: %p, share_context: %p, attrib_list: %p\n", env, this, _PTR(egl_display), _PTR(egl_config), _PTR(share_context), attrib_list);
jint* attrib_base = get_int_array_crit(env, attrib_list);
jint *attrib_base = get_int_array_crit(env, attrib_list);
EGLContext egl_context = eglCreateContext(_PTR(egl_display), _PTR(egl_config), NULL, attrib_base);
EGLContext egl_context = eglCreateContext(_PTR(egl_display), _PTR(egl_config), _PTR(share_context), attrib_base);
printf("egl_context: %p\n", egl_context);
release_int_array_crit(env, attrib_list, attrib_base);
release_int_array_crit(env, attrib_list, attrib_base);
return _INTPTR(egl_context);
}

View File

@@ -10,10 +10,10 @@ extern "C" {
/*
* Class: com_google_android_gles_jni_EGLImpl
* Method: native_eglCreateContext
* Signature: (JJLjavax/microedition/khronos/egl/EGLContext;[I)J
* Signature: (JJJ[I)J
*/
JNIEXPORT jlong JNICALL Java_com_google_android_gles_1jni_EGLImpl_native_1eglCreateContext
(JNIEnv *, jobject, jlong, jlong, jobject, jintArray);
(JNIEnv *, jobject, jlong, jlong, jlong, jintArray);
/*
* Class: com_google_android_gles_jni_EGLImpl

View File

@@ -22,10 +22,10 @@ import android.view.SurfaceView;
import javax.microedition.khronos.egl.*;
public class EGLImpl implements EGL10 {
private native long native_eglCreateContext(long egl_display, long egl_config, EGLContext share_context, int[] attrib_list);
private native long native_eglCreateContext(long egl_display, long egl_config, long share_context, int[] attrib_list);
public EGLContext eglCreateContext(EGLDisplay display, EGLConfig config, EGLContext share_context, int[] attrib_list) {
long native_egl_context = native_eglCreateContext(display.native_egl_display, config.native_egl_config, share_context, attrib_list);
long native_egl_context = native_eglCreateContext(display.native_egl_display, config.native_egl_config, (share_context != null) ? share_context.native_egl_context : 0, attrib_list);
if (native_egl_context == 0) {
return EGL10.EGL_NO_CONTEXT;
}