sw_engine: memory optimization.
authorHermet Park <chuneon.park@samsung.com>
Thu, 12 Aug 2021 11:06:07 +0000 (20:06 +0900)
committerJunsuChoi <jsuya.choi@samsung.com>
Fri, 13 Aug 2021 05:21:50 +0000 (14:21 +0900)
Save the size of the Countour array,
16 bits is large enough to count the points number in one Shape.

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

index 0fb59d3..e32b806 100644 (file)
@@ -98,12 +98,12 @@ struct SwSize
 
 struct SwOutline
 {
-    uint32_t*     cntrs;            //the contour end points
-    uint32_t      cntrsCnt;         //number of contours in glyph
-    uint32_t      reservedCntrsCnt;
     SwPoint*      pts;              //the outline's points
-    uint32_t      ptsCnt;           //number of points in the glyph
-    uint32_t      reservedPtsCnt;
+    uint16_t      ptsCnt;           //number of points in the glyph
+    uint16_t      reservedPtsCnt;
+    uint16_t*     cntrs;            //the contour end points
+    uint16_t      cntrsCnt;         //number of contours in glyph
+    uint16_t      reservedCntrsCnt;
     uint8_t*      types;            //curve type
     bool*         closed;           //opened or closed path?
     FillRule      fillRule;
index 7a9ad4d..185b801 100644 (file)
@@ -39,7 +39,7 @@ static bool _genOutline(SwImage* image, const Matrix* transform, SwMpool* mpool,
 
     if (outline->reservedCntrsCnt < 1) {
         outline->reservedCntrsCnt = 1;
-        outline->cntrs = static_cast<uint32_t*>(realloc(outline->cntrs, outline->reservedCntrsCnt * sizeof(uint32_t)));
+        outline->cntrs = static_cast<uint16_t*>(realloc(outline->cntrs, outline->reservedCntrsCnt * sizeof(uint16_t)));
         outline->closed = static_cast<bool*>(realloc(outline->closed, outline->reservedCntrsCnt * sizeof(bool)));
         outline->closed[0] = true;
     }
index d8c4b06..4ccbff6 100644 (file)
@@ -62,7 +62,7 @@ static bool _growOutlineContour(SwOutline& outline, uint32_t n)
 {
     if (outline.reservedCntrsCnt >= outline.cntrsCnt + n) return false;
     outline.reservedCntrsCnt = outline.cntrsCnt + n;
-    outline.cntrs = static_cast<uint32_t*>(realloc(outline.cntrs, outline.reservedCntrsCnt * sizeof(uint32_t)));
+    outline.cntrs = static_cast<uint16_t*>(realloc(outline.cntrs, outline.reservedCntrsCnt * sizeof(uint16_t)));
     return true;
 }
 
index dda4a9b..e7f9c77 100644 (file)
@@ -921,7 +921,7 @@ SwOutline* strokeExportOutline(SwStroke* stroke, SwMpool* mpool, unsigned tid)
         outline->reservedPtsCnt = ptsCnt;
     }
     if (outline->reservedCntrsCnt < cntrsCnt) {
-        outline->cntrs = static_cast<uint32_t*>(realloc(outline->cntrs, sizeof(uint32_t) * cntrsCnt));
+        outline->cntrs = static_cast<uint16_t*>(realloc(outline->cntrs, sizeof(uint16_t) * cntrsCnt));
         outline->reservedCntrsCnt = cntrsCnt;
     }