svg_engine: fix infinit loop dead in stroke rendering. 08/237908/3
authorHermet Park <chuneon.park@samsung.com>
Mon, 6 Jul 2020 10:26:50 +0000 (19:26 +0900)
committerHermet Park <chuneon.park@samsung.com>
Tue, 7 Jul 2020 02:26:28 +0000 (11:26 +0900)
here logic was wrongly introducedd, we fix the condition check properly.

Change-Id: I97f18f68290c61096f4e7fe54bd6f6fde51e175b

src/lib/sw_engine/tvgSwMath.cpp
src/lib/sw_engine/tvgSwShape.cpp
src/lib/sw_engine/tvgSwStroke.cpp

index 53cc8ce..540ddcf 100644 (file)
@@ -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;
 }
 
 
index a2ca5c6..66655b0 100644 (file)
@@ -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) {
index 6ccfb7d..d45ddd8 100644 (file)
@@ -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() */