Ken Thomases : winemac: Clip surface drawn region to new visible rect on window resize.

Alexandre Julliard julliard at winehq.org
Fri Apr 5 14:02:15 CDT 2013


Module: wine
Branch: master
Commit: c2bbdc4b868ad4f23e85871990f3edc6226d31ed
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=c2bbdc4b868ad4f23e85871990f3edc6226d31ed

Author: Ken Thomases <ken at codeweavers.com>
Date:   Thu Apr  4 14:26:13 2013 -0500

winemac: Clip surface drawn region to new visible rect on window resize.

This prevents stale drawing from being revealed if the window later grows.

---

 dlls/winemac.drv/macdrv.h  |    1 +
 dlls/winemac.drv/surface.c |   32 ++++++++++++++++++++++++++++++++
 dlls/winemac.drv/window.c  |    1 +
 3 files changed, 34 insertions(+), 0 deletions(-)

diff --git a/dlls/winemac.drv/macdrv.h b/dlls/winemac.drv/macdrv.h
index 881ce87..97ff08b 100644
--- a/dlls/winemac.drv/macdrv.h
+++ b/dlls/winemac.drv/macdrv.h
@@ -141,6 +141,7 @@ extern struct window_surface *create_surface(macdrv_window window, const RECT *r
                                              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 a27ff24..a79ec47 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 0ff54d4..987aa34 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;




More information about the wine-cvs mailing list