GLSurfaceView: remove old implementation, import the one from AOSP

Now that we have a reasonably well working SurfaceView implementation,
it is actually cleaner to just implement GLSurfaceView the way AOSP
does. In fact, their code doesn't have any weird dependencies, and
can mostly be used as-is.

The AOSP code is pure Java, which means we had to implement some
EGL wrappers.

This change fixes issues with Wayland (it only ever worked because
the pbuffers were allocated using an XWayland EGLDisplay), and
with resizing (which we simply didn't support), all while getting
rid of quite some (arguably not very readable) LoC.
This commit is contained in:
Mis012
2023-10-20 20:54:37 +02:00
parent 621cb866c1
commit 9ef2151c5e
19 changed files with 2140 additions and 879 deletions

View File

@@ -468,21 +468,28 @@ EGLDisplay bionic_eglGetDisplay(NativeDisplayType native_display)
}
}
EGLSurface egl_surface_hashtable;
EGLSurface bionic_eglCreateWindowSurface(EGLDisplay display, EGLConfig config, struct ANativeWindow *native_window, EGLint const *attrib_list)
{
// better than crashing (TODO: check if apps try to use the NULL value anyway)
if(!native_window)
return NULL;
if(!egl_surface_hashtable)
egl_surface_hashtable = g_hash_table_new(NULL, NULL);
PrintConfigAttributes(display, config);
EGLSurface ret = eglCreateWindowSurface(display, config, native_window->egl_window, attrib_list);
EGLSurface surface = eglCreateWindowSurface(display, config, native_window->egl_window, attrib_list);
printf("EGL::: native_window->egl_window: %ld\n", native_window->egl_window);
printf("EGL::: eglGetError: %d\n", eglGetError());
printf("EGL::: ret: %p\n", ret);
printf("EGL::: ret: %p\n", surface);
return ret;
g_hash_table_insert(egl_surface_hashtable, surface, native_window);
return surface;
}
// FIXME 1.5: this most likely belongs elsewhere

View File

@@ -14,4 +14,9 @@ struct ANativeWindow {
int refcount;
};
extern EGLSurface egl_surface_hashtable;
struct ANativeWindow *ANativeWindow_fromSurface(JNIEnv* env, jobject surface);
EGLSurface bionic_eglCreateWindowSurface(EGLDisplay display, EGLConfig config, struct ANativeWindow *native_window, EGLint const *attrib_list);
EGLDisplay bionic_eglGetDisplay(NativeDisplayType native_display);
void ANativeWindow_release(struct ANativeWindow *native_window);