sw_engine: code refactoring. 61/232361/1
authorHermet Park <chuneon.park@samsung.com>
Sat, 2 May 2020 08:44:49 +0000 (17:44 +0900)
committerHermet Park <chuneon.park@samsung.com>
Sat, 2 May 2020 08:44:49 +0000 (17:44 +0900)
renamed internal variables for better readibility.

Change-Id: I1ba7938401e8b7249c8bcc396be1ba3c109716cd

src/lib/sw_engine/tvgSwCommon.h
src/lib/sw_engine/tvgSwRle.cpp
src/lib/sw_engine/tvgSwShape.cpp

index 4b31bcd..2900577 100644 (file)
@@ -21,8 +21,8 @@
 
 using namespace tvg;
 
-constexpr auto SW_CURVE_TAG_ON = 1;
-constexpr auto SW_CURVE_TAG_CUBIC = 2;
+constexpr auto SW_CURVE_TYPE_POINT = 0;
+constexpr auto SW_CURVE_TYPE_CUBIC = 1;
 constexpr auto SW_OUTLINE_FILL_WINDING = 0;
 constexpr auto SW_OUTLINE_FILL_EVEN_ODD = 1;
 
@@ -62,7 +62,7 @@ struct SwOutline
     SwPoint*    pts;              //the outline's points
     size_t      ptsCnt;           //number of points in the glyph
     size_t      reservedPtsCnt;
-    char*       tags;             //the points flags
+    uint8_t*    types;            //curve type
     uint8_t     fillMode;         //outline fill mode
 };
 
index f915a5d..ea2e451 100644 (file)
@@ -606,27 +606,27 @@ static bool _decomposeOutline(RleWorker& rw)
         assert(limit);
 
         auto pt = outline->pts + first;
-        auto tags = outline->tags + first;
+        auto types = outline->types + first;
 
         /* A contour cannot start with a cubic control point! */
-        if (tags[0] == SW_CURVE_TAG_CUBIC) goto invalid_outline;
+        if (types[0] == SW_CURVE_TYPE_CUBIC) goto invalid_outline;
 
         _moveTo(rw, UPSCALE(outline->pts[first]));
 
         while (pt < limit) {
             assert(++pt);
-            assert(++tags);
+            assert(++types);
 
             //emit a single line_to
-            if (tags[0] == SW_CURVE_TAG_ON) {
+            if (types[0] == SW_CURVE_TYPE_POINT) {
                 _lineTo(rw, UPSCALE(*pt));
-            //tag cubic
+            //types cubic
             } else {
-                if (pt + 1 > limit || tags[1] != SW_CURVE_TAG_CUBIC)
+                if (pt + 1 > limit || types[1] != SW_CURVE_TYPE_CUBIC)
                     goto invalid_outline;
 
                 pt += 2;
-                tags += 2;
+                types += 2;
 
                 if (pt <= limit) {
                     _cubicTo(rw, UPSCALE(pt[-2]), UPSCALE(pt[-1]), UPSCALE(pt[0]));
index 1f24a63..8223545 100644 (file)
@@ -52,8 +52,8 @@ static void _growOutlinePoint(SwOutline& outline, size_t n)
     if (n == 0) {
         free(outline.pts);
         outline.pts = nullptr;
-        free(outline.tags);
-        outline.tags = nullptr;
+        free(outline.types);
+        outline.types = nullptr;
         outline.reservedPtsCnt = 0;
         outline.ptsCnt = 0;
         return;
@@ -65,8 +65,8 @@ static void _growOutlinePoint(SwOutline& outline, size_t n)
     outline.reservedPtsCnt = n;
     outline.pts = static_cast<SwPoint*>(realloc(outline.pts, n * sizeof(SwPoint)));
     assert(outline.pts);
-    outline.tags = static_cast<char*>(realloc(outline.tags, n * sizeof(char)));
-    assert(outline.tags);
+    outline.types = static_cast<uint8_t*>(realloc(outline.types, n * sizeof(uint8_t)));
+    assert(outline.types);
 }
 
 
@@ -87,7 +87,7 @@ static void _outlineMoveTo(SwOutline& outline, const Point* to)
     _growOutlinePoint(outline, 1);
 
     outline.pts[outline.ptsCnt] = TO_SWPOINT(to);
-    outline.tags[outline.ptsCnt] = SW_CURVE_TAG_ON;
+    outline.types[outline.ptsCnt] = SW_CURVE_TYPE_POINT;
 
     if (outline.ptsCnt > 0) {
         _growOutlineContour(outline, 1);
@@ -106,7 +106,7 @@ static void _outlineLineTo(SwOutline& outline, const Point* to)
     _growOutlinePoint(outline, 1);
 
     outline.pts[outline.ptsCnt] = TO_SWPOINT(to);
-    outline.tags[outline.ptsCnt] = SW_CURVE_TAG_ON;
+    outline.types[outline.ptsCnt] = SW_CURVE_TYPE_POINT;
 
     ++outline.ptsCnt;
 }
@@ -119,15 +119,15 @@ static void _outlineCubicTo(SwOutline& outline, const Point* ctrl1, const Point*
     _growOutlinePoint(outline, 3);
 
     outline.pts[outline.ptsCnt] = TO_SWPOINT(ctrl1);
-    outline.tags[outline.ptsCnt] = SW_CURVE_TAG_CUBIC;
+    outline.types[outline.ptsCnt] = SW_CURVE_TYPE_CUBIC;
     ++outline.ptsCnt;
 
     outline.pts[outline.ptsCnt] = TO_SWPOINT(ctrl2);
-    outline.tags[outline.ptsCnt] = SW_CURVE_TAG_CUBIC;
+    outline.types[outline.ptsCnt] = SW_CURVE_TYPE_CUBIC;
     ++outline.ptsCnt;
 
     outline.pts[outline.ptsCnt] = TO_SWPOINT(to);
-    outline.tags[outline.ptsCnt] = SW_CURVE_TAG_ON;
+    outline.types[outline.ptsCnt] = SW_CURVE_TYPE_POINT;
     ++outline.ptsCnt;
 }
 
@@ -149,7 +149,7 @@ static bool _outlineClose(SwOutline& outline)
     _growOutlinePoint(outline, 1);
 
     outline.pts[outline.ptsCnt] = outline.pts[i];
-    outline.tags[outline.ptsCnt] = SW_CURVE_TAG_ON;
+    outline.types[outline.ptsCnt] = SW_CURVE_TYPE_POINT;
     ++outline.ptsCnt;
 
     return true;
@@ -218,7 +218,7 @@ void _deleteOutline(SwShape& sdata)
     SwOutline* outline = sdata.outline;
     if (outline->cntrs) free(outline->cntrs);
     if (outline->pts) free(outline->pts);
-    if (outline->tags) free(outline->tags);
+    if (outline->types) free(outline->types);
     free(outline);
 
     sdata.outline = nullptr;