From ce8846d13fb9b1da65a7d16f520d839a66dba8a3 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Thu, 9 Jul 2020 02:10:28 +0200 Subject: [PATCH] Fix polygon redrawing -- #8148 Polygons used PolyLine::render() to render the path. However since 7bb8ca1e76986, the PolyLine path is constrained (for automation lanes), and closed shaped polygons were not always completely redrawn. --- libs/canvas/polygon.cc | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/libs/canvas/polygon.cc b/libs/canvas/polygon.cc index 3c6d5d51a2..215d51ce6f 100644 --- a/libs/canvas/polygon.cc +++ b/libs/canvas/polygon.cc @@ -46,15 +46,23 @@ Polygon::~Polygon () void Polygon::render (Rect const & area, Cairo::RefPtr context) const { + Points::size_type npoints = _points.size(); + if (npoints < 2) { + return; + } + if (_outline || _fill) { - render_path (area, context); + const double pixel_adjust = (_outline_width == 1.0 ? 0.5 : 0.0); - if (!_points.empty ()) { - /* close path */ - Duple p = item_to_window (Duple (_points.front().x, _points.front().y)); - context->line_to (p.x, p.y); + for (Points::size_type i = 0; i < npoints; i++) { + Duple c = item_to_window (Duple (_points[i].x, _points[i].y)); + if (i == 0) { + context->move_to (c.x + pixel_adjust, c.y + pixel_adjust); + } else { + context->line_to (c.x + pixel_adjust, c.y + pixel_adjust); + } } - + context->close_path (); } if (_outline) {