small optimization to curve rendering
This commit is contained in:
parent
4f465d37b3
commit
4b71d7fde5
@ -66,6 +66,10 @@ PolyItem::compute_bounding_box () const
|
|||||||
void
|
void
|
||||||
PolyItem::render_path (Rect const & /*area*/, Cairo::RefPtr<Cairo::Context> context) const
|
PolyItem::render_path (Rect const & /*area*/, Cairo::RefPtr<Cairo::Context> context) const
|
||||||
{
|
{
|
||||||
|
if (_points.size() < 2) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Points::const_iterator i = _points.begin();
|
Points::const_iterator i = _points.begin();
|
||||||
Duple c (item_to_window (Duple (i->x, i->y)));
|
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 cp1 = first_control_points.begin();
|
||||||
Points::const_iterator cp2 = second_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);
|
||||||
|
|
||||||
if (!done_first) {
|
while (p != _points.end()) {
|
||||||
|
|
||||||
Duple c = item_to_window (Duple (i->x, i->y));
|
Duple c1 = item_to_window (Duple (cp1->x, cp1->y));
|
||||||
context->move_to (c.x, c.y);
|
Duple c2 = item_to_window (Duple (cp2->x, cp2->y));
|
||||||
done_first = true;
|
|
||||||
|
|
||||||
} else {
|
c = item_to_window (Duple (p->x, p->y));
|
||||||
|
|
||||||
Duple c1 = item_to_window (Duple (cp1->x, cp1->y));
|
context->curve_to (c1.x, c1.y, c2.x, c2.y, c.x, c.y);
|
||||||
Duple c2 = item_to_window (Duple (cp2->x, cp2->y));
|
|
||||||
Duple c3 = item_to_window (Duple (i->x, i->y));
|
++cp1;
|
||||||
|
++cp2;
|
||||||
context->curve_to (c1.x, c1.y, c2.x, c2.y, c3.x, c3.y);
|
++p;
|
||||||
|
|
||||||
cp1++;
|
|
||||||
cp2++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user