From cfa17c6df602c04a88e9cc489a508207f963a309 Mon Sep 17 00:00:00 2001 From: Hermet Park Date: Mon, 6 Jul 2020 19:26:50 +0900 Subject: [PATCH] svg_engine: fix infinit loop dead in stroke rendering. here logic was wrongly introducedd, we fix the condition check properly. Change-Id: I97f18f68290c61096f4e7fe54bd6f6fde51e175b --- src/lib/sw_engine/tvgSwMath.cpp | 2 +- src/lib/sw_engine/tvgSwShape.cpp | 1 - src/lib/sw_engine/tvgSwStroke.cpp | 10 ++++++---- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/lib/sw_engine/tvgSwMath.cpp b/src/lib/sw_engine/tvgSwMath.cpp index 53cc8ce..540ddcf 100644 --- a/src/lib/sw_engine/tvgSwMath.cpp +++ b/src/lib/sw_engine/tvgSwMath.cpp @@ -237,7 +237,7 @@ bool mathSmallCubic(SwPoint* base, SwFixed& angleIn, SwFixed& angleMid, SwFixed& auto theta2 = abs(mathDiff(angleMid, angleOut)); if ((theta1 < (SW_ANGLE_PI / 8)) && (theta2 < (SW_ANGLE_PI / 8))) return true; - else return false; + return false; } diff --git a/src/lib/sw_engine/tvgSwShape.cpp b/src/lib/sw_engine/tvgSwShape.cpp index a2ca5c6..66655b0 100644 --- a/src/lib/sw_engine/tvgSwShape.cpp +++ b/src/lib/sw_engine/tvgSwShape.cpp @@ -648,7 +648,6 @@ bool shapeGenStrokeRle(SwShape& shape, const Shape* sdata, const SwSize& clip) if (sdata->strokeDash(nullptr) > 0) { shapeOutline = _genDashOutline(sdata); if (!shapeOutline) return false; - //Normal Style stroke } else { if (!shape.outline) { diff --git a/src/lib/sw_engine/tvgSwStroke.cpp b/src/lib/sw_engine/tvgSwStroke.cpp index 6ccfb7d..d45ddd8 100644 --- a/src/lib/sw_engine/tvgSwStroke.cpp +++ b/src/lib/sw_engine/tvgSwStroke.cpp @@ -442,7 +442,7 @@ static void _cubicTo(SwStroke& stroke, const SwPoint& ctrl1, const SwPoint& ctrl //initialize with current direction angleIn = angleOut = angleMid = stroke.angleIn; - if (arc < limit && mathSmallCubic(arc, angleIn, angleMid, angleOut)) { + if (arc < limit && !mathSmallCubic(arc, angleIn, angleMid, angleOut)) { if (stroke.firstPt) stroke.angleIn = angleIn; mathSplitCubic(arc); arc += 3; @@ -458,7 +458,7 @@ static void _cubicTo(SwStroke& stroke, const SwPoint& ctrl1, const SwPoint& ctrl stroke.angleOut = angleIn; _processCorner(stroke, 0); } - } else if (abs(mathDiff(stroke.angleIn, angleIn)) > (SW_ANGLE_PI / 8)) { + } else if (abs(mathDiff(stroke.angleIn, angleIn)) > (SW_ANGLE_PI / 8) / 4) { //if the deviation from one arc to the next is too great add a round corner stroke.center = arc[3]; stroke.angleOut = angleIn; @@ -534,9 +534,11 @@ static void _cubicTo(SwStroke& stroke, const SwPoint& ctrl1, const SwPoint& ctrl _borderLineTo(border, _end, false); _borderCubicTo(border, _ctrl2, _ctrl1, _start); - //and thenmove to the endpoint + //and then move to the endpoint _borderLineTo(border, _end, false); + ++side; + ++border; continue; } @@ -651,7 +653,7 @@ static void _addReverseLeft(SwStroke& stroke, bool opened) static void _beginSubPath(SwStroke& stroke, SwPoint& to, bool opened) { - /* We cannot process the first point because there is not enought + /* We cannot process the first point because there is not enough information regarding its corner/cap. Later, it will be processed in the _endSubPath() */ -- 2.7.4