sw_engine: revise stroke scaling logic. 20/239320/1
authorHermet Park <chuneon.park@samsung.com>
Fri, 24 Jul 2020 02:03:20 +0000 (11:03 +0900)
committerHermet Park <chuneon.park@samsung.com>
Fri, 24 Jul 2020 02:03:20 +0000 (11:03 +0900)
previous fast track logic is useless,
it actually doesn't helpful for performance, just increase the code complexity.

Change-Id: Ib6ad204edfb241d74c41413dfec7ab42fb02af81

src/lib/sw_engine/tvgSwCommon.h
src/lib/sw_engine/tvgSwStroke.cpp

index bad159b..5f7ec46 100644 (file)
@@ -153,13 +153,11 @@ struct SwStroke
 
     SwStrokeBorder borders[2];
 
-    float sx;
-    float sy;
+    float sx, sy;
 
     bool firstPt;
     bool openSubPath;
     bool handleWideStrokes;
-    bool postScale;
 };
 
 struct SwDashStroke
index 53fae90..15cbf02 100644 (file)
@@ -36,10 +36,8 @@ static inline SwFixed SIDE_TO_ROTATE(const int32_t s)
 
 static inline void SCALE(SwStroke& stroke, SwPoint& pt)
 {
-    if (stroke.postScale) {
-        pt.x = pt.x * stroke.sx;
-        pt.y = pt.y * stroke.sy;
-    }
+    pt.x *= stroke.sx;
+    pt.y *= stroke.sy;
 }
 
 
@@ -548,7 +546,6 @@ static void _cubicTo(SwStroke& stroke, const SwPoint& ctrl1, const SwPoint& ctrl
 
                     SwPoint delta = {alen, 0};
                     mathRotate(delta, beta);
-                    SCALE(stroke, delta);
                     delta += _start;
 
                     //circumnavigate the negative sector backwards
@@ -848,26 +845,14 @@ void strokeReset(SwStroke& stroke, const Shape* sdata, const Matrix* transform)
 {
     assert(sdata);
 
-    auto scale = 1.0f;
-
     if (transform) {
-        //Fast Track: if x/y scale factor is identical, we can scale width size simply.
-        auto sx = sqrt(pow(transform->e11, 2) + pow(transform->e21, 2));
-        auto sy = sqrt(pow(transform->e12, 2) + pow(transform->e22, 2));
-        if (fabsf(sx - sy) < FLT_EPSILON) {
-            scale = sx;
-            stroke.postScale = false;
-        //Try scaling stroke with normal approach.
-        } else {
-            stroke.postScale = true;
-            stroke.sx = sx;
-            stroke.sy = sy;
-        }
+        stroke.sx = sqrt(pow(transform->e11, 2) + pow(transform->e21, 2));
+        stroke.sy = sqrt(pow(transform->e12, 2) + pow(transform->e22, 2));
     } else {
-        stroke.postScale = false;
+        stroke.sx = stroke.sy = 1.0f;
     }
 
-    stroke.width = TO_SWCOORD(sdata->strokeWidth() * 0.5 * scale);
+    stroke.width = TO_SWCOORD(sdata->strokeWidth() * 0.5);
     stroke.cap = sdata->strokeCap();
 
     //Save line join: it can be temporarily changed when stroking curves...