[meld] Make fewer cairo calls during TextView drawing



commit 2fb10d1f31572f222ec2b6815040ed96f97eca6a
Author: Kai Willadsen <kai willadsen gmail com>
Date:   Sun Feb 28 07:42:03 2010 +1000

    Make fewer cairo calls during TextView drawing
    
    This commit simplifies our textview drawing by reusing a single rect for
    stroke and fill as appropriate. In actual use it produces a slight
    speed-up, trading off slightly decreased cairo time for an unnecessary
    _line_to_pixel call in the case of insert changes.

 meld/filediff.py |   16 ++++++----------
 1 files changed, 6 insertions(+), 10 deletions(-)
---
diff --git a/meld/filediff.py b/meld/filediff.py
index bcf6c7e..4e7fc4f 100644
--- a/meld/filediff.py
+++ b/meld/filediff.py
@@ -873,18 +873,14 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
 
         def draw_change(change): # draw background and thin lines
             ypos0 = self._line_to_pixel(pane, change[1]) - visible.y
+            ypos1 = self._line_to_pixel(pane, change[2]) - visible.y
+
+            context.rectangle(-0.5, ypos0 - 0.5, width + 1, ypos1 - ypos0)
+            if change[1] != change[2]:
+                context.set_source_rgb(*self.fill_colors[change[0]])
+                context.fill_preserve()
             context.set_source_rgb(*self.line_colors[change[0]])
-            context.move_to(-0.5, ypos0 - 0.5)
-            context.rel_line_to(width + 1, 0)
             context.stroke()
-            if change[2] != change[1]:
-                ypos1 = self._line_to_pixel(pane, change[2]) - visible.y
-                context.move_to(-0.5, ypos1 - 0.5)
-                context.rel_line_to(width + 1, 0)
-                context.stroke()
-                context.set_source_rgb(*self.fill_colors[change[0]])
-                context.rectangle(0, ypos0, width, ypos1 - ypos0 - 1)
-                context.fill()
 
         for change in self.linediffer.single_changes(pane):
             if change[2] < start_line: continue



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