From: Rémi Bernon rbernon@codeweavers.com
--- dlls/win32u/dce.c | 50 ++++++++++++++++-------------------- dlls/win32u/dibdrv/dc.c | 18 ++----------- dlls/win32u/input.c | 4 +-- dlls/win32u/message.c | 5 ---- dlls/win32u/win32u_private.h | 2 -- dlls/win32u/window.c | 1 - 6 files changed, 25 insertions(+), 55 deletions(-)
diff --git a/dlls/win32u/dce.c b/dlls/win32u/dce.c index 71ee85d64e1..79561b109af 100644 --- a/dlls/win32u/dce.c +++ b/dlls/win32u/dce.c @@ -53,6 +53,8 @@ static struct list dce_list = LIST_INIT(dce_list); static struct list window_surfaces = LIST_INIT( window_surfaces ); static pthread_mutex_t surfaces_lock = PTHREAD_MUTEX_INITIALIZER;
+static void window_surface_flush( struct window_surface *surface ); + /******************************************************************* * Dummy window surface for windows that shouldn't get painted. */ @@ -270,6 +272,18 @@ static RECT get_surface_rect( RECT rect ) return rect; }
+static struct window_surface *window_get_surface( HWND hwnd ) +{ + struct window_surface *surface; + WND *win; + + if (!(win = get_win_ptr( hwnd ))) return NULL; + if ((surface = win->surface)) window_surface_add_ref( surface ); + release_win_ptr( win ); + + return surface; +} + void create_window_surface( HWND hwnd, BOOL create_layered, const RECT *surface_rect, UINT monitor_dpi, struct window_surface **window_surface ) { @@ -606,7 +620,7 @@ static void *window_surface_get_color( struct window_surface *surface, BITMAPINF return gdi_bits.ptr; }
-void window_surface_flush( struct window_surface *surface ) +static void window_surface_flush( struct window_surface *surface ) { char color_buf[FIELD_OFFSET( BITMAPINFO, bmiColors[256] )]; char shape_buf[FIELD_OFFSET( BITMAPINFO, bmiColors[256] )]; @@ -721,13 +735,17 @@ void window_surface_set_shape( struct window_surface *surface, HRGN shape_region }
window_surface_unlock( surface ); - - window_surface_flush( surface ); }
void process_wine_present( HWND hwnd ) { - FIXME( "stub!\n" ); + struct window_surface *surface; + + TRACE( "hwnd %p\n", hwnd ); + + if (!(surface = window_get_surface( hwnd ))) return; + window_surface_flush( surface ); + window_surface_release( surface ); }
/******************************************************************* @@ -746,29 +764,6 @@ void register_window_surface( struct window_surface *old, struct window_surface pthread_mutex_unlock( &surfaces_lock ); }
-/******************************************************************* - * flush_window_surfaces - * - * Flush pending output from all window surfaces. - */ -void flush_window_surfaces( BOOL idle ) -{ - static DWORD last_idle; - DWORD now; - struct window_surface *surface; - - pthread_mutex_lock( &surfaces_lock ); - now = NtGetTickCount(); - if (idle) last_idle = now; - /* if not idle, we only flush if there's evidence that the app never goes idle */ - else if ((int)(now - last_idle) < 50) goto done; - - LIST_FOR_EACH_ENTRY( surface, &window_surfaces, struct window_surface, entry ) - window_surface_flush( surface ); -done: - pthread_mutex_unlock( &surfaces_lock ); -} - /*********************************************************************** * dump_rdw_flags */ @@ -1729,7 +1724,6 @@ HDC WINAPI NtUserBeginPaint( HWND hwnd, PAINTSTRUCT *ps ) BOOL WINAPI NtUserEndPaint( HWND hwnd, const PAINTSTRUCT *ps ) { NtUserShowCaret( hwnd ); - flush_window_surfaces( FALSE ); if (!ps) return FALSE; release_dc( hwnd, ps->hdc, TRUE ); return TRUE; diff --git a/dlls/win32u/dibdrv/dc.c b/dlls/win32u/dibdrv/dc.c index 8a72d9789ea..e50c2e9245e 100644 --- a/dlls/win32u/dibdrv/dc.c +++ b/dlls/win32u/dibdrv/dc.c @@ -496,8 +496,6 @@ const struct gdi_dc_funcs dib_driver = * can paint to the same window. */
-#define FLUSH_PERIOD 50 /* time in ms since drawing started for forcing a surface flush */ - struct windrv_physdev { struct gdi_physdev dev; @@ -517,25 +515,13 @@ static inline struct windrv_physdev *get_windrv_physdev( PHYSDEV dev ) static inline void lock_surface( struct windrv_physdev *dev ) { struct window_surface *surface = dev->surface; - - if (!dev->lock_count++) - { - window_surface_lock( surface ); - if (IsRectEmpty( dev->dibdrv->bounds ) || !surface->draw_start_ticks) - surface->draw_start_ticks = NtGetTickCount(); - } + if (!dev->lock_count++) window_surface_lock( surface ); }
static inline void unlock_surface( struct windrv_physdev *dev ) { struct window_surface *surface = dev->surface; - - if (!--dev->lock_count) - { - DWORD ticks = NtGetTickCount() - surface->draw_start_ticks; - window_surface_unlock( surface ); - if (ticks > FLUSH_PERIOD) window_surface_flush( dev->surface ); - } + if (!--dev->lock_count) window_surface_unlock( surface ); }
static inline void lock_surfaces( struct windrv_physdev *dst_dev, struct windrv_physdev *src_dev ) diff --git a/dlls/win32u/input.c b/dlls/win32u/input.c index c718bd1cbbc..b5ad3d1c027 100644 --- a/dlls/win32u/input.c +++ b/dlls/win32u/input.c @@ -796,9 +796,7 @@ static void check_for_events( UINT flags ) }; MSG msg;
- if (!user_driver->pProcessEvents( flags )) - flush_window_surfaces( TRUE ); - + user_driver->pProcessEvents( flags ); peek_message( &msg, &filter ); }
diff --git a/dlls/win32u/message.c b/dlls/win32u/message.c index 139a6d32fe9..b596b5a03df 100644 --- a/dlls/win32u/message.c +++ b/dlls/win32u/message.c @@ -3130,7 +3130,6 @@ static inline void check_for_driver_events(void) { if (get_user_thread_info()->last_driver_time != get_driver_check_time()) { - flush_window_surfaces( FALSE ); user_driver->pProcessEvents( QS_ALLINPUT ); get_user_thread_info()->last_driver_time = get_driver_check_time(); } @@ -3208,8 +3207,6 @@ static DWORD wait_objects( DWORD count, const HANDLE *handles, DWORD timeout, { assert( count ); /* we must have at least the server queue */
- flush_window_surfaces( TRUE ); - if (!check_queue_masks( wake_mask, changed_mask )) { SERVER_START_REQ( set_queue_mask ) @@ -3340,8 +3337,6 @@ BOOL WINAPI NtUserPeekMessage( MSG *msg_out, HWND hwnd, UINT first, UINT last, U void *ret_ptr; ULONG ret_len;
- flush_window_surfaces( TRUE ); - if (!KeUserDispatchCallback( ¶ms.dispatch, sizeof(params), &ret_ptr, &ret_len ) && ret_len == sizeof(params.locks)) { diff --git a/dlls/win32u/win32u_private.h b/dlls/win32u/win32u_private.h index 21e4b3e8f8a..29a3782ed76 100644 --- a/dlls/win32u/win32u_private.h +++ b/dlls/win32u/win32u_private.h @@ -48,7 +48,6 @@ extern void create_window_surface( HWND hwnd, BOOL create_layered, const RECT *s struct window_surface **window_surface ); extern struct window_surface *get_driver_window_surface( struct window_surface *surface, UINT monitor_dpi ); extern void erase_now( HWND hwnd, UINT rdw_flags ); -extern void flush_window_surfaces( BOOL idle ); extern void move_window_bits( HWND hwnd, const struct window_rects *rects, const RECT *valid_rects ); extern void move_window_bits_surface( HWND hwnd, const RECT *window_rect, struct window_surface *old_surface, const RECT *old_visible_rect, const RECT *valid_rects ); @@ -58,7 +57,6 @@ extern void register_window_surface( struct window_surface *old, extern void process_wine_present( HWND hwnd ); extern void window_surface_lock( struct window_surface *surface ); extern void window_surface_unlock( struct window_surface *surface ); -extern void window_surface_flush( struct window_surface *surface ); extern void window_surface_set_clip( struct window_surface *surface, HRGN clip_region ); extern void window_surface_set_layered( struct window_surface *surface, COLORREF color_key, UINT alpha_bits, UINT alpha_mask );
diff --git a/dlls/win32u/window.c b/dlls/win32u/window.c index 5825dd8b5a2..ccb561e9b77 100644 --- a/dlls/win32u/window.c +++ b/dlls/win32u/window.c @@ -2292,7 +2292,6 @@ static BOOL expose_window_surface( HWND hwnd, UINT flags, const RECT *rect, UINT add_bounds_rect( &surface->bounds, &exposed_rect ); } window_surface_unlock( surface ); - if (surface->alpha_mask) window_surface_flush( surface ); window_surface_release( surface ); return TRUE; }