emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] scratch/ns-drawing 3d56c32 2/4: Optimize drawRect


From: Alan Third
Subject: [Emacs-diffs] scratch/ns-drawing 3d56c32 2/4: Optimize drawRect
Date: Sat, 11 Aug 2018 09:59:34 -0400 (EDT)

branch: scratch/ns-drawing
commit 3d56c32690ca5618b51afb692d70ba7dd43138cc
Author: Alan Third <address@hidden>
Commit: Alan Third <address@hidden>

    Optimize drawRect
    
    * src/nsterm.m ([EmacsView drawRect:]): Only expose rectangles that
    have actually been marked dirty.
---
 src/nsterm.m | 27 +++++++++++++++++++++++----
 1 file changed, 23 insertions(+), 4 deletions(-)

diff --git a/src/nsterm.m b/src/nsterm.m
index 1002486..ec58ecc 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -8158,8 +8158,11 @@ not_in_argv (NSString *arg)
 
 - (void)drawRect: (NSRect)rect
 {
-  int x = NSMinX (rect), y = NSMinY (rect);
-  int width = NSWidth (rect), height = NSHeight (rect);
+  int x, y, width, height;
+  const NSRect *rects;
+  NSInteger numRects;
+  NSColor *bgCol = ns_lookup_indexed_color
+    (NS_FACE_BACKGROUND (FRAME_DEFAULT_FACE (emacsframe)), emacsframe);
 
   NSTRACE ("[EmacsView drawRect:" NSTRACE_FMT_RECT "]",
            NSTRACE_ARG_RECT(rect));
@@ -8167,9 +8170,25 @@ not_in_argv (NSString *arg)
   if (!emacsframe || !emacsframe->output_data.ns)
     return;
 
-  ns_clear_frame_area (emacsframe, x, y, width, height);
   block_input ();
-  expose_frame (emacsframe, x, y, width, height);
+
+  [self getRectsBeingDrawn:&rects count:&numRects];
+  //NSLog(@"numRects: %d", (int)numRects);
+  for (int i = 0 ; i < numRects ; i++)
+    {
+      //NSLog(@"rect: address@hidden", NSStringFromRect(rects[i]));
+      x = NSMinX (rects[i]);
+      y = NSMinY (rects[i]);
+      width = NSWidth (rects[i]);
+      height = NSHeight (rects[i]);
+
+      [bgCol set];
+      NSRectFill (rects[i]);
+
+      //ns_clear_frame_area (emacsframe, x, y, width, height);
+      expose_frame (emacsframe, x, y, width, height);
+    }
+
   unblock_input ();
 
   /*



reply via email to

[Prev in Thread] Current Thread [Next in Thread]