Canvas tweaks.
authornick_m <mainsbridge@gmail.com>
Wed, 18 Jun 2014 14:06:32 +0000 (00:06 +1000)
committernick_m <mainsbridge@gmail.com>
Wed, 18 Jun 2014 14:06:32 +0000 (00:06 +1000)
       * Only queue a draw for changed items that are set visible and in-window.

libs/canvas/canvas.cc
libs/canvas/item.cc

index 3d4f9e0c5df633d0eb71f609ef01fe336c17643c..c13386408bd3ce3ab336ba659af4762015c4ce8d 100644 (file)
@@ -170,7 +170,9 @@ Canvas::item_shown_or_hidden (Item* item)
 {
        boost::optional<Rect> bbox = item->bounding_box ();
        if (bbox) {
-               queue_draw_item_area (item, bbox.get ());
+               if (item->item_to_window (*bbox).intersection (visible_area ())) {
+                       queue_draw_item_area (item, bbox.get ());
+               }
        }
 }
 
@@ -183,7 +185,9 @@ Canvas::item_visual_property_changed (Item* item)
 {
        boost::optional<Rect> bbox = item->bounding_box ();
        if (bbox) {
-               queue_draw_item_area (item, bbox.get ());
+               if (item->item_to_window (*bbox).intersection (visible_area ())) {
+                       queue_draw_item_area (item, bbox.get ());
+               }
        }
 }
 
@@ -195,15 +199,24 @@ Canvas::item_visual_property_changed (Item* item)
 void
 Canvas::item_changed (Item* item, boost::optional<Rect> pre_change_bounding_box)
 {
+       
+       Rect window_bbox = visible_area ();
+
        if (pre_change_bounding_box) {
-               /* request a redraw of the item's old bounding box */
-               queue_draw_item_area (item, pre_change_bounding_box.get ());
+
+               if (item->item_to_window (*pre_change_bounding_box).intersection (window_bbox)) {
+                       /* request a redraw of the item's old bounding box */
+                       queue_draw_item_area (item, pre_change_bounding_box.get ());
+               }
        }
 
        boost::optional<Rect> post_change_bounding_box = item->bounding_box ();
        if (post_change_bounding_box) {
-               /* request a redraw of the item's new bounding box */
-               queue_draw_item_area (item, post_change_bounding_box.get ());
+               
+               if (item->item_to_window (*post_change_bounding_box).intersection (window_bbox)) {
+                       /* request a redraw of the item's new bounding box */
+                       queue_draw_item_area (item, post_change_bounding_box.get ());
+               }
        }
 }
 
index ce15782b9ee3732837946a3522774f9aff717d5f..90bf0972f0ed60677bd1144027fdcbd5fbe03762 100644 (file)
@@ -545,10 +545,12 @@ Item::begin_change ()
 void
 Item::end_change ()
 {
-       _canvas->item_changed (this, _pre_change_bounding_box);
+       if (_visible) {
+               _canvas->item_changed (this, _pre_change_bounding_box);
        
-       if (_parent) {
-               _parent->child_changed ();
+               if (_parent) {
+                       _parent->child_changed ();
+               }
        }
 }
 
@@ -560,7 +562,9 @@ Item::begin_visual_change ()
 void
 Item::end_visual_change ()
 {
-       _canvas->item_visual_property_changed (this);
+       if (_visible) {
+               _canvas->item_visual_property_changed (this);
+       }
 }
 
 void