Module: wine Branch: master Commit: ec700bb712c0bf3b051333754c8faf0f9b4de1ad URL: https://gitlab.winehq.org/wine/wine/-/commit/ec700bb712c0bf3b051333754c8faf0...
Author: Rémi Bernon rbernon@codeweavers.com Date: Mon Mar 4 17:10:08 2024 +0100
win32u: Flush window surface when it is fully unlocked.
---
dlls/win32u/dibdrv/dc.c | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-)
diff --git a/dlls/win32u/dibdrv/dc.c b/dlls/win32u/dibdrv/dc.c index 38039e7d6ae..e1b2f66cb25 100644 --- a/dlls/win32u/dibdrv/dc.c +++ b/dlls/win32u/dibdrv/dc.c @@ -734,6 +734,7 @@ struct windrv_physdev struct gdi_physdev dev; struct dibdrv_physdev *dibdrv; struct window_surface *surface; + UINT lock_count; };
static const struct gdi_dc_funcs window_driver; @@ -743,25 +744,34 @@ static inline struct windrv_physdev *get_windrv_physdev( PHYSDEV dev ) return (struct windrv_physdev *)dev; }
+/* gdi_lock should not be locked */ static inline void lock_surface( struct windrv_physdev *dev ) { - /* gdi_lock should not be locked */ - dev->surface->funcs->lock( dev->surface ); - if (IsRectEmpty( dev->dibdrv->bounds ) || dev->surface->draw_start_ticks == 0) - dev->surface->draw_start_ticks = NtGetTickCount(); + struct window_surface *surface = dev->surface; + + surface->funcs->lock( surface ); + if (!dev->lock_count++) + { + if (IsRectEmpty( dev->dibdrv->bounds ) || !surface->draw_start_ticks) + surface->draw_start_ticks = NtGetTickCount(); + } }
static inline void unlock_surface( struct windrv_physdev *dev ) { - BOOL should_flush = NtGetTickCount() - dev->surface->draw_start_ticks > FLUSH_PERIOD; - dev->surface->funcs->unlock( dev->surface ); - if (should_flush) dev->surface->funcs->flush( dev->surface ); + struct window_surface *surface = dev->surface; + + surface->funcs->unlock( surface ); + if (!--dev->lock_count) + { + DWORD ticks = NtGetTickCount() - surface->draw_start_ticks; + if (ticks > FLUSH_PERIOD) surface->funcs->flush( dev->surface ); + } }
-static void unlock_bits_surface( struct gdi_image_bits *bits ) +static void unlock_windrv_bits( struct gdi_image_bits *bits ) { - struct window_surface *surface = bits->param; - surface->funcs->unlock( surface ); + unlock_surface( bits->param ); }
void dibdrv_set_window_surface( DC *dc, struct window_surface *surface ) @@ -964,8 +974,8 @@ static DWORD windrv_GetImage( PHYSDEV dev, BITMAPINFO *info, { /* use the freeing callback to unlock the surface */ assert( !bits->free ); - bits->free = unlock_bits_surface; - bits->param = physdev->surface; + bits->free = unlock_windrv_bits; + bits->param = physdev; } else unlock_surface( physdev ); return ret;