From: Rémi Bernon rbernon@codeweavers.com
--- dlls/win32u/opengl.c | 4 ++++ dlls/wineandroid.drv/opengl.c | 15 ++++++--------- dlls/winewayland.drv/opengl.c | 14 ++++++-------- dlls/winex11.drv/opengl.c | 1 - include/wine/opengl_driver.h | 1 + 5 files changed, 17 insertions(+), 18 deletions(-)
diff --git a/dlls/win32u/opengl.c b/dlls/win32u/opengl.c index d7ebb386867..781b9df159d 100644 --- a/dlls/win32u/opengl.c +++ b/dlls/win32u/opengl.c @@ -243,11 +243,15 @@ void opengl_drawable_release( struct opengl_drawable *drawable )
if (!ref) { + const struct opengl_funcs *funcs = &display_funcs; + const struct egl_platform *egl = &display_egl; + pthread_mutex_lock( &drawables_lock ); opengl_drawable_detach( drawable ); pthread_mutex_unlock( &drawables_lock );
drawable->funcs->destroy( drawable ); + if (drawable->surface) funcs->p_eglDestroySurface( egl->display, drawable->surface ); free( drawable ); } } diff --git a/dlls/wineandroid.drv/opengl.c b/dlls/wineandroid.drv/opengl.c index c3c77b03170..6d4e67fb4e0 100644 --- a/dlls/wineandroid.drv/opengl.c +++ b/dlls/wineandroid.drv/opengl.c @@ -53,9 +53,7 @@ static const struct opengl_drawable_funcs android_drawable_funcs; struct gl_drawable { struct opengl_drawable base; - struct list entry; ANativeWindow *window; - EGLSurface surface; };
static struct gl_drawable *impl_from_opengl_drawable( struct opengl_drawable *base ) @@ -82,8 +80,8 @@ static struct gl_drawable *create_gl_drawable( HWND hwnd, HDC hdc, int format, A if (!window) gl->window = create_ioctl_window( hwnd, TRUE, 1.0f ); else gl->window = grab_ioctl_window( window );
- if (!window) gl->surface = funcs->p_eglCreatePbufferSurface( egl->display, egl_config_for_format(gl->base.format), attribs ); - else gl->surface = funcs->p_eglCreateWindowSurface( egl->display, egl_config_for_format(gl->base.format), gl->window, NULL ); + if (!window) gl->base.surface = funcs->p_eglCreatePbufferSurface( egl->display, egl_config_for_format(gl->base.format), attribs ); + else gl->base.surface = funcs->p_eglCreateWindowSurface( egl->display, egl_config_for_format(gl->base.format), gl->window, NULL );
TRACE( "Created drawable %s with client window %p\n", debugstr_opengl_drawable( &gl->base ), gl->window ); return gl; @@ -92,7 +90,6 @@ static struct gl_drawable *create_gl_drawable( HWND hwnd, HDC hdc, int format, A static void android_drawable_destroy( struct opengl_drawable *base ) { struct gl_drawable *gl = impl_from_opengl_drawable( base ); - if (gl->surface) funcs->p_eglDestroySurface( egl->display, gl->surface ); release_ioctl_window( gl->window ); }
@@ -153,7 +150,7 @@ static BOOL android_make_current( struct opengl_drawable *draw_base, struct open { struct gl_drawable *draw = impl_from_opengl_drawable( draw_base ), *read = impl_from_opengl_drawable( read_base ); TRACE( "draw %s, read %s, context %p\n", debugstr_opengl_drawable( draw_base ), debugstr_opengl_drawable( read_base ), context ); - return funcs->p_eglMakeCurrent( egl->display, context ? draw->surface : EGL_NO_SURFACE, context ? read->surface : EGL_NO_SURFACE, context ); + return funcs->p_eglMakeCurrent( egl->display, context ? draw->base.surface : EGL_NO_SURFACE, context ? read->base.surface : EGL_NO_SURFACE, context ); }
static EGLenum android_init_egl_platform( const struct egl_platform *platform, EGLNativeDisplayType *platform_display ) @@ -174,9 +171,9 @@ static BOOL android_drawable_swap( struct opengl_drawable *base ) { struct gl_drawable *gl = impl_from_opengl_drawable( base );
- TRACE( "drawable %s surface %p\n", debugstr_opengl_drawable( base ), gl->surface ); + TRACE( "drawable %s surface %p\n", debugstr_opengl_drawable( base ), gl->base.surface );
- funcs->p_eglSwapBuffers( egl->display, gl->surface ); + funcs->p_eglSwapBuffers( egl->display, gl->base.surface ); return TRUE; }
@@ -184,7 +181,7 @@ static void android_drawable_flush( struct opengl_drawable *base, UINT flags ) { struct gl_drawable *gl = impl_from_opengl_drawable( base );
- TRACE( "drawable %s, surface %p, flags %#x\n", debugstr_opengl_drawable( base ), gl->surface, flags ); + TRACE( "drawable %s, surface %p, flags %#x\n", debugstr_opengl_drawable( base ), gl->base.surface, flags );
if (flags & GL_FLUSH_INTERVAL) funcs->p_eglSwapInterval( egl->display, abs( base->interval ) ); } diff --git a/dlls/winewayland.drv/opengl.c b/dlls/winewayland.drv/opengl.c index bfc3ac7518f..bd84ea43932 100644 --- a/dlls/winewayland.drv/opengl.c +++ b/dlls/winewayland.drv/opengl.c @@ -51,7 +51,6 @@ struct wayland_gl_drawable struct opengl_drawable base; struct wayland_client_surface *client; struct wl_egl_window *wl_egl_window; - EGLSurface surface; BOOL double_buffered; };
@@ -64,7 +63,6 @@ static void wayland_drawable_destroy(struct opengl_drawable *base) { struct wayland_gl_drawable *gl = impl_from_opengl_drawable(base);
- if (gl->surface) funcs->p_eglDestroySurface(egl->display, gl->surface); if (gl->wl_egl_window) wl_egl_window_destroy(gl->wl_egl_window); if (gl->client) { @@ -131,9 +129,9 @@ static struct wayland_gl_drawable *wayland_gl_drawable_create(HWND hwnd, HDC hdc goto err; }
- gl->surface = funcs->p_eglCreateWindowSurface(egl->display, egl_config_for_format(format), - gl->wl_egl_window, attribs); - if (!gl->surface) + gl->base.surface = funcs->p_eglCreateWindowSurface(egl->display, egl_config_for_format(format), + gl->wl_egl_window, attribs); + if (!gl->base.surface) { ERR("Failed to create EGL surface\n"); goto err; @@ -141,7 +139,7 @@ static struct wayland_gl_drawable *wayland_gl_drawable_create(HWND hwnd, HDC hdc
gl->double_buffered = is_onscreen_format(format);
- TRACE("Created drawable %s with egl_surface %p\n", debugstr_opengl_drawable(&gl->base), gl->surface); + TRACE("Created drawable %s with egl_surface %p\n", debugstr_opengl_drawable(&gl->base), gl->base.surface);
return gl;
@@ -167,7 +165,7 @@ static BOOL wayland_make_current(struct opengl_drawable *draw_base, struct openg { struct wayland_gl_drawable *draw = impl_from_opengl_drawable(draw_base), *read = impl_from_opengl_drawable(read_base); TRACE("draw %s, read %s, context %p\n", debugstr_opengl_drawable(draw_base), debugstr_opengl_drawable(read_base), context); - return funcs->p_eglMakeCurrent(egl->display, context ? draw->surface : EGL_NO_SURFACE, context ? read->surface : EGL_NO_SURFACE, context); + return funcs->p_eglMakeCurrent(egl->display, context ? draw->base.surface : EGL_NO_SURFACE, context ? read->base.surface : EGL_NO_SURFACE, context); }
static BOOL wayland_opengl_surface_create(HWND hwnd, HDC hdc, int format, struct opengl_drawable **drawable) @@ -218,7 +216,7 @@ static BOOL wayland_drawable_swap(struct opengl_drawable *base)
/* Although all the EGL surfaces we create are double-buffered, we want to * use some as single-buffered, so avoid swapping those. */ - if (gl->double_buffered) funcs->p_eglSwapBuffers(egl->display, gl->surface); + if (gl->double_buffered) funcs->p_eglSwapBuffers(egl->display, gl->base.surface);
return TRUE; } diff --git a/dlls/winex11.drv/opengl.c b/dlls/winex11.drv/opengl.c index 80554860bdc..6d4c1144506 100644 --- a/dlls/winex11.drv/opengl.c +++ b/dlls/winex11.drv/opengl.c @@ -883,7 +883,6 @@ static BOOL x11drv_surface_create( HWND hwnd, HDC hdc, int format, struct opengl NtUserGetClientRect( hwnd, &rect, NtUserGetDpiForWindow( hwnd ) );
if (!(gl = opengl_drawable_create( sizeof(*gl), &x11drv_surface_funcs, format, hwnd, hdc ))) return FALSE; - /* Default GLX and WGL swap interval is 1, but in case of glXSwapIntervalSGI there is no way to query it. */ gl->rect = rect;
gl->colormap = XCreateColormap( gdi_display, get_dummy_parent(), fmt->visual->visual, diff --git a/include/wine/opengl_driver.h b/include/wine/opengl_driver.h index 55d862c9dfe..188c7b81249 100644 --- a/include/wine/opengl_driver.h +++ b/include/wine/opengl_driver.h @@ -157,6 +157,7 @@ struct opengl_drawable HDC hdc; /* DC the drawable was created for */ struct list entry; /* entry in win32u managed list */ LONG updated; /* has been moved / resized / reparented */ + EGLSurface surface; /* surface for EGL based drivers */ };
static inline const char *debugstr_opengl_drawable( struct opengl_drawable *drawable )