summaryrefslogtreecommitdiff
path: root/libs/canvas/poly_item.cc
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2014-01-03 14:05:05 -0500
committerPaul Davis <paul@linuxaudiosystems.com>2014-01-06 20:45:40 -0500
commit4b71d7fde5dd7982d5393bfacd03dd99cb0c642f (patch)
treea61d77561dffbbb43081c07e0702abc288b5fe23 /libs/canvas/poly_item.cc
parent4f465d37b3c2506f00a3dbc7d2191a887ea91a2d (diff)
small optimization to curve rendering
Diffstat (limited to 'libs/canvas/poly_item.cc')
-rw-r--r--libs/canvas/poly_item.cc33
1 files changed, 17 insertions, 16 deletions
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<Cairo::Context> 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<Cairo::Context> 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;
}
}