From 1640973a826eccbefb8743bba6c5662a7b4e9fe9 Mon Sep 17 00:00:00 2001 From: Eirik Aavitsland Date: Fri, 14 Jun 2019 10:34:15 +0200 Subject: [PATCH] Fix raster paint error in path joins of tightly bending bezier curves The code for generating round line joins is optimized with a shortcut for the inner, normally invisible joins. For certain joins of a tightly turning bezier, this optimization would lead to visible painting error. Fix by avoiding the optimization if the next control point is so close as to allow such tight turns. As a driveby, make the angle > 90 test cheaper, since absolute precision is not required in the optimization choice. Fixes: QTBUG-75008 Change-Id: I293e0776003310dc36fa7f43fbcd9c25f1f8fa5d Reviewed-by: Lars Knoll Reviewed-by: Allan Sandfeld Jensen --- src/gui/painting/qstroker.cpp | 2 +- .../auto/other/lancelot/scripts/degeneratebeziers.qps | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/gui/painting/qstroker.cpp b/src/gui/painting/qstroker.cpp index 56d0917c6c..43dd191be8 100644 --- a/src/gui/painting/qstroker.cpp +++ b/src/gui/painting/qstroker.cpp @@ -524,7 +524,7 @@ void QStroker::joinPoints(qfixed focal_x, qfixed focal_y, const QLineF &nextLine QLineF shortCut(prevLine.p2(), nextLine.p1()); qreal angle = shortCut.angleTo(prevLine); - if (type == QLineF::BoundedIntersection || (angle > 90 && !qFuzzyCompare(angle, (qreal)90))) { + if ((type == QLineF::BoundedIntersection || (angle > qreal(90.01))) && nextLine.length() > offset) { emitLineTo(focal_x, focal_y); emitLineTo(qt_real_to_fixed(nextLine.x1()), qt_real_to_fixed(nextLine.y1())); return; diff --git a/tests/auto/other/lancelot/scripts/degeneratebeziers.qps b/tests/auto/other/lancelot/scripts/degeneratebeziers.qps index 6c069fd82f..948968b0cd 100644 --- a/tests/auto/other/lancelot/scripts/degeneratebeziers.qps +++ b/tests/auto/other/lancelot/scripts/degeneratebeziers.qps @@ -34,3 +34,14 @@ setPen blue 40 solidline roundcap drawPath revbez setPen red 0 drawPath revbez + +resetMatrix +path_lineTo tightJoin 60 10 +path_cubicTo tightJoin 50 0 100 0 100 50 + +translate 50 500 + +setPen green 40 solidline roundcap roundjoin +drawPath tightJoin +setPen red 0 +drawPath tightJoin