Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/gdi32/dibdrv/dc.c | 6 ++--- dlls/user32/painting.c | 4 +-- dlls/wineandroid.drv/window.c | 48 ++++++++++------------------------- dlls/winemac.drv/surface.c | 12 ++++----- dlls/winemac.drv/window.c | 12 ++++----- dlls/winex11.drv/bitblt.c | 40 ++++++++--------------------- dlls/winex11.drv/window.c | 4 +-- include/wine/gdi_driver.h | 12 +++++++++ 8 files changed, 55 insertions(+), 83 deletions(-)
diff --git a/dlls/gdi32/dibdrv/dc.c b/dlls/gdi32/dibdrv/dc.c index 7fd404fc2cb..f8b26dc2b8e 100644 --- a/dlls/gdi32/dibdrv/dc.c +++ b/dlls/gdi32/dibdrv/dc.c @@ -784,20 +784,20 @@ static inline struct windrv_physdev *get_windrv_physdev( PHYSDEV dev ) static inline void lock_surface( struct windrv_physdev *dev ) { GDI_CheckNotLock(); - dev->surface->funcs->lock( dev->surface ); + window_surface_lock( dev->surface ); if (is_rect_empty( dev->dibdrv->bounds )) dev->start_ticks = GetTickCount(); }
static inline void unlock_surface( struct windrv_physdev *dev ) { - dev->surface->funcs->unlock( dev->surface ); + window_surface_unlock( dev->surface ); if (GetTickCount() - dev->start_ticks > FLUSH_PERIOD) dev->surface->funcs->flush( dev->surface ); }
static void CDECL unlock_bits_surface( struct gdi_image_bits *bits ) { struct window_surface *surface = bits->param; - surface->funcs->unlock( surface ); + window_surface_unlock( surface ); }
void dibdrv_set_window_surface( DC *dc, struct window_surface *surface ) diff --git a/dlls/user32/painting.c b/dlls/user32/painting.c index db244ff04a5..47ea45ee86d 100644 --- a/dlls/user32/painting.c +++ b/dlls/user32/painting.c @@ -777,12 +777,12 @@ static void copy_bits_from_surface( HWND hwnd, struct window_surface *surface, HDC hdc = GetDCEx( hwnd, rgn, DCX_CACHE | DCX_WINDOW | DCX_EXCLUDERGN );
bits = surface->funcs->get_info( surface, info ); - surface->funcs->lock( surface ); + window_surface_lock( surface ); SetDIBitsToDevice( 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 ); - surface->funcs->unlock( surface ); + window_surface_unlock( surface ); ReleaseDC( hwnd, hdc ); }
diff --git a/dlls/wineandroid.drv/window.c b/dlls/wineandroid.drv/window.c index 902f5980d13..53b0ef5a11e 100644 --- a/dlls/wineandroid.drv/window.c +++ b/dlls/wineandroid.drv/window.c @@ -652,26 +652,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 CDECL android_surface_lock( struct window_surface *window_surface ) -{ - struct android_window_surface *surface = get_android_surface( window_surface ); - - EnterCriticalSection( &surface->header.cs ); -} - -/*********************************************************************** - * android_surface_unlock - */ -static void CDECL android_surface_unlock( struct window_surface *window_surface ) -{ - struct android_window_surface *surface = get_android_surface( window_surface ); - - LeaveCriticalSection( &surface->header.cs ); -} - /*********************************************************************** * android_surface_get_bitmap_info */ @@ -702,7 +682,7 @@ static void CDECL android_surface_set_region( struct window_surface *window_surf
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) DeleteObject( surface->region ); @@ -713,7 +693,7 @@ static void CDECL android_surface_set_region( struct window_surface *window_surf if (!surface->region) surface->region = CreateRectRgn( 0, 0, 0, 0 ); CombineRgn( surface->region, region, 0, RGN_COPY ); } - window_surface->funcs->unlock( window_surface ); + window_surface_unlock( window_surface ); set_surface_region( &surface->header, (HRGN)1 ); }
@@ -728,12 +708,12 @@ static void CDECL 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 = IntersectRect( &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", @@ -820,8 +800,8 @@ static void CDECL android_surface_destroy( struct window_surface *window_surface
static const struct window_surface_funcs android_surface_funcs = { - android_surface_lock, - android_surface_unlock, + NULL, + NULL, android_surface_get_bitmap_info, android_surface_get_bounds, android_surface_set_region, @@ -893,11 +873,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 ); HeapFree( GetProcessHeap(), 0, 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) DeleteObject( region ); }
@@ -956,14 +936,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 ); }
/*********************************************************************** @@ -1582,7 +1562,7 @@ BOOL CDECL ANDROID_UpdateLayeredWindow( HWND hwnd, const UPDATELAYEREDWINDOWINFO
SelectObject( hdc, dib );
- surface->funcs->lock( surface ); + window_surface_lock( surface );
if (info->prcDirty) { @@ -1604,7 +1584,7 @@ BOOL CDECL ANDROID_UpdateLayeredWindow( HWND hwnd, const UPDATELAYEREDWINDOWINFO add_bounds_rect( surface->funcs->get_bounds( surface ), &rect ); }
- surface->funcs->unlock( surface ); + window_surface_unlock( surface ); surface->funcs->flush( surface );
done: @@ -1634,9 +1614,9 @@ LRESULT CDECL 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 7be1b6850e0..65bbe31b89d 100644 --- a/dlls/winemac.drv/surface.c +++ b/dlls/winemac.drv/surface.c @@ -144,7 +144,7 @@ static void CDECL macdrv_surface_set_region(struct window_surface *window_surfac
TRACE("updating surface %p with %p\n", surface, region);
- window_surface->funcs->lock(window_surface); + window_surface_lock(window_surface);
if (region) { @@ -158,7 +158,7 @@ static void CDECL macdrv_surface_set_region(struct window_surface *window_surfac } update_blit_data(surface);
- window_surface->funcs->unlock(window_surface); + window_surface_unlock(window_surface); }
/*********************************************************************** @@ -170,7 +170,7 @@ static void CDECL 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); @@ -191,7 +191,7 @@ static void CDECL 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); @@ -428,7 +428,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) { @@ -447,5 +447,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 e7f5327fcdc..f2f53520e31 100644 --- a/dlls/winemac.drv/window.c +++ b/dlls/winemac.drv/window.c @@ -507,10 +507,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); } }
@@ -1938,9 +1938,9 @@ BOOL CDECL macdrv_UpdateLayeredWindow(HWND hwnd, const UPDATELAYEREDWINDOWINFO * if (info->prcDirty) { IntersectRect(&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); PatBlt(hdc, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, BLACKNESS); } src_rect = rect; @@ -1957,10 +1957,10 @@ BOOL CDECL macdrv_UpdateLayeredWindow(HWND hwnd, const UPDATELAYEREDWINDOWINFO * { 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/winex11.drv/bitblt.c b/dlls/winex11.drv/bitblt.c index b931fd88da3..731be11a181 100644 --- a/dlls/winex11.drv/bitblt.c +++ b/dlls/winex11.drv/bitblt.c @@ -1813,26 +1813,6 @@ failed: } #endif /* HAVE_LIBXXSHM */
-/*********************************************************************** - * x11drv_surface_lock - */ -static void CDECL x11drv_surface_lock( struct window_surface *window_surface ) -{ - struct x11drv_window_surface *surface = get_x11_surface( window_surface ); - - EnterCriticalSection( &surface->header.cs ); -} - -/*********************************************************************** - * x11drv_surface_unlock - */ -static void CDECL x11drv_surface_unlock( struct window_surface *window_surface ) -{ - struct x11drv_window_surface *surface = get_x11_surface( window_surface ); - - LeaveCriticalSection( &surface->header.cs ); -} - /*********************************************************************** * x11drv_surface_get_bitmap_info */ @@ -1864,7 +1844,7 @@ static void CDECL x11drv_surface_set_region( struct window_surface *window_surfa
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) DeleteObject( surface->region ); @@ -1882,7 +1862,7 @@ static void CDECL x11drv_surface_set_region( struct window_surface *window_surfa HeapFree( GetProcessHeap(), 0, data ); } } - window_surface->funcs->unlock( window_surface ); + window_surface_unlock( window_surface ); }
/*********************************************************************** @@ -1895,7 +1875,7 @@ static void CDECL 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; @@ -1949,7 +1929,7 @@ static void CDECL 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 ); }
/*********************************************************************** @@ -1984,8 +1964,8 @@ static void CDECL x11drv_surface_destroy( struct window_surface *window_surface
static const struct window_surface_funcs x11drv_surface_funcs = { - x11drv_surface_lock, - x11drv_surface_unlock, + NULL, + NULL, x11drv_surface_get_bitmap_info, x11drv_surface_get_bounds, x11drv_surface_set_region, @@ -2075,11 +2055,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 ); }
/*********************************************************************** @@ -2093,7 +2073,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) @@ -2105,6 +2085,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 b3ae5c54408..c79305963b9 100644 --- a/dlls/winex11.drv/window.c +++ b/dlls/winex11.drv/window.c @@ -2742,7 +2742,7 @@ BOOL CDECL X11DRV_UpdateLayeredWindow( HWND hwnd, const UPDATELAYEREDWINDOWINFO
SelectObject( hdc, dib );
- surface->funcs->lock( surface ); + window_surface_lock( surface );
if (info->prcDirty) { @@ -2764,7 +2764,7 @@ BOOL CDECL X11DRV_UpdateLayeredWindow( HWND hwnd, const UPDATELAYEREDWINDOWINFO 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 6c700664eb5..0667b3758a3 100644 --- a/include/wine/gdi_driver.h +++ b/include/wine/gdi_driver.h @@ -268,6 +268,18 @@ static inline ULONG window_surface_release( struct window_surface *surface ) return ret; }
+static inline void window_surface_lock( struct window_surface *surface ) +{ + if (surface->funcs->lock) surface->funcs->lock( surface ); + else EnterCriticalSection( &surface->cs ); +} + +static inline void window_surface_unlock( struct window_surface *surface ) +{ + if (surface->funcs->unlock) surface->funcs->unlock( surface ); + else LeaveCriticalSection( &surface->cs ); +} + /* the DC hook support is only exported on Win16, the 32-bit version is a Wine extension */
#define DCHC_INVALIDVISRGN 0x0001