[gimp-macos-build/wip/Jehan/GDK-expose-too-much] modulesets, patches: intersect to-draw regions with dirtyRect.



commit 70fff569f80629b646c9b50a0f8e2c5d632bb722
Author: Jehan <jehan girinstud io>
Date:   Mon Feb 14 14:17:25 2022 +0100

    modulesets, patches: intersect to-draw regions with dirtyRect.
    
    Apple docs says that we should limit drawing to the dirtyRect so let's
    make an intersection. I have no idea if it would help at all, as maybe
    the passed dirtyRect is overly big as well, anyway. I have no way to
    test myself.
    
    See: https://developer.apple.com/documentation/appkit/nsview/1483686-drawrect

 modulesets/gtk-osx.modules                         |  1 +
 ...draw-contents-outside-the-rect-passed-by-.patch | 59 ++++++++++++++++++++++
 2 files changed, 60 insertions(+)
---
diff --git a/modulesets/gtk-osx.modules b/modulesets/gtk-osx.modules
index 110bbd8..fc232d1 100644
--- a/modulesets/gtk-osx.modules
+++ b/modulesets/gtk-osx.modules
@@ -291,6 +291,7 @@
       <patch file="gtk-3.24.31-use-cairo-surface-for-drawing.patch" strip="1"/>
       <patch file="gtk3-gdk-in-Quartz-send-expose-events-for-individual-dama.patch" strip="1"/>
       <patch file="gtk3-For-testing-and-making-sure-this-code-runs.patch" strip="1"/>
+      <patch file="gtk3-gdk-do-not-draw-contents-outside-the-rect-passed-by-.patch" strip="1"/>
     </branch>
     <dependencies>
       <dep package="glib"/>
diff --git a/patches/gtk3-gdk-do-not-draw-contents-outside-the-rect-passed-by-.patch 
b/patches/gtk3-gdk-do-not-draw-contents-outside-the-rect-passed-by-.patch
new file mode 100644
index 0000000..f76e68c
--- /dev/null
+++ b/patches/gtk3-gdk-do-not-draw-contents-outside-the-rect-passed-by-.patch
@@ -0,0 +1,59 @@
+From d871eb23d46c08fbf4c2780fa3ebd1c0ef872cd7 Mon Sep 17 00:00:00 2001
+From: Jehan <jehan girinstud io>
+Date: Mon, 14 Feb 2022 14:13:57 +0100
+Subject: [PATCH] gdk: do not draw contents outside the rect passed by
+ drawRect().
+
+Apple docs says:
+
+> The dirtyRect parameter helps you achieve better performance by
+> specifying the portion of the view that needs to be drawn. You should
+> always limit drawing to the content inside this rectangle.
+
+We were not doing this, basically limiting our testing with rect to
+whether it is empty. We should actually combine it with values returned
+by getRectsBeingDrawn, and only draw intersections.
+---
+ gdk/quartz/GdkQuartzView.c | 18 +++++++++++++-----
+ 1 file changed, 13 insertions(+), 5 deletions(-)
+
+diff --git a/gdk/quartz/GdkQuartzView.c b/gdk/quartz/GdkQuartzView.c
+index ca68e031ac..dc15aaf286 100644
+--- a/gdk/quartz/GdkQuartzView.c
++++ b/gdk/quartz/GdkQuartzView.c
+@@ -318,7 +318,7 @@
+   if (! (gdk_window->event_mask & GDK_EXPOSURE_MASK))
+     return;
+ 
+-  if (NSEqualRects (rect, NSZeroRect))
++  if (NSIsEmptyRect (rect))
+     return;
+ 
+   if (!GDK_WINDOW_IS_MAPPED (gdk_window))
+@@ -353,11 +353,19 @@
+     {
+       cairo_region_t        *region;
+       cairo_rectangle_int_t  cairo_rect;
++      NSRect                 intersect_rect;
+ 
+-      cairo_rect.x = drawn_rects[i].origin.x;
+-      cairo_rect.y = drawn_rects[i].origin.y;
+-      cairo_rect.width = drawn_rects[i].size.width;
+-      cairo_rect.height = drawn_rects[i].size.height;
++      /* Apple docs of drawRect() clearly says we should always limit drawing
++       * to contents inside the rectangle passed as parameter.
++       */
++      intersect_rect = NSIntersectionRect (rect, drawn_rects[i]);
++      if (NSIsEmptyRect (intersect_rect))
++        continue;
++
++      cairo_rect.x = intersect_rect.origin.x;
++      cairo_rect.y = intersect_rect.origin.y;
++      cairo_rect.width = intersect_rect.size.width;
++      cairo_rect.height = intersect_rect.size.height;
+ 
+       region = cairo_region_create_rectangles (&cairo_rect, 1);
+ 
+-- 
+2.30.2
+


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]