X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fcanvas%2Fpoly_item.cc;h=69afb5ac24b93df1efdd9703080e79cc079ec7fa;hb=98dec658ee4067bdb22262640a821334ddc2ed83;hp=6c9f0c98ab7ca1e2bb871be734109697de711b57;hpb=37dd7e952bd084cd35a4c4f67949890ee3e7c152;p=ardour.git diff --git a/libs/canvas/poly_item.cc b/libs/canvas/poly_item.cc index 6c9f0c98ab..69afb5ac24 100644 --- a/libs/canvas/poly_item.cc +++ b/libs/canvas/poly_item.cc @@ -38,7 +38,6 @@ void PolyItem::compute_bounding_box () const { bool have_one = false; - Rect bbox; for (Points::const_iterator i = _points.begin(); i != _points.end(); ++i) { @@ -65,24 +64,28 @@ PolyItem::compute_bounding_box () const } void -PolyItem::render_path (Rect const & /*area*/, Cairo::RefPtr context) const +PolyItem::render_path (Rect const & /* area */, Cairo::RefPtr context) const { - bool done_first = false; - for (Points::const_iterator i = _points.begin(); i != _points.end(); ++i) { - if (done_first) { - context->line_to (i->x, i->y); - } else { - context->move_to (i->x, i->y); - done_first = true; - } + if (_points.size() < 2) { + return; + } + + Points::const_iterator i = _points.begin(); + Duple c (item_to_window (Duple (i->x, i->y))); + + context->move_to (c.x, c.y); + ++i; + + while (i != _points.end()) { + c = item_to_window (Duple (i->x, i->y)); + context->line_to (c.x, c.y); + ++i; } } void PolyItem::render_curve (Rect const & area, Cairo::RefPtr context, Points const & first_control_points, Points const & second_control_points) const { - bool done_first = false; - if (_points.size() <= 2) { render_path (area, context); return; @@ -90,23 +93,24 @@ 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) { + Duple c = item_to_window (Duple (p->x, p->y)); + context->move_to (c.x, c.y); + ++p; - if (done_first) { + while (p != _points.end()) { - context->curve_to (cp1->x, cp1->y, - cp2->x, cp2->y, - i->x, i->y); + Duple c1 = item_to_window (Duple (cp1->x, cp1->y)); + Duple c2 = item_to_window (Duple (cp2->x, cp2->y)); - cp1++; - cp2++; - - } else { - - context->move_to (i->x, i->y); - done_first = true; - } + 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; } }