From 4e13c06f3bc043b454d931ba161b8bf0bfa400ff Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Thu, 13 Jul 2017 11:03:44 +0200 Subject: [PATCH] user32: Add a helper function for copying bits from a window surface. Signed-off-by: Alexandre Julliard --- dlls/user32/painting.c | 50 ++++++++++++++++++++++++++++------------------ dlls/user32/user_private.h | 2 +- dlls/user32/winpos.c | 2 +- 3 files changed, 33 insertions(+), 21 deletions(-) diff --git a/dlls/user32/painting.c b/dlls/user32/painting.c index 7a6b0dc9b55..1bfb86d6c1a 100644 --- a/dlls/user32/painting.c +++ b/dlls/user32/painting.c @@ -760,6 +760,32 @@ void erase_now( HWND hwnd, UINT rdw_flags ) /*********************************************************************** + * copy_bits_from_surface + * + * Copy bits from a window surface; helper for move_window_bits and move_window_bits_parent. + */ +static void copy_bits_from_surface( HWND hwnd, struct window_surface *surface, + const RECT *dst, const RECT *src ) +{ + char buffer[FIELD_OFFSET( BITMAPINFO, bmiColors[256] )]; + BITMAPINFO *info = (BITMAPINFO *)buffer; + void *bits; + UINT flags = UPDATE_NOCHILDREN; + HRGN rgn = get_update_region( hwnd, &flags, NULL ); + HDC hdc = GetDCEx( hwnd, rgn, DCX_CACHE | DCX_WINDOW | DCX_EXCLUDERGN ); + + bits = surface->funcs->get_info( surface, info ); + surface->funcs->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 ); + ReleaseDC( hwnd, hdc ); +} + + +/*********************************************************************** * move_window_bits * * Move the window bits when a window is resized or its surface recreated. @@ -767,7 +793,7 @@ void erase_now( HWND hwnd, UINT rdw_flags ) void move_window_bits( HWND hwnd, struct window_surface *old_surface, struct window_surface *new_surface, const RECT *visible_rect, const RECT *old_visible_rect, - const RECT *client_rect, const RECT *valid_rects ) + const RECT *window_rect, const RECT *valid_rects ) { RECT dst = valid_rects[0]; RECT src = valid_rects[1]; @@ -776,24 +802,10 @@ void move_window_bits( HWND hwnd, struct window_surface *old_surface, src.left - old_visible_rect->left != dst.left - visible_rect->left || src.top - old_visible_rect->top != dst.top - visible_rect->top) { - char buffer[FIELD_OFFSET( BITMAPINFO, bmiColors[256] )]; - BITMAPINFO *info = (BITMAPINFO *)buffer; - void *bits; - UINT flags = UPDATE_NOCHILDREN; - HRGN rgn = get_update_region( hwnd, &flags, NULL ); - HDC hdc = GetDCEx( hwnd, rgn, DCX_CACHE | DCX_EXCLUDERGN ); - - OffsetRect( &dst, -client_rect->left, -client_rect->top ); - TRACE( "copying %s -> %s\n", wine_dbgstr_rect(&src), wine_dbgstr_rect(&dst) ); - bits = old_surface->funcs->get_info( old_surface, info ); - old_surface->funcs->lock( old_surface ); - SetDIBitsToDevice( hdc, dst.left, dst.top, dst.right - dst.left, dst.bottom - dst.top, - src.left - old_visible_rect->left - old_surface->rect.left, - old_surface->rect.bottom - (src.bottom - old_visible_rect->top), - 0, old_surface->rect.bottom - old_surface->rect.top, - bits, info, DIB_RGB_COLORS ); - old_surface->funcs->unlock( old_surface ); - ReleaseDC( hwnd, hdc ); + TRACE( "copying %s -> %s\n", wine_dbgstr_rect( &src ), wine_dbgstr_rect( &dst )); + OffsetRect( &src, -old_visible_rect->left, -old_visible_rect->top ); + OffsetRect( &dst, -window_rect->left, -window_rect->top ); + copy_bits_from_surface( hwnd, old_surface, &dst, &src ); } } diff --git a/dlls/user32/user_private.h b/dlls/user32/user_private.h index b4a756cb1fd..a697fd922ef 100644 --- a/dlls/user32/user_private.h +++ b/dlls/user32/user_private.h @@ -231,7 +231,7 @@ extern void erase_now( HWND hwnd, UINT rdw_flags ) DECLSPEC_HIDDEN; extern void move_window_bits( HWND hwnd, struct window_surface *old_surface, struct window_surface *new_surface, const RECT *visible_rect, const RECT *old_visible_rect, - const RECT *client_rect, const RECT *valid_rects ) DECLSPEC_HIDDEN; + const RECT *window_rect, const RECT *valid_rects ) DECLSPEC_HIDDEN; extern void *get_hook_proc( void *proc, const WCHAR *module, HMODULE *free_module ) DECLSPEC_HIDDEN; extern RECT get_virtual_screen_rect(void) DECLSPEC_HIDDEN; extern LRESULT call_current_hook( HHOOK hhook, INT code, WPARAM wparam, LPARAM lparam ) DECLSPEC_HIDDEN; diff --git a/dlls/user32/winpos.c b/dlls/user32/winpos.c index 87f8deb4263..a37ab7c2eb2 100644 --- a/dlls/user32/winpos.c +++ b/dlls/user32/winpos.c @@ -2151,7 +2151,7 @@ BOOL set_window_pos( HWND hwnd, HWND insert_after, UINT swp_flags, if (!IsRectEmpty( valid_rects )) { move_window_bits( hwnd, old_surface, new_surface, &visible_rect, - &old_visible_rect, client_rect, valid_rects ); + &old_visible_rect, window_rect, valid_rects ); valid_rects = NULL; /* prevent the driver from trying to also move the bits */ } window_surface_release( old_surface ); -- 2.11.4.GIT