sw_engine: optimize span generation. 17/236917/1
authorHermet Park <chuneon.park@samsung.com>
Tue, 23 Jun 2020 08:29:28 +0000 (17:29 +0900)
committerHermet Park <chuneon.park@samsung.com>
Tue, 23 Jun 2020 08:29:28 +0000 (17:29 +0900)
there are unnecessary partial spans generated in orthogonal rectangle.

we can merge those partial spans to others if they are on the same scanline...

Change-Id: I35a437a4f2eec106bd50f46f0390c652e617311d

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

index 076cccd..71af7df 100644 (file)
@@ -19,7 +19,7 @@
 
 #include "tvgCommon.h"
 
-#if 1
+#if 0
 #include <sys/time.h>
 static double timeStamp()
 {
index bd7f81e..2a9ba69 100644 (file)
@@ -189,7 +189,7 @@ void fillFetchRadial(const SwFill* fill, uint32_t* dst, uint32_t y, uint32_t x,
 {
     if (fill->radial.a < FLT_EPSILON) return;
 
-    //TODO: Rotation???
+    //Rotation
     auto rx = x + 0.5f - fill->radial.cx;
     auto ry = y + 0.5f - fill->radial.cy;
     auto inv2a = fill->radial.inv2a;
@@ -199,13 +199,12 @@ void fillFetchRadial(const SwFill* fill, uint32_t* dst, uint32_t y, uint32_t x,
     auto detDelta = (4 * fill->radial.a * (rxryPlus + 1.0f)) * inv2a;
     auto detDelta2 = (4 * fill->radial.a * 2.0f) * inv2a;
 
-   for (uint32_t i = 0 ; i < len ; ++i)
-     {
+   for (uint32_t i = 0 ; i < len ; ++i) {
         *dst = _pixel(fill, sqrt(det));
         ++dst;
         det += detDelta;
         detDelta += detDelta2;
-     }
+    }
 }
 
 
@@ -213,7 +212,7 @@ void fillFetchLinear(const SwFill* fill, uint32_t* dst, uint32_t y, uint32_t x,
 {
     if (fill->linear.len < FLT_EPSILON) return;
 
-    //TODO: Rotation???
+    //Rotation
     auto rx = x + 0.5f;
     auto ry = y + 0.5f;
     auto t = (fill->linear.dx * rx + fill->linear.dy * ry + fill->linear.offset) * (GRADIENT_STOP_SIZE - 1);
index cab5463..5d7d5a7 100644 (file)
@@ -195,7 +195,7 @@ static void _horizLine(RleWorker& rw, SwCoord x, SwCoord y, SwCoord area, SwCoor
         y = SHRT_MAX;
     }
 
-    if (coverage) {
+    if (coverage > 0) {
         auto count = rw.spansCnt;
         auto span = rw.spans + count - 1;
         assert(span);
@@ -209,13 +209,15 @@ static void _horizLine(RleWorker& rw, SwCoord x, SwCoord y, SwCoord area, SwCoor
             if (x + acount >= rw.clip.w) xOver -= (x + acount - rw.clip.w);
             if (x < 0) xOver += x;
 
-            span->len += (acount + xOver) - 1;
+            //span->len += (acount + xOver) - 1;
+            span->len += (acount + xOver);
             return;
         }
 
         if (count >=  MAX_SPANS) {
             _genSpan(rw.rle, rw.spans, count);
             rw.spansCnt = 0;
+            rw.ySpan = 0;
             span = rw.spans;
             assert(span);
         } else {
@@ -240,6 +242,7 @@ static void _horizLine(RleWorker& rw, SwCoord x, SwCoord y, SwCoord area, SwCoor
         span->len = (acount + xOver);
         span->coverage = coverage;
         ++rw.spansCnt;
+        rw.ySpan = y;
     }
 }
 
@@ -249,6 +252,7 @@ static void _sweep(RleWorker& rw)
     if (rw.cellsCnt == 0) return;
 
     rw.spansCnt = 0;
+    rw.ySpan = 0;
 
     for (int y = 0; y < rw.yCnt; ++y) {
         auto cover = 0;
@@ -775,6 +779,4 @@ void rleFree(SwRleData* rle)
     free(rle);
 }
 
-
-
 #endif /* _TVG_SW_RLE_H_ */