sw_engine: fix to update stroking transform 15/237415/5
authorHermet Park <chuneon.park@samsung.com>
Tue, 30 Jun 2020 07:57:31 +0000 (16:57 +0900)
committerHermet Park <chuneon.park@samsung.com>
Tue, 30 Jun 2020 08:24:14 +0000 (17:24 +0900)
when shape doesn't have fill color, stroking is missed in update.

this fixs that issue.

Change-Id: I49292475e56caa834e79497a16db705b965bcf5f

src/lib/sw_engine/tvgSwRenderer.cpp
src/lib/sw_engine/tvgSwShape.cpp
test/testCustomTransform.cpp

index 4f09c60..f6fc88b 100644 (file)
@@ -175,12 +175,19 @@ void* SwRenderer::prepare(const Shape& sdata, void* data, const RenderTransform*
     task->flags = flags;
 
     auto asyncTask = [](SwTask* task) {
+
+        //Valid Stroking?
+        uint8_t strokeAlpha = 0;
+        if (task->sdata->strokeWidth() > FLT_EPSILON) {
+            task->sdata->strokeColor(nullptr, nullptr, nullptr, &strokeAlpha);
+        }
+
         //Shape
         if (task->flags & (RenderUpdateFlag::Path | RenderUpdateFlag::Transform)) {
             shapeReset(task->shape);
             uint8_t alpha = 0;
             task->sdata->fill(nullptr, nullptr, nullptr, &alpha);
-            if (alpha > 0 || task->sdata->fill()) {
+            if (alpha > 0 || task->sdata->fill() || strokeAlpha > 0) {
                 if (!shapeGenRle(task->shape, task->sdata, task->clip, task->transform)) return;
             }
         }
@@ -197,13 +204,9 @@ void* SwRenderer::prepare(const Shape& sdata, void* data, const RenderTransform*
         }
         //Stroke
         if (task->flags & (RenderUpdateFlag::Stroke | RenderUpdateFlag::Transform)) {
-            if (task->sdata->strokeWidth() > FLT_EPSILON) {
+            if (strokeAlpha > 0) {
                 shapeResetStroke(task->shape, task->sdata);
-                uint8_t alpha = 0;
-                task->sdata->strokeColor(nullptr, nullptr, nullptr, &alpha);
-                if (alpha > 0) {
-                    if (!shapeGenStrokeRle(task->shape, task->sdata, task->clip)) return;
-                }
+                if (!shapeGenStrokeRle(task->shape, task->sdata, task->clip)) return;
             } else {
                 shapeDelStroke(task->shape);
             }
index 29ecf27..a4c811a 100644 (file)
@@ -211,7 +211,7 @@ static bool _updateBBox(SwOutline* outline, SwBBox& bbox)
     bbox.min.y = yMin >> 6;
     bbox.max.y = (yMax + 63) >> 6;
 
-    if (xMax - xMin < 1 || yMax - yMin < 1) return false;
+    if (xMax - xMin < 1 && yMax - yMin < 1) return false;
 
     return true;
 }
@@ -451,6 +451,9 @@ bool shapeGenRle(SwShape& shape, const Shape* sdata, const SwSize& clip, const M
 
     if (!_checkValid(shape.outline, shape.bbox, clip)) goto end;
 
+    //Case: Stroke Line
+    if (shape.outline->opened) return true;
+
     shape.rle = rleRender(shape.outline, shape.bbox, clip);
 end:
     if (shape.rle) return true;
index d87b481..27e3c6e 100644 (file)
@@ -26,6 +26,8 @@ void tvgDrawCmds(tvg::Canvas* canvas)
     shape->lineTo(-53, -5.5);
     shape->close();
     shape->fill(0, 0, 255, 255);
+    shape->stroke(3);
+    shape->stroke(255, 255, 255, 255);
     if (canvas->push(move(shape)) != tvg::Result::Success) return;
 }
 
@@ -203,4 +205,4 @@ int main(int argc, char **argv)
 
     //Terminate ThorVG Engine
     tvg::Initializer::term(tvgEngine);
-}
\ No newline at end of file
+}