From: Rémi Bernon rbernon@codeweavers.com
--- dlls/win32u/ntuser_private.h | 4 -- dlls/win32u/opengl.c | 76 +++------------------------------ dlls/win32u/window.c | 3 -- dlls/wineandroid.drv/opengl.c | 45 ++++++++++++++------ dlls/winemac.drv/opengl.c | 78 +++++++++++++++++++++------------- dlls/winewayland.drv/opengl.c | 35 +++++---------- dlls/winex11.drv/opengl.c | 80 ++++++++++------------------------- include/wine/opengl_driver.h | 21 +++------ 8 files changed, 126 insertions(+), 216 deletions(-)
diff --git a/dlls/win32u/ntuser_private.h b/dlls/win32u/ntuser_private.h index f87cc191d18..27a723b4c2f 100644 --- a/dlls/win32u/ntuser_private.h +++ b/dlls/win32u/ntuser_private.h @@ -221,10 +221,6 @@ extern PFN_vkGetInstanceProcAddr p_vkGetInstanceProcAddr;
extern BOOL vulkan_init(void);
-/* opengl.c */ -extern void update_opengl_drawables( HWND hwnd ); -extern void detach_opengl_drawables( HWND hwnd ); - /* window.c */ HANDLE alloc_user_handle( void *ptr, unsigned short type ); void *free_user_handle( HANDLE handle, unsigned short type ); diff --git a/dlls/win32u/opengl.c b/dlls/win32u/opengl.c index 6ed8ac1010e..f27143f3357 100644 --- a/dlls/win32u/opengl.c +++ b/dlls/win32u/opengl.c @@ -163,54 +163,7 @@ static void register_extension( char *list, size_t size, const char *name ) } }
-static pthread_mutex_t drawables_lock = PTHREAD_MUTEX_INITIALIZER; -static struct list drawables = LIST_INIT( drawables ); - -void detach_opengl_drawables( HWND hwnd ) -{ - struct list detached = LIST_INIT( detached ); - struct opengl_drawable *drawable, *next; - - pthread_mutex_lock( &drawables_lock ); - - LIST_FOR_EACH_ENTRY_SAFE( drawable, next, &drawables, struct opengl_drawable, entry ) - { - if (drawable->hwnd != hwnd) continue; - - list_remove( &drawable->entry ); - list_add_tail( &detached, &drawable->entry ); - opengl_drawable_add_ref( drawable ); - - drawable->funcs->detach( drawable ); - drawable->hwnd = NULL; - } - - pthread_mutex_unlock( &drawables_lock ); - - LIST_FOR_EACH_ENTRY_SAFE( drawable, next, &detached, struct opengl_drawable, entry ) - { - list_remove( &drawable->entry ); - opengl_drawable_release( drawable ); - } -} - -void update_opengl_drawables( HWND hwnd ) -{ - struct opengl_drawable *drawable, *next; - - pthread_mutex_lock( &drawables_lock ); - - LIST_FOR_EACH_ENTRY_SAFE( drawable, next, &drawables, struct opengl_drawable, entry ) - { - if (drawable->hwnd != hwnd) continue; - drawable->funcs->update( drawable ); - InterlockedExchange( &drawable->updated, 1 ); - } - - pthread_mutex_unlock( &drawables_lock ); -} - -void *opengl_drawable_create( UINT size, const struct opengl_drawable_funcs *funcs, int format, HWND hwnd ) +void *opengl_drawable_create( UINT size, const struct opengl_drawable_funcs *funcs, int format, struct client_surface *client ) { struct opengl_drawable *drawable;
@@ -220,15 +173,7 @@ void *opengl_drawable_create( UINT size, const struct opengl_drawable_funcs *fun
drawable->format = format; drawable->interval = INT_MIN; - drawable->hwnd = hwnd; - - if (!hwnd) list_init( &drawable->entry ); /* pbuffer, keep it unlinked */ - else - { - pthread_mutex_lock( &drawables_lock ); - list_add_tail( &drawables, &drawable->entry ); - pthread_mutex_unlock( &drawables_lock ); - } + if ((drawable->client = client)) client_surface_add_ref( client );
TRACE( "created %s\n", debugstr_opengl_drawable( drawable ) ); return drawable; @@ -250,25 +195,18 @@ void opengl_drawable_release( struct opengl_drawable *drawable ) const struct opengl_funcs *funcs = &display_funcs; const struct egl_platform *egl = &display_egl;
- pthread_mutex_lock( &drawables_lock ); - if (drawable->hwnd) - { - drawable->funcs->detach( drawable ); - list_remove( &drawable->entry ); - } - pthread_mutex_unlock( &drawables_lock ); - drawable->funcs->destroy( drawable ); if (drawable->surface) funcs->p_eglDestroySurface( egl->display, drawable->surface ); + if (drawable->client) client_surface_release( drawable->client ); free( drawable ); } }
static void opengl_drawable_flush( struct opengl_drawable *drawable, int interval, UINT flags ) { - if (!drawable->hwnd) return; + if (!drawable->client) return;
- if (InterlockedCompareExchange( &drawable->updated, 0, 1 )) flags |= GL_FLUSH_UPDATED; + if (InterlockedCompareExchange( &drawable->client->updated, 0, 1 )) flags |= GL_FLUSH_UPDATED; if (interval != drawable->interval) { drawable->interval = interval; @@ -553,7 +491,7 @@ static BOOL egldrv_pbuffer_create( HDC hdc, int format, BOOL largest, GLenum tex } *attrib++ = EGL_NONE;
- if (!(gl = opengl_drawable_create( sizeof(*gl), &egldrv_pbuffer_funcs, format, 0 ))) return FALSE; + if (!(gl = opengl_drawable_create( sizeof(*gl), &egldrv_pbuffer_funcs, format, NULL ))) return FALSE; if (!(gl->surface = funcs->p_eglCreatePbufferSurface( egl->display, egl_config_for_format( egl, gl->format ), attribs ))) { opengl_drawable_release( gl ); @@ -1749,7 +1687,7 @@ static BOOL win32u_wglSwapBuffers( HDC hdc )
if (!(draw = get_dc_opengl_drawable( draw_hdc, FALSE ))) return FALSE; opengl_drawable_flush( draw, interval, 0 ); - if (!draw->hwnd) ret = FALSE; /* pbuffer, nothing to do */ + if (!draw->client) ret = FALSE; /* pbuffer, nothing to do */ else ret = draw->funcs->swap( draw ); opengl_drawable_release( draw );
diff --git a/dlls/win32u/window.c b/dlls/win32u/window.c index 47cded6ec4e..4a9e817c7e4 100644 --- a/dlls/win32u/window.c +++ b/dlls/win32u/window.c @@ -2256,7 +2256,6 @@ static BOOL apply_window_pos( HWND hwnd, HWND insert_after, UINT swp_flags, stru
user_driver->pWindowPosChanged( hwnd, insert_after, owner_hint, swp_flags, is_fullscreen, &monitor_rects, get_driver_window_surface( new_surface, raw_dpi ) ); - update_opengl_drawables( hwnd ); update_client_surfaces( hwnd );
update_children_window_state( hwnd ); @@ -5191,7 +5190,6 @@ LRESULT destroy_window( HWND hwnd ) window_surface_release( surface ); }
- detach_opengl_drawables( hwnd ); detach_client_surfaces( hwnd ); if (win->opengl_drawable) opengl_drawable_release( win->opengl_drawable ); user_driver->pDestroyWindow( hwnd ); @@ -5347,7 +5345,6 @@ void destroy_thread_windows(void) free_list = entry->next; TRACE( "destroying %p\n", entry );
- detach_opengl_drawables( entry->handle ); detach_client_surfaces( entry->handle ); user_driver->pDestroyWindow( entry->handle ); if (entry->opengl_drawable) opengl_drawable_release( entry->opengl_drawable ); diff --git a/dlls/wineandroid.drv/opengl.c b/dlls/wineandroid.drv/opengl.c index e5f660c2be4..25e6751c744 100644 --- a/dlls/wineandroid.drv/opengl.c +++ b/dlls/wineandroid.drv/opengl.c @@ -48,6 +48,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(android);
static const struct egl_platform *egl; static const struct opengl_funcs *funcs; +static const struct client_surface_funcs android_client_surface_funcs; static const struct opengl_drawable_funcs android_drawable_funcs;
struct gl_drawable @@ -73,9 +74,13 @@ static inline EGLConfig egl_config_for_format(int format) static struct gl_drawable *create_gl_drawable( HWND hwnd, HDC hdc, int format, ANativeWindow *window ) { static const int attribs[] = { EGL_WIDTH, 1, EGL_HEIGHT, 1, EGL_NONE }; + struct client_surface *client; struct gl_drawable *gl;
- if (!(gl = opengl_drawable_create( sizeof(*gl), &android_drawable_funcs, format, hwnd ))) return NULL; + if (!(client = client_surface_create( sizeof(*client), &android_client_surface_funcs, hwnd ))) return NULL; + gl = opengl_drawable_create( sizeof(*gl), &android_drawable_funcs, format, client ); + client_surface_release( client ); + if (!gl) return NULL;
if (!window) gl->window = create_ioctl_window( hwnd, TRUE, 1.0f ); else gl->window = grab_ioctl_window( window ); @@ -93,16 +98,6 @@ static void android_drawable_destroy( struct opengl_drawable *base ) release_ioctl_window( gl->window ); }
-static void android_drawable_detach( struct opengl_drawable *base ) -{ - TRACE( "%s\n", debugstr_opengl_drawable( base ) ); -} - -static void android_drawable_update( struct opengl_drawable *base ) -{ - TRACE( "%s\n", debugstr_opengl_drawable( base ) ); -} - void update_gl_drawable( HWND hwnd ) { struct gl_drawable *old, *new; @@ -133,7 +128,6 @@ static BOOL android_surface_create( HWND hwnd, HDC hdc, int format, struct openg gl = impl_from_opengl_drawable( *drawable ); funcs->p_eglGetConfigAttrib( egl->display, egl_config_for_format(format), EGL_NATIVE_VISUAL_ID, &pf ); gl->window->perform( gl->window, NATIVE_WINDOW_SET_BUFFERS_FORMAT, pf ); - gl->base.hwnd = hwnd; gl->base.format = format;
TRACE( "Updated drawable %s\n", debugstr_opengl_drawable( *drawable ) ); @@ -191,11 +185,34 @@ static struct opengl_driver_funcs android_driver_funcs = .p_surface_create = android_surface_create, };
+static void android_client_surface_destroy(struct client_surface *client) +{ + TRACE("%s\n", debugstr_client_surface(client)); +} + +static void android_client_surface_detach(struct client_surface *client) +{ +} + +static void android_client_surface_update(struct client_surface *client) +{ +} + +static void android_client_surface_present(struct client_surface *client, HDC hdc) +{ +} + +static const struct client_surface_funcs android_client_surface_funcs = +{ + .destroy = android_client_surface_destroy, + .detach = android_client_surface_detach, + .update = android_client_surface_update, + .present = android_client_surface_present, +}; + static const struct opengl_drawable_funcs android_drawable_funcs = { .destroy = android_drawable_destroy, - .detach = android_drawable_detach, - .update = android_drawable_update, .flush = android_drawable_flush, .swap = android_drawable_swap, }; diff --git a/dlls/winemac.drv/opengl.c b/dlls/winemac.drv/opengl.c index f48737c1b43..172b0d60226 100644 --- a/dlls/winemac.drv/opengl.c +++ b/dlls/winemac.drv/opengl.c @@ -96,6 +96,7 @@ static pthread_mutex_t context_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 client_surface_funcs macdrv_client_surface_funcs; static const struct opengl_drawable_funcs macdrv_surface_funcs; static const struct opengl_drawable_funcs macdrv_pbuffer_funcs;
@@ -1470,6 +1471,7 @@ static BOOL create_context(struct macdrv_context *context, CGLContextObj share,
static BOOL macdrv_surface_create(HWND hwnd, HDC hdc, int format, struct opengl_drawable **drawable) { + struct client_surface *client; struct macdrv_win_data *data; struct gl_drawable *gl;
@@ -1484,9 +1486,12 @@ static BOOL macdrv_surface_create(HWND hwnd, HDC hdc, int format, struct opengl_ data->pixel_format = format; release_win_data(data);
- if (!(gl = opengl_drawable_create(sizeof(*gl), &macdrv_surface_funcs, format, hwnd))) return FALSE; - *drawable = &gl->base; + if (!(client = client_surface_create(sizeof(*client), &macdrv_client_surface_funcs, hwnd))) return FALSE; + gl = opengl_drawable_create(sizeof(*gl), &macdrv_surface_funcs, format, client); + client_surface_release(client); + if (!gl) return FALSE;
+ *drawable = &gl->base; return TRUE; }
@@ -1511,21 +1516,6 @@ static void mark_contexts_for_moved_view(macdrv_view view) pthread_mutex_unlock(&context_mutex); }
-static void macdrv_surface_update(struct opengl_drawable *base) -{ - struct macdrv_win_data *data = get_win_data(base->hwnd); - - TRACE("%s\n", debugstr_opengl_drawable(base)); - - if (data->client_cocoa_view && data->pixel_format) - { - TRACE("GL view %p changed position; marking contexts\n", data->client_cocoa_view); - mark_contexts_for_moved_view(data->client_cocoa_view); - } - - release_win_data(data); -} - /********************************************************************** * sync_context_rect */ @@ -2085,11 +2075,6 @@ static void macdrv_glCopyPixels(GLint x, GLint y, GLsizei width, GLsizei height, make_context_current(context, FALSE); }
-static void macdrv_surface_detach(struct opengl_drawable *base) -{ - TRACE("%s\n", debugstr_opengl_drawable(base)); -} - static void macdrv_surface_flush(struct opengl_drawable *base, UINT flags) { struct macdrv_context *context = NtCurrentTeb()->glReserved2; @@ -2357,7 +2342,7 @@ static BOOL macdrv_pbuffer_create(HDC hdc, int format, BOOL largest, GLenum text texture_format = GL_RGB; }
- if (!(gl = opengl_drawable_create(sizeof(*gl), &macdrv_pbuffer_funcs, format, 0))) return FALSE; + if (!(gl = opengl_drawable_create(sizeof(*gl), &macdrv_pbuffer_funcs, format, NULL))) return FALSE;
err = CGLCreatePBuffer(*width, *height, texture_target, texture_format, max_level, &gl->pbuffer); if (err != kCGLNoError) @@ -2386,7 +2371,6 @@ static BOOL macdrv_make_current(struct opengl_drawable *draw_base, struct opengl struct gl_drawable *draw = impl_from_opengl_drawable(draw_base), *read = impl_from_opengl_drawable(read_base); struct macdrv_context *context = private; struct macdrv_win_data *data; - HWND hwnd;
TRACE("draw %s, read %s, context %p\n", debugstr_opengl_drawable(draw_base), debugstr_opengl_drawable(read_base), private);
@@ -2397,8 +2381,9 @@ static BOOL macdrv_make_current(struct opengl_drawable *draw_base, struct opengl return TRUE; }
- if ((hwnd = draw->base.hwnd)) + if (draw->base.client) { + HWND hwnd = draw->base.client->hwnd; if (!(data = get_win_data(hwnd))) { FIXME("draw DC for window %p of other process: not implemented\n", hwnd); @@ -2424,8 +2409,9 @@ static BOOL macdrv_make_current(struct opengl_drawable *draw_base, struct opengl context->read_pbuffer = NULL; if (read != draw) { - if ((hwnd = read->base.hwnd)) + if (read->base.client) { + HWND hwnd = read->base.client->hwnd; if ((data = get_win_data(hwnd))) { if (data->client_cocoa_view != context->draw_view) @@ -2906,7 +2892,7 @@ static BOOL macdrv_surface_swap(struct opengl_drawable *base) { struct macdrv_context *context = NtCurrentTeb()->glReserved2; struct macdrv_win_data *data; - HWND hwnd = base->hwnd; + HWND hwnd = base->client->hwnd; BOOL match = FALSE;
TRACE("%s context %p/%p/%p\n", debugstr_opengl_drawable(base), context, (context ? context->context : NULL), @@ -2948,11 +2934,45 @@ static const struct opengl_driver_funcs macdrv_driver_funcs = .p_pbuffer_bind = macdrv_pbuffer_bind, };
+static void macdrv_client_surface_destroy(struct client_surface *client) +{ + TRACE("%s\n", debugstr_client_surface(client)); +} + +static void macdrv_client_surface_detach(struct client_surface *client) +{ +} + +static void macdrv_client_surface_update(struct client_surface *client) +{ + struct macdrv_win_data *data = get_win_data(client->hwnd); + + TRACE("%s\n", debugstr_client_surface(client)); + + if (data->client_cocoa_view && data->pixel_format) + { + TRACE("GL view %p changed position; marking contexts\n", data->client_cocoa_view); + mark_contexts_for_moved_view(data->client_cocoa_view); + } + + release_win_data(data); +} + +static void macdrv_client_surface_present(struct client_surface *client, HDC hdc) +{ +} + +static const struct client_surface_funcs macdrv_client_surface_funcs = +{ + .destroy = macdrv_client_surface_destroy, + .detach = macdrv_client_surface_detach, + .update = macdrv_client_surface_update, + .present = macdrv_client_surface_present, +}; + static const struct opengl_drawable_funcs macdrv_surface_funcs = { .destroy = macdrv_surface_destroy, - .detach = macdrv_surface_detach, - .update = macdrv_surface_update, .flush = macdrv_surface_flush, .swap = macdrv_surface_swap, }; diff --git a/dlls/winewayland.drv/opengl.c b/dlls/winewayland.drv/opengl.c index db510d2df97..c3ccfc93202 100644 --- a/dlls/winewayland.drv/opengl.c +++ b/dlls/winewayland.drv/opengl.c @@ -49,7 +49,6 @@ static const struct opengl_drawable_funcs wayland_drawable_funcs; struct wayland_gl_drawable { struct opengl_drawable base; - struct wayland_client_surface *client; struct wl_egl_window *wl_egl_window; };
@@ -61,23 +60,7 @@ static struct wayland_gl_drawable *impl_from_opengl_drawable(struct opengl_drawa static void wayland_drawable_destroy(struct opengl_drawable *base) { struct wayland_gl_drawable *gl = impl_from_opengl_drawable(base); - if (gl->wl_egl_window) wl_egl_window_destroy(gl->wl_egl_window); - if (gl->client) - { - gl->client->client.funcs->detach( &gl->client->client ); - client_surface_release( &gl->client->client ); - } -} - -static void wayland_drawable_detach(struct opengl_drawable *base) -{ - TRACE("%s\n", debugstr_opengl_drawable(base)); -} - -static void wayland_drawable_update(struct opengl_drawable *base) -{ - TRACE("%s\n", debugstr_opengl_drawable(base)); }
static EGLConfig egl_config_for_format(int format) @@ -92,7 +75,7 @@ static void wayland_gl_drawable_sync_size(struct wayland_gl_drawable *gl) int client_width, client_height; RECT client_rect = {0};
- NtUserGetClientRect(gl->base.hwnd, &client_rect, NtUserGetDpiForWindow(gl->base.hwnd)); + NtUserGetClientRect(gl->base.client->hwnd, &client_rect, NtUserGetDpiForWindow(gl->base.client->hwnd)); client_width = client_rect.right - client_rect.left; client_height = client_rect.bottom - client_rect.top; if (client_width == 0 || client_height == 0) client_width = client_height = 1; @@ -103,6 +86,7 @@ static void wayland_gl_drawable_sync_size(struct wayland_gl_drawable *gl) static BOOL wayland_opengl_surface_create(HWND hwnd, HDC hdc, int format, struct opengl_drawable **drawable) { EGLConfig config = egl_config_for_format(format); + struct wayland_client_surface *client; EGLint attribs[4], *attrib = attribs; struct opengl_drawable *previous; struct wayland_gl_drawable *gl; @@ -125,11 +109,14 @@ static BOOL wayland_opengl_surface_create(HWND hwnd, HDC hdc, int format, struct } *attrib++ = EGL_NONE;
- if (!(gl = opengl_drawable_create(sizeof(*gl), &wayland_drawable_funcs, format, hwnd))) return FALSE; - if (!(gl->client = wayland_client_surface_create(hwnd))) goto err; - if (!(gl->wl_egl_window = wl_egl_window_create(gl->client->wl_surface, rect.right, rect.bottom))) goto err; + if (!(client = wayland_client_surface_create(hwnd))) return FALSE; + gl = opengl_drawable_create(sizeof(*gl), &wayland_drawable_funcs, format, &client->client); + client_surface_release(&client->client); + if (!gl) return FALSE; + + if (!(gl->wl_egl_window = wl_egl_window_create(client->wl_surface, rect.right, rect.bottom))) goto err; if (!(gl->base.surface = funcs->p_eglCreateWindowSurface(egl->display, config, gl->wl_egl_window, attribs))) goto err; - set_client_surface(hwnd, gl->client); + set_client_surface(hwnd, client);
TRACE("Created drawable %s with egl_surface %p\n", debugstr_opengl_drawable(&gl->base), gl->base.surface);
@@ -167,7 +154,7 @@ static BOOL wayland_drawable_swap(struct opengl_drawable *base) { struct wayland_gl_drawable *gl = impl_from_opengl_drawable(base);
- client_surface_present(&gl->client->client, NULL); + client_surface_present(base->client, NULL); funcs->p_eglSwapBuffers(egl->display, gl->base.surface);
return TRUE; @@ -248,8 +235,6 @@ static struct opengl_driver_funcs wayland_driver_funcs = static const struct opengl_drawable_funcs wayland_drawable_funcs = { .destroy = wayland_drawable_destroy, - .detach = wayland_drawable_detach, - .update = wayland_drawable_update, .flush = wayland_drawable_flush, .swap = wayland_drawable_swap, }; diff --git a/dlls/winex11.drv/opengl.c b/dlls/winex11.drv/opengl.c index 7e9e253a373..8d5654d8379 100644 --- a/dlls/winex11.drv/opengl.c +++ b/dlls/winex11.drv/opengl.c @@ -197,7 +197,6 @@ struct glx_pixel_format struct gl_drawable { struct opengl_drawable base; - struct client_surface *client; RECT rect; /* current size of the GL drawable */ GLXDrawable drawable; /* drawable for rendering with GL */ Colormap colormap; /* colormap for the client window */ @@ -488,6 +487,7 @@ static inline EGLConfig egl_config_for_format(int format) static BOOL x11drv_egl_surface_create( HWND hwnd, HDC hdc, int format, struct opengl_drawable **drawable ) { struct opengl_drawable *previous; + struct client_surface *client; struct gl_drawable *gl; Window window; RECT rect; @@ -495,19 +495,15 @@ static BOOL x11drv_egl_surface_create( HWND hwnd, HDC hdc, int format, struct op if ((previous = *drawable) && previous->format == format) return TRUE; NtUserGetClientRect( hwnd, &rect, NtUserGetDpiForWindow( hwnd ) );
- if (!(gl = opengl_drawable_create( sizeof(*gl), &x11drv_egl_surface_funcs, format, hwnd ))) return FALSE; + if (!(window = x11drv_client_surface_create( hwnd, &client ))) return FALSE; + gl = opengl_drawable_create( sizeof(*gl), &x11drv_egl_surface_funcs, format, client ); + client_surface_release( client ); + if (!gl) return FALSE; gl->rect = rect; gl->hdc = hdc;
- if (!(window = x11drv_client_surface_create(hwnd, &gl->client))) - { - opengl_drawable_release( &gl->base ); - return FALSE; - } - - gl->base.surface = funcs->p_eglCreateWindowSurface( egl->display, egl_config_for_format(format), - (void *)window, NULL ); - if (!gl->base.surface) + if (!(gl->base.surface = funcs->p_eglCreateWindowSurface( egl->display, egl_config_for_format(format), + (void *)window, NULL ))) { opengl_drawable_release( &gl->base ); return FALSE; @@ -877,7 +873,6 @@ static void x11drv_surface_destroy( struct opengl_drawable *base ) if (gl->colormap) XFreeColormap( gdi_display, gl->colormap ); if (gl->hdc_src) NtGdiDeleteObjectApp( gl->hdc_src ); if (gl->hdc_dst) NtGdiDeleteObjectApp( gl->hdc_dst ); - if (gl->client) client_surface_release( gl->client ); }
static BOOL set_swap_interval( struct gl_drawable *gl, int interval ) @@ -935,6 +930,7 @@ static BOOL x11drv_surface_create( HWND hwnd, HDC hdc, int format, struct opengl { struct glx_pixel_format *fmt = glx_pixel_format_from_format( format ); struct opengl_drawable *previous; + struct client_surface *client; struct gl_drawable *gl; Window window; RECT rect; @@ -942,16 +938,13 @@ static BOOL x11drv_surface_create( HWND hwnd, HDC hdc, int format, struct opengl if ((previous = *drawable) && previous->format == format) return TRUE; NtUserGetClientRect( hwnd, &rect, NtUserGetDpiForWindow( hwnd ) );
- if (!(gl = opengl_drawable_create( sizeof(*gl), &x11drv_surface_funcs, format, hwnd ))) return FALSE; + if (!(window = x11drv_client_surface_create( hwnd, &client ))) return FALSE; + gl = opengl_drawable_create( sizeof(*gl), &x11drv_surface_funcs, format, client ); + client_surface_release( client ); + if (!gl) return FALSE; gl->rect = rect; gl->hdc = hdc;
- if (!(window = x11drv_client_surface_create(hwnd, &gl->client))) - { - opengl_drawable_release( &gl->base ); - return FALSE; - } - gl->colormap = XCreateColormap( gdi_display, get_dummy_parent(), fmt->visual->visual, (fmt->visual->class == PseudoColor || fmt->visual->class == GrayScale || fmt->visual->class == DirectColor) ? AllocAll : AllocNone ); @@ -969,17 +962,6 @@ static BOOL x11drv_surface_create( HWND hwnd, HDC hdc, int format, struct opengl return TRUE; }
-static void x11drv_surface_update( struct opengl_drawable *base ) -{ - TRACE( "%s\n", debugstr_opengl_drawable( base ) ); -} - -static void x11drv_surface_detach( struct opengl_drawable *base ) -{ - TRACE( "%s\n", debugstr_opengl_drawable( base ) ); -} - - static BOOL x11drv_describe_pixel_format( int format, struct wgl_pixel_format *pf ) { int value, drawable_type = 0, render_type = 0; @@ -1205,11 +1187,11 @@ static void x11drv_surface_flush( struct opengl_drawable *base, UINT flags )
if (flags & GL_FLUSH_INTERVAL) set_swap_interval( gl, base->interval );
- if (InterlockedCompareExchange( &gl->client->offscreen, 0, 0 )) + if (InterlockedCompareExchange( &base->client->offscreen, 0, 0 )) { if (!(flags & GL_FLUSH_FINISHED)) funcs->p_glFinish(); XFlush( gdi_display ); - client_surface_present( gl->client, gl->hdc ); + client_surface_present( base->client, gl->hdc ); } }
@@ -1306,7 +1288,7 @@ static BOOL x11drv_pbuffer_create( HDC hdc, int format, BOOL largest, GLenum tex } glx_attribs[count++] = 0;
- if (!(gl = opengl_drawable_create( sizeof(*gl), &x11drv_pbuffer_funcs, format, 0 ))) return FALSE; + if (!(gl = opengl_drawable_create( sizeof(*gl), &x11drv_pbuffer_funcs, format, NULL ))) return FALSE;
gl->drawable = pglXCreatePbuffer( gdi_display, fmt->fbconfig, glx_attribs ); TRACE( "new Pbuffer drawable as %p (%lx)\n", gl, gl->drawable ); @@ -1472,10 +1454,10 @@ static BOOL x11drv_surface_swap( struct opengl_drawable *base ) if (pglXWaitForSbcOML) pglXWaitForSbcOML( gdi_display, gl->drawable, target_sbc, &ust, &msc, &sbc ); }
- if (InterlockedCompareExchange( &gl->client->offscreen, 0, 0 )) + if (InterlockedCompareExchange( &base->client->offscreen, 0, 0 )) { if (!pglXWaitForSbcOML) XFlush( gdi_display ); - client_surface_present( gl->client, gl->hdc ); + client_surface_present( base->client, gl->hdc ); }
return TRUE; @@ -1483,21 +1465,7 @@ static BOOL x11drv_surface_swap( struct opengl_drawable *base )
static void x11drv_egl_surface_destroy( struct opengl_drawable *base ) { - struct gl_drawable *gl = impl_from_opengl_drawable( base ); - - TRACE( "%s\n", debugstr_opengl_drawable( base ) ); - - if (gl->client) client_surface_release( gl->client ); -} - -static void x11drv_egl_surface_detach( struct opengl_drawable *base ) -{ - TRACE( "%s\n", debugstr_opengl_drawable( base ) ); -} - -static void x11drv_egl_surface_update( struct opengl_drawable *base ) -{ - TRACE( "%s\n", debugstr_opengl_drawable( base ) ); + TRACE( "drawable %s\n", debugstr_opengl_drawable( base ) ); }
static void x11drv_egl_surface_flush( struct opengl_drawable *base, UINT flags ) @@ -1508,11 +1476,11 @@ static void x11drv_egl_surface_flush( struct opengl_drawable *base, UINT flags )
if (flags & GL_FLUSH_INTERVAL) funcs->p_eglSwapInterval( egl->display, abs( base->interval ) );
- if (InterlockedCompareExchange( &gl->client->offscreen, 0, 0 )) + if (InterlockedCompareExchange( &base->client->offscreen, 0, 0 )) { if (!(flags & GL_FLUSH_FINISHED)) funcs->p_glFinish(); XFlush( gdi_display ); - client_surface_present( gl->client, gl->hdc ); + client_surface_present( base->client, gl->hdc ); } }
@@ -1524,10 +1492,10 @@ static BOOL x11drv_egl_surface_swap( struct opengl_drawable *base )
funcs->p_eglSwapBuffers( egl->display, gl->base.surface );
- if (InterlockedCompareExchange( &gl->client->offscreen, 0, 0 )) + if (InterlockedCompareExchange( &base->client->offscreen, 0, 0 )) { XFlush( gdi_display ); - client_surface_present( gl->client, gl->hdc ); + client_surface_present( base->client, gl->hdc ); }
return TRUE; @@ -1551,8 +1519,6 @@ static struct opengl_driver_funcs x11drv_driver_funcs = static const struct opengl_drawable_funcs x11drv_surface_funcs = { .destroy = x11drv_surface_destroy, - .detach = x11drv_surface_detach, - .update = x11drv_surface_update, .flush = x11drv_surface_flush, .swap = x11drv_surface_swap, }; @@ -1565,8 +1531,6 @@ static const struct opengl_drawable_funcs x11drv_pbuffer_funcs = static const struct opengl_drawable_funcs x11drv_egl_surface_funcs = { .destroy = x11drv_egl_surface_destroy, - .detach = x11drv_egl_surface_detach, - .update = x11drv_egl_surface_update, .flush = x11drv_egl_surface_flush, .swap = x11drv_egl_surface_swap, }; diff --git a/include/wine/opengl_driver.h b/include/wine/opengl_driver.h index 1e744622dbd..dec9abb0f91 100644 --- a/include/wine/opengl_driver.h +++ b/include/wine/opengl_driver.h @@ -136,10 +136,6 @@ struct opengl_drawable; struct opengl_drawable_funcs { void (*destroy)( struct opengl_drawable *iface ); - /* detach the drawable from its window, called from window owner thread */ - void (*detach)( struct opengl_drawable *drawable ); - /* update the drawable to match its window state, called from window owner thread */ - void (*update)( struct opengl_drawable *drawable ); /* flush and update the drawable front buffer, called from render thread */ void (*flush)( struct opengl_drawable *iface, UINT flags ); /* swap and present the drawable buffers, called from render thread */ @@ -154,23 +150,20 @@ struct opengl_drawable_funcs struct opengl_drawable { const struct opengl_drawable_funcs *funcs; - LONG ref; - - int format; /* pixel format of the drawable */ - int interval; /* last set surface swap interval */ - HWND hwnd; /* window 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 */ + LONG ref; /* reference count */ + struct client_surface *client; /* underlying client surface */ + int format; /* pixel format of the drawable */ + int interval; /* last set surface swap interval */ + EGLSurface surface; /* surface for EGL based drivers */ };
static inline const char *debugstr_opengl_drawable( struct opengl_drawable *drawable ) { if (!drawable) return "(null)"; - return wine_dbg_sprintf( "%p (format %u, hwnd %p)", drawable, drawable->format, drawable->hwnd ); + return wine_dbg_sprintf( "%s/%p (format %u)", debugstr_client_surface( drawable->surface ), drawable, drawable->format ); }
-W32KAPI void *opengl_drawable_create( UINT size, const struct opengl_drawable_funcs *funcs, int format, HWND hwnd ); +W32KAPI void *opengl_drawable_create( UINT size, const struct opengl_drawable_funcs *funcs, int format, struct client_surface *client ); W32KAPI void opengl_drawable_add_ref( struct opengl_drawable *drawable ); W32KAPI void opengl_drawable_release( struct opengl_drawable *drawable );