diff --git a/dlls/winemac.drv/macdrv.h b/dlls/winemac.drv/macdrv.h index 881ce879eda..97ff08b7772 100644 --- a/dlls/winemac.drv/macdrv.h +++ b/dlls/winemac.drv/macdrv.h @@ -141,6 +141,7 @@ static inline RECT rect_from_cgrect(CGRect cgrect) struct window_surface *old_surface, BOOL use_alpha) DECLSPEC_HIDDEN; extern void set_window_surface(macdrv_window window, struct window_surface *window_surface) DECLSPEC_HIDDEN; extern void set_surface_use_alpha(struct window_surface *window_surface, BOOL use_alpha) DECLSPEC_HIDDEN; +extern void surface_clip_to_visible_rect(struct window_surface *window_surface, const RECT *visible_rect) DECLSPEC_HIDDEN; extern void macdrv_handle_event(const macdrv_event *event) DECLSPEC_HIDDEN; diff --git a/dlls/winemac.drv/surface.c b/dlls/winemac.drv/surface.c index a27ff246a9a..a79ec474563 100644 --- a/dlls/winemac.drv/surface.c +++ b/dlls/winemac.drv/surface.c @@ -410,3 +410,35 @@ CGImageRef create_surface_image(void *window_surface, CGRect *rect, int copy_dat return cgimage; } + +/*********************************************************************** + * surface_clip_to_visible_rect + * + * Intersect the accumulated drawn region with a new visible rect, + * effectively discarding stale drawing in the surface slack area. + */ +void surface_clip_to_visible_rect(struct window_surface *window_surface, const RECT *visible_rect) +{ + struct macdrv_window_surface *surface = get_mac_surface(window_surface); + + window_surface->funcs->lock(window_surface); + + if (surface->drawn) + { + RECT rect; + HRGN region; + + rect = *visible_rect; + OffsetRect(&rect, -rect.left, -rect.top); + + if ((region = CreateRectRgnIndirect(&rect))) + { + CombineRgn(surface->drawn, surface->drawn, region, RGN_AND); + DeleteObject(region); + + update_blit_data(surface); + } + } + + window_surface->funcs->unlock(window_surface); +} diff --git a/dlls/winemac.drv/window.c b/dlls/winemac.drv/window.c index 0ff54d41978..987aa348d8c 100644 --- a/dlls/winemac.drv/window.c +++ b/dlls/winemac.drv/window.c @@ -1284,6 +1284,7 @@ void CDECL macdrv_WindowPosChanging(HWND hwnd, HWND insert_after, UINT swp_flags if (!memcmp(&data->surface->rect, &surface_rect, sizeof(surface_rect))) { /* existing surface is good enough */ + surface_clip_to_visible_rect(data->surface, visible_rect); window_surface_add_ref(data->surface); *surface = data->surface; goto done;