From 4b71d7fde5dd7982d5393bfacd03dd99cb0c642f Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Fri, 3 Jan 2014 14:05:05 -0500 Subject: small optimization to curve rendering --- libs/canvas/poly_item.cc | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) (limited to 'libs/canvas/poly_item.cc') diff --git a/libs/canvas/poly_item.cc b/libs/canvas/poly_item.cc index ebf744a0b2..dfd58bcdb0 100644 --- a/libs/canvas/poly_item.cc +++ b/libs/canvas/poly_item.cc @@ -66,6 +66,10 @@ PolyItem::compute_bounding_box () const void PolyItem::render_path (Rect const & /*area*/, Cairo::RefPtr context) const { + if (_points.size() < 2) { + return; + } + Points::const_iterator i = _points.begin(); Duple c (item_to_window (Duple (i->x, i->y))); @@ -90,26 +94,23 @@ PolyItem::render_curve (Rect const & area, Cairo::RefPtr context Points::const_iterator cp1 = first_control_points.begin(); Points::const_iterator cp2 = second_control_points.begin(); + Points::const_iterator p = _points.begin(); - for (Points::const_iterator i = _points.begin(); i != _points.end(); ++i) { - - if (!done_first) { - - Duple c = item_to_window (Duple (i->x, i->y)); - context->move_to (c.x, c.y); - done_first = true; - - } else { + Duple c = item_to_window (Duple (p->x, p->y)); + context->move_to (c.x, c.y); - Duple c1 = item_to_window (Duple (cp1->x, cp1->y)); - Duple c2 = item_to_window (Duple (cp2->x, cp2->y)); - Duple c3 = item_to_window (Duple (i->x, i->y)); + while (p != _points.end()) { - context->curve_to (c1.x, c1.y, c2.x, c2.y, c3.x, c3.y); + Duple c1 = item_to_window (Duple (cp1->x, cp1->y)); + Duple c2 = item_to_window (Duple (cp2->x, cp2->y)); - cp1++; - cp2++; - } + c = item_to_window (Duple (p->x, p->y)); + + context->curve_to (c1.x, c1.y, c2.x, c2.y, c.x, c.y); + + ++cp1; + ++cp2; + ++p; } } -- cgit v1.2.3