don't queue redraws when various canvas item properties are "reset" to the same value...
authorPaul Davis <paul@linuxaudiosystems.com>
Tue, 11 Mar 2014 11:36:09 +0000 (07:36 -0400)
committerPaul Davis <paul@linuxaudiosystems.com>
Tue, 11 Mar 2014 11:36:09 +0000 (07:36 -0400)
libs/canvas/canvas.cc
libs/canvas/canvas/rectangle.h
libs/canvas/canvas/types.h
libs/canvas/line.cc
libs/canvas/poly_item.cc
libs/canvas/rectangle.cc
libs/canvas/types.cc

index 8ad608ea5e1d5a1037b22f1e41098b3f059bf397..d5d85623612c33f8bbe1a54ca28fada03a5c49b2 100644 (file)
@@ -262,7 +262,7 @@ void
 Canvas::queue_draw_item_area (Item* item, Rect area)
 {
        ArdourCanvas::Rect canvas_area = item->item_to_canvas (area);
-       // cerr << "CANVAS " << this << " for " << item->whatami() << ' ' << item->name << " invalidate " << area << " TRANSLATE AS " << canvas_area << " window = " << canvas_to_window (canvas_area) << std::endl;
+       // cerr << "CANVAS " << this << " for " << item << ' ' << item->whatami() << ' ' << item->name << " invalidate " << area << " TRANSLATE AS " << canvas_area << " window = " << canvas_to_window (canvas_area) << std::endl;
        request_redraw (canvas_area);
 }
 
index ff2ff994b7917bc943b96cad73578c192de18446..91f23f9336178539efbf851967f773e5a60220c2 100644 (file)
@@ -72,7 +72,12 @@ public:
        };
 
        void set_outline_what (What);
-       void set_outline_what (int);
+       void set_outline_all () {
+               set_outline_what (ArdourCanvas::Rectangle::What (ArdourCanvas::Rectangle::TOP|
+                                                                ArdourCanvas::Rectangle::LEFT|
+                                                                ArdourCanvas::Rectangle::RIGHT|
+                                                                ArdourCanvas::Rectangle::BOTTOM));
+       }
 
 private:
        /** Our rectangle; note that x0 may not always be less than x1
index 1e8b7b145f9e203010d99b48e39b315f638b9e2f..2800ccc91be392d34be1b912864c786fa2df8204 100644 (file)
@@ -64,6 +64,7 @@ struct LIBCANVAS_API Duple
 extern LIBCANVAS_API Duple operator- (Duple const &);
 extern LIBCANVAS_API Duple operator+ (Duple const &, Duple const &);
 extern LIBCANVAS_API bool operator== (Duple const &, Duple const &);
+extern LIBCANVAS_API bool operator!= (Duple const &, Duple const &);
 extern LIBCANVAS_API Duple operator- (Duple const &, Duple const &);
 extern LIBCANVAS_API Duple operator/ (Duple const &, double);
 extern LIBCANVAS_API std::ostream & operator<< (std::ostream &, Duple const &);
@@ -106,6 +107,8 @@ struct LIBCANVAS_API Rect
        }
 };
 
+extern LIBCANVAS_API bool operator!= (Rect const &, Rect const &);
+
 extern LIBCANVAS_API std::ostream & operator<< (std::ostream &, Rect const &);
 
 typedef std::vector<Duple> Points;
index 09f9061c8593653b601c3d6791c7c42918f06982..8f04e2b27878699345feb26f2896e27095fe0aa4 100644 (file)
@@ -77,53 +77,55 @@ Line::render (Rect const & /*area*/, Cairo::RefPtr<Cairo::Context> context) cons
 void
 Line::set (Duple a, Duple b)
 {
-       begin_change ();
-
-       _points[0] = a;
-       _points[1] = b;
-
-       _bounding_box_dirty = true;
-       end_change ();
-
-       DEBUG_TRACE (PBD::DEBUG::CanvasItemsDirtied, "canvas item dirty: line change\n");
+       if (a != _points[0] || b != _points[1]) {
+               begin_change ();
+               
+               _points[0] = a;
+               _points[1] = b;
+               
+               _bounding_box_dirty = true;
+               end_change ();
+       }
 }
 
 void
 Line::set_x (Coord x0, Coord x1)
 {
-       begin_change ();
-       
-       _points[0].x = x0;
-       _points[1].x = x1;
-
-       _bounding_box_dirty = true;
-       end_change ();
-
-       DEBUG_TRACE (PBD::DEBUG::CanvasItemsDirtied, "canvas item dirty: line change\n");
+       if (x0 != _points[0].x || x1 != _points[1].x) {
+               begin_change ();
+               
+               _points[0].x = x0;
+               _points[1].x = x1;
+               
+               _bounding_box_dirty = true;
+               end_change ();
+       }
 }      
 
 void
 Line::set_x0 (Coord x0)
 {
-       begin_change ();
-       
-       _points[0].x = x0;
-
-       _bounding_box_dirty = true;
-       end_change ();
-
-       DEBUG_TRACE (PBD::DEBUG::CanvasItemsDirtied, "canvas item dirty: line change\n");
+       if (x0 != _points[0].x) {
+               begin_change ();
+               
+               _points[0].x = x0;
+               
+               _bounding_box_dirty = true;
+               end_change ();
+       }
 }
 
 void
 Line::set_y0 (Coord y0)
 {
-       begin_change ();
-
-       _points[0].y = y0;
-
-       _bounding_box_dirty = true;
-       end_change ();
+       if (y0 != _points[0].y) {
+               begin_change ();
+               
+               _points[0].y = y0;
+               
+               _bounding_box_dirty = true;
+               end_change ();
+       }
 
        DEBUG_TRACE (PBD::DEBUG::CanvasItemsDirtied, "canvas item dirty: line change\n");
 }
@@ -131,27 +133,27 @@ Line::set_y0 (Coord y0)
 void
 Line::set_x1 (Coord x1)
 {
-       begin_change ();
-
-       _points[1].x = x1;
-
-       _bounding_box_dirty = true;
-       end_change ();
-
-       DEBUG_TRACE (PBD::DEBUG::CanvasItemsDirtied, "canvas item dirty: line change\n");
+       if (x1 != _points[1].x) {
+               begin_change ();
+               
+               _points[1].x = x1;
+               
+               _bounding_box_dirty = true;
+               end_change ();
+       }
 }
 
 void
 Line::set_y1 (Coord y1)
 {
-       begin_change ();
-
-       _points[1].y = y1;
-
-       _bounding_box_dirty = true;
-       end_change ();
-
-       DEBUG_TRACE (PBD::DEBUG::CanvasItemsDirtied, "canvas item dirty: line change\n");
+       if (y1 != _points[1].y) {
+               begin_change ();
+               
+               _points[1].y = y1;
+               
+               _bounding_box_dirty = true;
+               end_change ();
+       }
 }
 
 bool
index 88b9af78781cbc28a4242287daac5a9ab2e240e0..0d3369f70b0a822ba94eaa359027aa75b6c7dd65 100644 (file)
@@ -127,12 +127,15 @@ PolyItem::render_curve (Rect const & area, Cairo::RefPtr<Cairo::Context> context
 void
 PolyItem::set (Points const & points)
 {
-       begin_change ();
-       
-       _points = points;
-       
-       _bounding_box_dirty = true;
-       end_change ();
+       if (_points != points) {
+
+               begin_change ();
+               
+               _points = points;
+               
+               _bounding_box_dirty = true;
+               end_change ();
+       }
 }
 
 Points const &
index 7fd61e6cc45824b9222d26d8b12326b4f7f30261..57c26874c454de36fb256c46f3b3f75cd7bc751b 100644 (file)
@@ -139,82 +139,77 @@ Rectangle::set (Rect const & r)
        /* We don't update the bounding box here; it's just
           as cheap to do it when asked.
        */
-       
-       begin_change ();
-       
-       _rect = r;
-       
-       _bounding_box_dirty = true;
-       end_change ();
 
-       DEBUG_TRACE (PBD::DEBUG::CanvasItemsDirtied, "canvas item dirty: rectangle change (set)\n");
+       if (r != _rect) {
+               
+               begin_change ();
+               
+               _rect = r;
+               
+               _bounding_box_dirty = true;
+               end_change ();
+       }
 }
 
 void
 Rectangle::set_x0 (Coord x0)
 {
-       begin_change ();
-
-       _rect.x0 = x0;
-
-       _bounding_box_dirty = true;
-       end_change ();
-
-       DEBUG_TRACE (PBD::DEBUG::CanvasItemsDirtied, "canvas item dirty: rectangle change (x0)\n");
+       if (x0 != _rect.x0) {
+               begin_change ();
+               
+               _rect.x0 = x0;
+               
+               _bounding_box_dirty = true;
+               end_change ();
+       }
 }
 
 void
 Rectangle::set_y0 (Coord y0)
 {
-       begin_change ();
-       
-       _rect.y0 = y0;
-
-       _bounding_box_dirty = true;
-       end_change();
-
-       DEBUG_TRACE (PBD::DEBUG::CanvasItemsDirtied, "canvas item dirty: rectangle change (y0)\n");
+       if (y0 != _rect.y0) {
+               begin_change ();
+               
+               _rect.y0 = y0;
+               
+               _bounding_box_dirty = true;
+               end_change();
+       }
 }
 
 void
 Rectangle::set_x1 (Coord x1)
 {
-       begin_change ();
-       
-       _rect.x1 = x1;
-
-       _bounding_box_dirty = true;
-       end_change ();
-
-       DEBUG_TRACE (PBD::DEBUG::CanvasItemsDirtied, "canvas item dirty: rectangle change (x1)\n");
+       if (x1 != _rect.x1) {
+               begin_change ();
+               
+               _rect.x1 = x1;
+               
+               _bounding_box_dirty = true;
+               end_change ();
+       }
 }
 
 void
 Rectangle::set_y1 (Coord y1)
 {
-       begin_change ();
-
-       _rect.y1 = y1;
-
-       _bounding_box_dirty = true;
-       end_change ();
-
-       DEBUG_TRACE (PBD::DEBUG::CanvasItemsDirtied, "canvas item dirty: rectangle change (y1)\n");
+       if (y1 != _rect.y1) {
+               begin_change ();
+               
+               _rect.y1 = y1;
+               
+               _bounding_box_dirty = true;
+               end_change ();
+       }
 }
 
 void
 Rectangle::set_outline_what (What what)
 {
-       begin_change ();
-       
-       _outline_what = what;
-
-       end_change ();
-}
-
-void
-Rectangle::set_outline_what (int what)
-{
-       set_outline_what ((What) what);
+       if (what != _outline_what) {
+               begin_visual_change ();
+               _outline_what = what;
+               end_visual_change ();
+       }
 }
 
index 7d7a495df56666f4586a5d006b91702ec29fe530..4fd064d7467b1f844847207b6006e85da02ad0cd 100644 (file)
@@ -121,6 +121,16 @@ Rect::fix () const
        return r;
 }
 
+bool
+ArdourCanvas::operator!= (Rect const& a, Rect const& b)
+{
+       return a.x0 != b.x0 ||
+               a.x1 != b.x1 ||
+               a.y0 != b.y0 ||
+               a.y1 != b.y1;
+}
+
+
 Duple
 ArdourCanvas::operator- (Duple const & o)
 {
@@ -139,6 +149,12 @@ ArdourCanvas::operator== (Duple const & a, Duple const & b)
        return a.x == b.x && a.y == b.y;
 }
 
+bool
+ArdourCanvas::operator!= (Duple const & a, Duple const & b)
+{
+       return a.x != b.x || a.y != b.y;
+}
+
 Duple
 ArdourCanvas::operator- (Duple const & a, Duple const & b)
 {