From: Rémi Bernon rbernon@codeweavers.com
--- dlls/win32u/opengl.c | 15 +---------- dlls/winemac.drv/opengl.c | 15 ++++++----- dlls/winewayland.drv/opengl.c | 23 +++++----------- dlls/winex11.drv/opengl.c | 50 +++++++++++++++-------------------- include/wine/opengl_driver.h | 1 - 5 files changed, 39 insertions(+), 65 deletions(-)
diff --git a/dlls/win32u/opengl.c b/dlls/win32u/opengl.c index 921f79a33a5..8d20ff05fce 100644 --- a/dlls/win32u/opengl.c +++ b/dlls/win32u/opengl.c @@ -400,12 +400,6 @@ static BOOL egldrv_pbuffer_create( HDC hdc, int format, BOOL largest, GLenum tex return FALSE; }
-static BOOL egldrv_pbuffer_destroy( HDC hdc, struct opengl_drawable *drawable ) -{ - FIXME( "stub!\n" ); - return FALSE; -} - static BOOL egldrv_pbuffer_updated( HDC hdc, struct opengl_drawable *drawable, GLenum cube_face, GLint mipmap_level ) { FIXME( "stub!\n" ); @@ -451,7 +445,6 @@ static const struct opengl_driver_funcs egldrv_funcs = .p_set_pixel_format = egldrv_set_pixel_format, .p_swap_buffers = egldrv_swap_buffers, .p_pbuffer_create = egldrv_pbuffer_create, - .p_pbuffer_destroy = egldrv_pbuffer_destroy, .p_pbuffer_updated = egldrv_pbuffer_updated, .p_pbuffer_bind = egldrv_pbuffer_bind, .p_context_create = egldrv_context_create, @@ -613,11 +606,6 @@ static BOOL nulldrv_pbuffer_create( HDC hdc, int format, BOOL largest, GLenum te return FALSE; }
-static BOOL nulldrv_pbuffer_destroy( HDC hdc, struct opengl_drawable *drawable ) -{ - return FALSE; -} - static BOOL nulldrv_pbuffer_updated( HDC hdc, struct opengl_drawable *drawable, GLenum cube_face, GLint mipmap_level ) { return GL_TRUE; @@ -657,7 +645,6 @@ static const struct opengl_driver_funcs nulldrv_funcs = .p_set_pixel_format = nulldrv_set_pixel_format, .p_swap_buffers = nulldrv_swap_buffers, .p_pbuffer_create = nulldrv_pbuffer_create, - .p_pbuffer_destroy = nulldrv_pbuffer_destroy, .p_pbuffer_updated = nulldrv_pbuffer_updated, .p_pbuffer_bind = nulldrv_pbuffer_bind, .p_context_create = nulldrv_context_create, @@ -1085,7 +1072,7 @@ static BOOL win32u_wglDestroyPbufferARB( struct wgl_pbuffer *pbuffer )
TRACE( "pbuffer %p\n", pbuffer );
- driver_funcs->p_pbuffer_destroy( pbuffer->hdc, pbuffer->drawable ); + opengl_drawable_release( pbuffer->drawable ); if (pbuffer->tmp_context) funcs->p_wglDeleteContext( pbuffer->tmp_context ); NtGdiDeleteObjectApp( pbuffer->hdc ); free( pbuffer ); diff --git a/dlls/winemac.drv/opengl.c b/dlls/winemac.drv/opengl.c index 8fd32474c7c..1facd278726 100644 --- a/dlls/winemac.drv/opengl.c +++ b/dlls/winemac.drv/opengl.c @@ -100,7 +100,7 @@ static pthread_mutex_t dc_pbuffers_mutex = PTHREAD_MUTEX_INITIALIZER; static void *opengl_handle; static const struct opengl_funcs *funcs; static const struct opengl_driver_funcs macdrv_driver_funcs; -static const struct opengl_drawable_funcs macdrv_drawable_funcs; +static const struct opengl_drawable_funcs macdrv_pbuffer_funcs;
static void (*pglCopyColorTable)(GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); @@ -2384,7 +2384,7 @@ static BOOL macdrv_pbuffer_create(HDC hdc, int format, BOOL largest, GLenum text }
if (!(gl = calloc(1, sizeof(*gl)))) return FALSE; - gl->base.funcs = &macdrv_drawable_funcs; + gl->base.funcs = &macdrv_pbuffer_funcs; gl->base.ref = 1; gl->base.hwnd = 0; gl->base.hdc = hdc; @@ -2407,11 +2407,11 @@ static BOOL macdrv_pbuffer_create(HDC hdc, int format, BOOL largest, GLenum text return TRUE; }
-static BOOL macdrv_pbuffer_destroy(HDC hdc, struct opengl_drawable *base) +static void macdrv_pbuffer_destroy(struct opengl_drawable *base) { struct gl_drawable *gl = impl_from_opengl_drawable(base);
- TRACE("hdc %p, drawable %s\n", hdc, debugstr_opengl_drawable(base)); + TRACE("drawable %s\n", debugstr_opengl_drawable(base));
pthread_mutex_lock(&dc_pbuffers_mutex); CFDictionaryRemoveValue(dc_pbuffers, gl->pbuffer); @@ -2419,7 +2419,6 @@ static BOOL macdrv_pbuffer_destroy(HDC hdc, struct opengl_drawable *base)
CGLReleasePBuffer(gl->pbuffer); free(gl); - return TRUE; }
@@ -3064,7 +3063,11 @@ static const struct opengl_driver_funcs macdrv_driver_funcs = .p_context_flush = macdrv_context_flush, .p_context_make_current = macdrv_context_make_current, .p_pbuffer_create = macdrv_pbuffer_create, - .p_pbuffer_destroy = macdrv_pbuffer_destroy, .p_pbuffer_updated = macdrv_pbuffer_updated, .p_pbuffer_bind = macdrv_pbuffer_bind, }; + +static const struct opengl_drawable_funcs macdrv_pbuffer_funcs = +{ + .destroy = macdrv_pbuffer_destroy, +}; diff --git a/dlls/winewayland.drv/opengl.c b/dlls/winewayland.drv/opengl.c index 34b9487d6b6..0dc3f16b9f9 100644 --- a/dlls/winewayland.drv/opengl.c +++ b/dlls/winewayland.drv/opengl.c @@ -124,6 +124,13 @@ static struct wayland_gl_drawable *wayland_gl_drawable_get(HWND hwnd, HDC hdc) static void wayland_drawable_destroy(struct opengl_drawable *base) { struct wayland_gl_drawable *gl = impl_from_opengl_drawable(base); + + if (!gl->base.hwnd) + { + pthread_mutex_lock(&gl_object_mutex); + list_remove(&gl->entry); + pthread_mutex_unlock(&gl_object_mutex); + } 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) @@ -523,21 +530,6 @@ static BOOL wayland_pbuffer_create(HDC hdc, int format, BOOL largest, GLenum tex return TRUE; }
-static BOOL wayland_pbuffer_destroy(HDC hdc, struct opengl_drawable *base) -{ - struct wayland_gl_drawable *drawable = impl_from_opengl_drawable(base); - - TRACE("hdc %p, drawable %s\n", hdc, debugstr_opengl_drawable(base)); - - pthread_mutex_lock(&gl_object_mutex); - list_remove(&drawable->entry); - pthread_mutex_unlock(&gl_object_mutex); - - opengl_drawable_release(&drawable->base); - - return GL_TRUE; -} - static BOOL wayland_pbuffer_updated(HDC hdc, struct opengl_drawable *base, GLenum cube_face, GLint mipmap_level) { return GL_TRUE; @@ -558,7 +550,6 @@ static struct opengl_driver_funcs wayland_driver_funcs = .p_context_flush = wayland_context_flush, .p_context_make_current = wayland_context_make_current, .p_pbuffer_create = wayland_pbuffer_create, - .p_pbuffer_destroy = wayland_pbuffer_destroy, .p_pbuffer_updated = wayland_pbuffer_updated, .p_pbuffer_bind = wayland_pbuffer_bind, }; diff --git a/dlls/winex11.drv/opengl.c b/dlls/winex11.drv/opengl.c index 499e906b948..eae594d630d 100644 --- a/dlls/winex11.drv/opengl.c +++ b/dlls/winex11.drv/opengl.c @@ -828,21 +828,15 @@ static struct gl_drawable *grab_gl_drawable( struct gl_drawable *gl ) return gl; }
-static void x11drv_drawable_destroy( struct opengl_drawable *base ) +static void x11drv_surface_destroy( struct opengl_drawable *base ) { - struct gl_drawable *gl = impl_from_opengl_drawable(base); - if (gl->base.funcs == &x11drv_surface_funcs) - { - TRACE( "destroying %lx drawable %lx\n", gl->window, gl->drawable ); - pglXDestroyWindow( gdi_display, gl->drawable ); - destroy_client_window( gl->base.hwnd, gl->window ); - XFreeColormap( gdi_display, gl->colormap ); - } - else - { - TRACE( "destroying pbuffer drawable %lx\n", gl->drawable ); - pglXDestroyPbuffer( gdi_display, gl->drawable ); - } + struct gl_drawable *gl = impl_from_opengl_drawable( base ); + + TRACE( "drawable %s\n", debugstr_opengl_drawable( base ) ); + + pglXDestroyWindow( gdi_display, gl->drawable ); + destroy_client_window( gl->base.hwnd, gl->window ); + XFreeColormap( gdi_display, gl->colormap ); if (gl->hdc_src) NtGdiDeleteObjectApp( gl->hdc_src ); if (gl->hdc_dst) NtGdiDeleteObjectApp( gl->hdc_dst ); free( gl ); @@ -1302,17 +1296,17 @@ static void *x11drv_get_proc_address( const char *name ) return pglXGetProcAddressARB( (const GLubyte *)name ); }
-static void set_context_drawables( struct x11drv_context *ctx, struct gl_drawable *draw, - struct gl_drawable *read ) +static void set_context_drawables( struct x11drv_context *ctx, struct gl_drawable **draw, + struct gl_drawable **read ) { struct gl_drawable *old_draw, *old_read;
old_draw = ctx->draw; old_read = ctx->read; - ctx->draw = grab_gl_drawable( draw ); - ctx->read = read ? grab_gl_drawable( read ) : NULL; - if (old_draw) opengl_drawable_release( &old_draw->base ); - if (old_read) opengl_drawable_release( &old_read->base ); + ctx->draw = *draw; + ctx->read = *read; + *draw = old_draw; + *read = old_read; }
static BOOL x11drv_context_make_current( HDC draw_hdc, HDC read_hdc, void *private ) @@ -1339,7 +1333,7 @@ static BOOL x11drv_context_make_current( HDC draw_hdc, HDC read_hdc, void *priva else ret = pglXMakeContextCurrent( gdi_display, draw_gl->drawable, read_gl ? read_gl->drawable : 0, ctx->ctx ); if (ret) { - set_context_drawables( ctx, draw_gl, read_gl ); + set_context_drawables( ctx, &draw_gl, &read_gl ); NtCurrentTeb()->glReserved2 = ctx; pthread_mutex_unlock( &context_mutex ); goto done; @@ -1548,18 +1542,19 @@ static BOOL x11drv_pbuffer_create( HDC hdc, int format, BOOL largest, GLenum tex return TRUE; }
-static BOOL x11drv_pbuffer_destroy( HDC hdc, struct opengl_drawable *base ) +static void x11drv_pbuffer_destroy( struct opengl_drawable *base ) { struct gl_drawable *gl = impl_from_opengl_drawable( base ); + HDC hdc = gl->base.hdc;
- TRACE( "hdc %p, drawable %s\n", hdc, debugstr_opengl_drawable( base ) ); + TRACE( "drawable %s\n", debugstr_opengl_drawable( base ) );
pthread_mutex_lock( &context_mutex ); XDeleteContext( gdi_display, (XID)hdc, gl_pbuffer_context ); pthread_mutex_unlock( &context_mutex ); - opengl_drawable_release( &gl->base );
- return GL_TRUE; + pglXDestroyPbuffer( gdi_display, gl->drawable ); + free( gl ); }
static BOOL x11drv_pbuffer_updated( HDC hdc, struct opengl_drawable *base, GLenum cube_face, GLint mipmap_level ) @@ -1744,19 +1739,18 @@ static const struct opengl_driver_funcs x11drv_driver_funcs = .p_context_flush = x11drv_context_flush, .p_context_make_current = x11drv_context_make_current, .p_pbuffer_create = x11drv_pbuffer_create, - .p_pbuffer_destroy = x11drv_pbuffer_destroy, .p_pbuffer_updated = x11drv_pbuffer_updated, .p_pbuffer_bind = x11drv_pbuffer_bind, };
static const struct opengl_drawable_funcs x11drv_surface_funcs = { - .destroy = x11drv_drawable_destroy, + .destroy = x11drv_surface_destroy, };
static const struct opengl_drawable_funcs x11drv_pbuffer_funcs = { - .destroy = x11drv_drawable_destroy, + .destroy = x11drv_pbuffer_destroy, };
#else /* no OpenGL includes */ diff --git a/include/wine/opengl_driver.h b/include/wine/opengl_driver.h index 5101525f744..b4f3d13eca3 100644 --- a/include/wine/opengl_driver.h +++ b/include/wine/opengl_driver.h @@ -168,7 +168,6 @@ struct opengl_driver_funcs BOOL (*p_context_make_current)(HDC,HDC,void*); BOOL (*p_pbuffer_create)( HDC hdc, int format, BOOL largest, GLenum texture_format, GLenum texture_target, GLint max_level, GLsizei *width, GLsizei *height, struct opengl_drawable **drawable ); - BOOL (*p_pbuffer_destroy)( HDC hdc, struct opengl_drawable *drawable ); BOOL (*p_pbuffer_updated)( HDC hdc, struct opengl_drawable *drawable, GLenum cube_face, GLint mipmap_level ); UINT (*p_pbuffer_bind)( HDC hdc, struct opengl_drawable *drawable, GLenum buffer ); };