mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-08 05:33:36 +00:00
svg_engine: fix infinit loop dead in stroke rendering.
here logic was wrongly introducedd, we fix the condition check properly. Change-Id: I97f18f68290c61096f4e7fe54bd6f6fde51e175b
This commit is contained in:
parent
2929fa5c57
commit
cfa17c6df6
3 changed files with 7 additions and 6 deletions
|
@ -237,7 +237,7 @@ bool mathSmallCubic(SwPoint* base, SwFixed& angleIn, SwFixed& angleMid, SwFixed&
|
||||||
auto theta2 = abs(mathDiff(angleMid, angleOut));
|
auto theta2 = abs(mathDiff(angleMid, angleOut));
|
||||||
|
|
||||||
if ((theta1 < (SW_ANGLE_PI / 8)) && (theta2 < (SW_ANGLE_PI / 8))) return true;
|
if ((theta1 < (SW_ANGLE_PI / 8)) && (theta2 < (SW_ANGLE_PI / 8))) return true;
|
||||||
else return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -648,7 +648,6 @@ bool shapeGenStrokeRle(SwShape& shape, const Shape* sdata, const SwSize& clip)
|
||||||
if (sdata->strokeDash(nullptr) > 0) {
|
if (sdata->strokeDash(nullptr) > 0) {
|
||||||
shapeOutline = _genDashOutline(sdata);
|
shapeOutline = _genDashOutline(sdata);
|
||||||
if (!shapeOutline) return false;
|
if (!shapeOutline) return false;
|
||||||
|
|
||||||
//Normal Style stroke
|
//Normal Style stroke
|
||||||
} else {
|
} else {
|
||||||
if (!shape.outline) {
|
if (!shape.outline) {
|
||||||
|
|
|
@ -442,7 +442,7 @@ static void _cubicTo(SwStroke& stroke, const SwPoint& ctrl1, const SwPoint& ctrl
|
||||||
//initialize with current direction
|
//initialize with current direction
|
||||||
angleIn = angleOut = angleMid = stroke.angleIn;
|
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;
|
if (stroke.firstPt) stroke.angleIn = angleIn;
|
||||||
mathSplitCubic(arc);
|
mathSplitCubic(arc);
|
||||||
arc += 3;
|
arc += 3;
|
||||||
|
@ -458,7 +458,7 @@ static void _cubicTo(SwStroke& stroke, const SwPoint& ctrl1, const SwPoint& ctrl
|
||||||
stroke.angleOut = angleIn;
|
stroke.angleOut = angleIn;
|
||||||
_processCorner(stroke, 0);
|
_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
|
//if the deviation from one arc to the next is too great add a round corner
|
||||||
stroke.center = arc[3];
|
stroke.center = arc[3];
|
||||||
stroke.angleOut = angleIn;
|
stroke.angleOut = angleIn;
|
||||||
|
@ -534,9 +534,11 @@ static void _cubicTo(SwStroke& stroke, const SwPoint& ctrl1, const SwPoint& ctrl
|
||||||
_borderLineTo(border, _end, false);
|
_borderLineTo(border, _end, false);
|
||||||
_borderCubicTo(border, _ctrl2, _ctrl1, _start);
|
_borderCubicTo(border, _ctrl2, _ctrl1, _start);
|
||||||
|
|
||||||
//and thenmove to the endpoint
|
//and then move to the endpoint
|
||||||
_borderLineTo(border, _end, false);
|
_borderLineTo(border, _end, false);
|
||||||
|
|
||||||
|
++side;
|
||||||
|
++border;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -651,7 +653,7 @@ static void _addReverseLeft(SwStroke& stroke, bool opened)
|
||||||
|
|
||||||
static void _beginSubPath(SwStroke& stroke, SwPoint& to, 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
|
information regarding its corner/cap. Later, it will be processed
|
||||||
in the _endSubPath() */
|
in the _endSubPath() */
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue