From: Rémi Bernon rbernon@codeweavers.com
--- dlls/win32u/dce.c | 44 ++++++++++----------------- dlls/win32u/dibdrv/dc.c | 4 +-- dlls/wineandroid.drv/window.c | 42 ++++++++----------------- dlls/winemac.drv/surface.c | 30 ++++-------------- dlls/winemac.drv/window.c | 12 ++++---- dlls/winewayland.drv/window_surface.c | 26 +++------------- dlls/winex11.drv/bitblt.c | 34 +++++---------------- dlls/winex11.drv/window.c | 4 +-- include/wine/gdi_driver.h | 4 +-- 9 files changed, 58 insertions(+), 142 deletions(-)
diff --git a/dlls/win32u/dce.c b/dlls/win32u/dce.c index f62cddd2116..2fa149d8d90 100644 --- a/dlls/win32u/dce.c +++ b/dlls/win32u/dce.c @@ -56,16 +56,6 @@ static pthread_mutex_t surfaces_lock = PTHREAD_MUTEX_INITIALIZER; * Dummy window surface for windows that shouldn't get painted. */
-static void dummy_surface_lock( struct window_surface *window_surface ) -{ - /* nothing to do */ -} - -static void dummy_surface_unlock( struct window_surface *window_surface ) -{ - /* nothing to do */ -} - static void *dummy_surface_get_bitmap_info( struct window_surface *window_surface, BITMAPINFO *info ) { static DWORD dummy_data; @@ -107,8 +97,6 @@ static void dummy_surface_destroy( struct window_surface *window_surface )
static const struct window_surface_funcs dummy_surface_funcs = { - dummy_surface_lock, - dummy_surface_unlock, dummy_surface_get_bitmap_info, dummy_surface_get_bounds, dummy_surface_set_region, @@ -138,16 +126,6 @@ static struct offscreen_window_surface *impl_from_window_surface( struct window_ return CONTAINING_RECORD( base, struct offscreen_window_surface, header ); }
-static void offscreen_window_surface_lock( struct window_surface *surface ) -{ - pthread_mutex_lock( &surface->mutex ); -} - -static void offscreen_window_surface_unlock( struct window_surface *surface ) -{ - pthread_mutex_unlock( &surface->mutex ); -} - static RECT *offscreen_window_surface_get_bounds( struct window_surface *base ) { struct offscreen_window_surface *impl = impl_from_window_surface( base ); @@ -168,9 +146,9 @@ static void offscreen_window_surface_set_region( struct window_surface *base, HR static void offscreen_window_surface_flush( struct window_surface *base ) { struct offscreen_window_surface *impl = impl_from_window_surface( base ); - base->funcs->lock( base ); + window_surface_lock( base ); reset_bounds( &impl->bounds ); - base->funcs->unlock( base ); + window_surface_unlock( base ); }
static void offscreen_window_surface_destroy( struct window_surface *base ) @@ -181,8 +159,6 @@ static void offscreen_window_surface_destroy( struct window_surface *base )
static const struct window_surface_funcs offscreen_window_surface_funcs = { - offscreen_window_surface_lock, - offscreen_window_surface_unlock, offscreen_window_surface_get_bitmap_info, offscreen_window_surface_get_bounds, offscreen_window_surface_set_region, @@ -258,6 +234,18 @@ W32KAPI void window_surface_release( struct window_surface *surface ) } }
+W32KAPI void window_surface_lock( struct window_surface *surface ) +{ + if (surface == &dummy_surface) return; + pthread_mutex_lock( &surface->mutex ); +} + +W32KAPI void window_surface_unlock( struct window_surface *surface ) +{ + if (surface == &dummy_surface) return; + pthread_mutex_unlock( &surface->mutex ); +} + /******************************************************************* * register_window_surface * @@ -1171,12 +1159,12 @@ static void copy_bits_from_surface( HWND hwnd, struct window_surface *surface, else { bits = surface->funcs->get_info( surface, info ); - surface->funcs->lock( surface ); + window_surface_lock( surface ); NtGdiSetDIBitsToDeviceInternal( hdc, dst->left, dst->top, dst->right - dst->left, dst->bottom - dst->top, src->left - surface->rect.left, surface->rect.bottom - src->bottom, 0, surface->rect.bottom - surface->rect.top, bits, info, DIB_RGB_COLORS, 0, 0, FALSE, NULL ); - surface->funcs->unlock( surface ); + window_surface_unlock( surface ); }
NtUserReleaseDC( hwnd, hdc ); diff --git a/dlls/win32u/dibdrv/dc.c b/dlls/win32u/dibdrv/dc.c index 48cbe51d708..f1e5f2c9d6b 100644 --- a/dlls/win32u/dibdrv/dc.c +++ b/dlls/win32u/dibdrv/dc.c @@ -751,7 +751,7 @@ static inline void lock_surface( struct windrv_physdev *dev )
if (!dev->lock_count++) { - surface->funcs->lock( surface ); + window_surface_lock( surface ); if (IsRectEmpty( dev->dibdrv->bounds ) || !surface->draw_start_ticks) surface->draw_start_ticks = NtGetTickCount(); } @@ -764,7 +764,7 @@ static inline void unlock_surface( struct windrv_physdev *dev ) if (!--dev->lock_count) { DWORD ticks = NtGetTickCount() - surface->draw_start_ticks; - surface->funcs->unlock( surface ); + window_surface_unlock( surface ); if (ticks > FLUSH_PERIOD) surface->funcs->flush( dev->surface ); } } diff --git a/dlls/wineandroid.drv/window.c b/dlls/wineandroid.drv/window.c index ac6b211a34c..669ad7a6b2e 100644 --- a/dlls/wineandroid.drv/window.c +++ b/dlls/wineandroid.drv/window.c @@ -645,22 +645,6 @@ static void apply_line_region( DWORD *dst, int width, int x, int y, const RECT * if (width > 0) memset( dst, 0, width * sizeof(*dst) ); }
-/*********************************************************************** - * android_surface_lock - */ -static void android_surface_lock( struct window_surface *window_surface ) -{ - pthread_mutex_lock( &window_surface->mutex ); -} - -/*********************************************************************** - * android_surface_unlock - */ -static void android_surface_unlock( struct window_surface *window_surface ) -{ - pthread_mutex_unlock( &window_surface->mutex ); -} - /*********************************************************************** * android_surface_get_bitmap_info */ @@ -691,7 +675,7 @@ static void android_surface_set_region( struct window_surface *window_surface, H
TRACE( "updating surface %p hwnd %p with %p\n", surface, surface->hwnd, region );
- window_surface->funcs->lock( window_surface ); + window_surface_lock( window_surface ); if (!region) { if (surface->region) NtGdiDeleteObjectApp( surface->region ); @@ -702,7 +686,7 @@ static void android_surface_set_region( struct window_surface *window_surface, H if (!surface->region) surface->region = NtGdiCreateRectRgn( 0, 0, 0, 0 ); NtGdiCombineRgn( surface->region, region, 0, RGN_COPY ); } - window_surface->funcs->unlock( window_surface ); + window_surface_unlock( window_surface ); set_surface_region( &surface->header, (HRGN)1 ); }
@@ -717,12 +701,12 @@ static void android_surface_flush( struct window_surface *window_surface ) RECT rect; BOOL needs_flush;
- window_surface->funcs->lock( window_surface ); + window_surface_lock( window_surface ); SetRect( &rect, 0, 0, surface->header.rect.right - surface->header.rect.left, surface->header.rect.bottom - surface->header.rect.top ); needs_flush = intersect_rect( &rect, &rect, &surface->bounds ); reset_bounds( &surface->bounds ); - window_surface->funcs->unlock( window_surface ); + window_surface_unlock( window_surface ); if (!needs_flush) return;
TRACE( "flushing %p hwnd %p surface %s rect %s bits %p alpha %02x key %08x region %u rects\n", @@ -807,8 +791,6 @@ static void android_surface_destroy( struct window_surface *window_surface )
static const struct window_surface_funcs android_surface_funcs = { - android_surface_lock, - android_surface_unlock, android_surface_get_bitmap_info, android_surface_get_bounds, android_surface_set_region, @@ -880,11 +862,11 @@ static void set_surface_region( struct window_surface *window_surface, HRGN win_ }
done: - window_surface->funcs->lock( window_surface ); + window_surface_lock( window_surface ); free( surface->region_data ); surface->region_data = data; *window_surface->funcs->get_bounds( window_surface ) = surface->header.rect; - window_surface->funcs->unlock( window_surface ); + window_surface_unlock( window_surface ); if (region != win_region) NtGdiDeleteObjectApp( region ); }
@@ -938,14 +920,14 @@ static void set_surface_layered( struct window_surface *window_surface, BYTE alp
if (window_surface->funcs != &android_surface_funcs) return; /* we may get the null surface */
- window_surface->funcs->lock( window_surface ); + window_surface_lock( window_surface ); prev_key = surface->color_key; prev_alpha = surface->alpha; surface->alpha = alpha; set_color_key( surface, color_key ); if (alpha != prev_alpha || surface->color_key != prev_key) /* refresh */ *window_surface->funcs->get_bounds( window_surface ) = surface->header.rect; - window_surface->funcs->unlock( window_surface ); + window_surface_unlock( window_surface ); }
/*********************************************************************** @@ -1577,7 +1559,7 @@ BOOL ANDROID_UpdateLayeredWindow( HWND hwnd, const UPDATELAYEREDWINDOWINFO *info
NtGdiSelectBitmap( hdc, dib );
- surface->funcs->lock( surface ); + window_surface_lock( surface );
if (info->prcDirty) { @@ -1600,7 +1582,7 @@ BOOL ANDROID_UpdateLayeredWindow( HWND hwnd, const UPDATELAYEREDWINDOWINFO *info add_bounds_rect( surface->funcs->get_bounds( surface ), &rect ); }
- surface->funcs->unlock( surface ); + window_surface_unlock( surface ); surface->funcs->flush( surface );
done: @@ -1630,9 +1612,9 @@ LRESULT ANDROID_WindowMessage( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp ) struct window_surface *surface = data->surface; if (surface) { - surface->funcs->lock( surface ); + window_surface_lock( surface ); *surface->funcs->get_bounds( surface ) = surface->rect; - surface->funcs->unlock( surface ); + window_surface_unlock( surface ); if (is_argb_surface( surface )) surface->funcs->flush( surface ); } release_win_data( data ); diff --git a/dlls/winemac.drv/surface.c b/dlls/winemac.drv/surface.c index d2c156adb5d..82cf7f57eb7 100644 --- a/dlls/winemac.drv/surface.c +++ b/dlls/winemac.drv/surface.c @@ -96,22 +96,6 @@ static void update_blit_data(struct macdrv_window_surface *surface) } }
-/*********************************************************************** - * macdrv_surface_lock - */ -static void macdrv_surface_lock(struct window_surface *window_surface) -{ - pthread_mutex_lock(&window_surface->mutex); -} - -/*********************************************************************** - * macdrv_surface_unlock - */ -static void macdrv_surface_unlock(struct window_surface *window_surface) -{ - pthread_mutex_unlock(&window_surface->mutex); -} - /*********************************************************************** * macdrv_surface_get_bitmap_info */ @@ -143,7 +127,7 @@ static void macdrv_surface_set_region(struct window_surface *window_surface, HRG
TRACE("updating surface %p with %p\n", surface, region);
- window_surface->funcs->lock(window_surface); + window_surface_lock(window_surface);
if (region) { @@ -157,7 +141,7 @@ static void macdrv_surface_set_region(struct window_surface *window_surface, HRG } update_blit_data(surface);
- window_surface->funcs->unlock(window_surface); + window_surface_unlock(window_surface); }
/*********************************************************************** @@ -169,7 +153,7 @@ static void macdrv_surface_flush(struct window_surface *window_surface) CGRect rect; HRGN region;
- window_surface->funcs->lock(window_surface); + window_surface_lock(window_surface);
TRACE("flushing %p %s bounds %s bits %p\n", surface, wine_dbgstr_rect(&surface->header.rect), wine_dbgstr_rect(&surface->bounds), surface->bits); @@ -192,7 +176,7 @@ static void macdrv_surface_flush(struct window_surface *window_surface) update_blit_data(surface); reset_bounds(&surface->bounds);
- window_surface->funcs->unlock(window_surface); + window_surface_unlock(window_surface);
if (!CGRectIsEmpty(rect)) macdrv_window_needs_display(surface->window, rect); @@ -215,8 +199,6 @@ static void macdrv_surface_destroy(struct window_surface *window_surface)
static const struct window_surface_funcs macdrv_surface_funcs = { - macdrv_surface_lock, - macdrv_surface_unlock, macdrv_surface_get_bitmap_info, macdrv_surface_get_bounds, macdrv_surface_set_region, @@ -427,7 +409,7 @@ void surface_clip_to_visible_rect(struct window_surface *window_surface, const R struct macdrv_window_surface *surface = get_mac_surface(window_surface);
if (!surface) return; - window_surface->funcs->lock(window_surface); + window_surface_lock(window_surface);
if (surface->drawn) { @@ -446,5 +428,5 @@ void surface_clip_to_visible_rect(struct window_surface *window_surface, const R } }
- window_surface->funcs->unlock(window_surface); + window_surface_unlock(window_surface); } diff --git a/dlls/winemac.drv/window.c b/dlls/winemac.drv/window.c index a04ff5fd4c9..d04ebe39bfa 100644 --- a/dlls/winemac.drv/window.c +++ b/dlls/winemac.drv/window.c @@ -509,10 +509,10 @@ static void sync_window_opacity(struct macdrv_win_data *data, COLORREF key, BYTE
rect = data->whole_rect; OffsetRect(&rect, -data->whole_rect.left, -data->whole_rect.top); - data->surface->funcs->lock(data->surface); + window_surface_lock(data->surface); bounds = data->surface->funcs->get_bounds(data->surface); add_bounds_rect(bounds, &rect); - data->surface->funcs->unlock(data->surface); + window_surface_unlock(data->surface); } }
@@ -1964,9 +1964,9 @@ BOOL macdrv_UpdateLayeredWindow(HWND hwnd, const UPDATELAYEREDWINDOWINFO *info, if (info->prcDirty) { intersect_rect(&rect, &rect, info->prcDirty); - surface->funcs->lock(surface); + window_surface_lock(surface); memcpy(src_bits, dst_bits, bmi->bmiHeader.biSizeImage); - surface->funcs->unlock(surface); + window_surface_unlock(surface); NtGdiPatBlt(hdc, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, BLACKNESS); } src_rect = rect; @@ -1983,10 +1983,10 @@ BOOL macdrv_UpdateLayeredWindow(HWND hwnd, const UPDATELAYEREDWINDOWINFO *info, { if (surface == data->surface) { - surface->funcs->lock(surface); + window_surface_lock(surface); memcpy(dst_bits, src_bits, bmi->bmiHeader.biSizeImage); add_bounds_rect(surface->funcs->get_bounds(surface), &rect); - surface->funcs->unlock(surface); + window_surface_unlock(surface); surface->funcs->flush(surface); }
diff --git a/dlls/winewayland.drv/window_surface.c b/dlls/winewayland.drv/window_surface.c index 47ccb8c0213..4c8d3956408 100644 --- a/dlls/winewayland.drv/window_surface.c +++ b/dlls/winewayland.drv/window_surface.c @@ -218,22 +218,6 @@ static void wayland_buffer_queue_add_damage(struct wayland_buffer_queue *queue, } }
-/*********************************************************************** - * wayland_window_surface_lock - */ -static void wayland_window_surface_lock(struct window_surface *window_surface) -{ - pthread_mutex_lock(&window_surface->mutex); -} - -/*********************************************************************** - * wayland_window_surface_unlock - */ -static void wayland_window_surface_unlock(struct window_surface *window_surface) -{ - pthread_mutex_unlock(&window_surface->mutex); -} - /*********************************************************************** * wayland_window_surface_get_bitmap_info */ @@ -376,7 +360,7 @@ static void wayland_window_surface_flush(struct window_surface *window_surface) HRGN surface_damage_region = NULL; HRGN copy_from_window_region;
- wayland_window_surface_lock(window_surface); + window_surface_lock(window_surface);
if (!intersect_rect(&damage_rect, &wws->header.rect, &wws->bounds)) goto done;
@@ -466,7 +450,7 @@ static void wayland_window_surface_flush(struct window_surface *window_surface) done: if (flushed) reset_bounds(&wws->bounds); if (surface_damage_region) NtGdiDeleteObjectApp(surface_damage_region); - wayland_window_surface_unlock(window_surface); + window_surface_unlock(window_surface); }
/*********************************************************************** @@ -486,8 +470,6 @@ static void wayland_window_surface_destroy(struct window_surface *window_surface
static const struct window_surface_funcs wayland_window_surface_funcs = { - wayland_window_surface_lock, - wayland_window_surface_unlock, wayland_window_surface_get_bitmap_info, wayland_window_surface_get_bounds, wayland_window_surface_set_region, @@ -543,7 +525,7 @@ void wayland_window_surface_update_wayland_surface(struct window_surface *window { struct wayland_window_surface *wws = wayland_window_surface_cast(window_surface);
- wayland_window_surface_lock(window_surface); + window_surface_lock(window_surface);
TRACE("surface=%p hwnd=%p wayland_surface=%p\n", wws, wws->hwnd, wayland_surface);
@@ -562,5 +544,5 @@ void wayland_window_surface_update_wayland_surface(struct window_surface *window wws->wayland_buffer_queue = NULL; }
- wayland_window_surface_unlock(window_surface); + window_surface_unlock(window_surface); } diff --git a/dlls/winex11.drv/bitblt.c b/dlls/winex11.drv/bitblt.c index bb4b11be866..c19836c31a3 100644 --- a/dlls/winex11.drv/bitblt.c +++ b/dlls/winex11.drv/bitblt.c @@ -1827,22 +1827,6 @@ failed: } #endif /* HAVE_LIBXXSHM */
-/*********************************************************************** - * x11drv_surface_lock - */ -static void x11drv_surface_lock( struct window_surface *window_surface ) -{ - pthread_mutex_lock( &window_surface->mutex ); -} - -/*********************************************************************** - * x11drv_surface_unlock - */ -static void x11drv_surface_unlock( struct window_surface *window_surface ) -{ - pthread_mutex_unlock( &window_surface->mutex ); -} - /*********************************************************************** * x11drv_surface_get_bitmap_info */ @@ -1874,7 +1858,7 @@ static void x11drv_surface_set_region( struct window_surface *window_surface, HR
TRACE( "updating surface %p with %p\n", surface, region );
- window_surface->funcs->lock( window_surface ); + window_surface_lock( window_surface ); if (!region) { if (surface->region) NtGdiDeleteObjectApp( surface->region ); @@ -1892,7 +1876,7 @@ static void x11drv_surface_set_region( struct window_surface *window_surface, HR free( data ); } } - window_surface->funcs->unlock( window_surface ); + window_surface_unlock( window_surface ); }
/*********************************************************************** @@ -1905,7 +1889,7 @@ static void x11drv_surface_flush( struct window_surface *window_surface ) unsigned char *dst = (unsigned char *)surface->image->data; struct bitblt_coords coords;
- window_surface->funcs->lock( window_surface ); + window_surface_lock( window_surface ); coords.x = 0; coords.y = 0; coords.width = surface->header.rect.right - surface->header.rect.left; @@ -1959,7 +1943,7 @@ static void x11drv_surface_flush( struct window_surface *window_surface ) XFlush( gdi_display ); } reset_bounds( &surface->bounds ); - window_surface->funcs->unlock( window_surface ); + window_surface_unlock( window_surface ); }
/*********************************************************************** @@ -1993,8 +1977,6 @@ static void x11drv_surface_destroy( struct window_surface *window_surface )
static const struct window_surface_funcs x11drv_surface_funcs = { - x11drv_surface_lock, - x11drv_surface_unlock, x11drv_surface_get_bitmap_info, x11drv_surface_get_bounds, x11drv_surface_set_region, @@ -2078,11 +2060,11 @@ void set_surface_color_key( struct window_surface *window_surface, COLORREF colo
if (window_surface->funcs != &x11drv_surface_funcs) return; /* we may get the null surface */
- window_surface->funcs->lock( window_surface ); + window_surface_lock( window_surface ); prev = surface->color_key; set_color_key( surface, color_key ); if (surface->color_key != prev) update_surface_region( surface ); - window_surface->funcs->unlock( window_surface ); + window_surface_unlock( window_surface ); }
/*********************************************************************** @@ -2096,7 +2078,7 @@ HRGN expose_surface( struct window_surface *window_surface, const RECT *rect )
if (window_surface->funcs != &x11drv_surface_funcs) return 0; /* we may get the null surface */
- window_surface->funcs->lock( window_surface ); + window_surface_lock( window_surface ); OffsetRect( &rc, -window_surface->rect.left, -window_surface->rect.top ); add_bounds_rect( &surface->bounds, &rc ); if (surface->region) @@ -2108,6 +2090,6 @@ HRGN expose_surface( struct window_surface *window_surface, const RECT *rect ) region = 0; } } - window_surface->funcs->unlock( window_surface ); + window_surface_unlock( window_surface ); return region; } diff --git a/dlls/winex11.drv/window.c b/dlls/winex11.drv/window.c index c6bf49c6ec8..eb9c5d4d8a8 100644 --- a/dlls/winex11.drv/window.c +++ b/dlls/winex11.drv/window.c @@ -3026,7 +3026,7 @@ BOOL X11DRV_UpdateLayeredWindow( HWND hwnd, const UPDATELAYEREDWINDOWINFO *info,
NtGdiSelectBitmap( hdc, dib );
- surface->funcs->lock( surface ); + window_surface_lock( surface );
if (info->prcDirty) { @@ -3049,7 +3049,7 @@ BOOL X11DRV_UpdateLayeredWindow( HWND hwnd, const UPDATELAYEREDWINDOWINFO *info, add_bounds_rect( surface->funcs->get_bounds( surface ), &rect ); }
- surface->funcs->unlock( surface ); + window_surface_unlock( surface ); surface->funcs->flush( surface );
done: diff --git a/include/wine/gdi_driver.h b/include/wine/gdi_driver.h index 53555db972b..0104cdbe8ba 100644 --- a/include/wine/gdi_driver.h +++ b/include/wine/gdi_driver.h @@ -211,8 +211,6 @@ struct window_surface;
struct window_surface_funcs { - void (*lock)( struct window_surface *surface ); - void (*unlock)( struct window_surface *surface ); void* (*get_info)( struct window_surface *surface, BITMAPINFO *info ); RECT* (*get_bounds)( struct window_surface *surface ); void (*set_region)( struct window_surface *surface, HRGN region ); @@ -235,6 +233,8 @@ struct window_surface W32KAPI void window_surface_init( struct window_surface *surface, const struct window_surface_funcs *funcs, const RECT *rect ); W32KAPI void window_surface_add_ref( struct window_surface *surface ); W32KAPI void window_surface_release( struct window_surface *surface ); +W32KAPI void window_surface_lock( struct window_surface *surface ); +W32KAPI void window_surface_unlock( struct window_surface *surface );
/* display manager interface, used to initialize display device registry data */