sw_engine: support stroke transformation properly. 94/235194/2
authorHermet Park <chuneon.park@samsung.com>
Tue, 2 Jun 2020 12:00:50 +0000 (21:00 +0900)
committerHermet Park <chuneon.park@samsung.com>
Wed, 3 Jun 2020 03:08:48 +0000 (12:08 +0900)
also updated transform test cases.

Yet, this engine is not well optimized,
If they are too mch sluggish,
you can use ELM_FPS envrionment lowing down the fps
when you launch test cases...

ex) $ELM_FPS=30 ./testSceneTransform

Change-Id: I1871d5bedee010d5d6a3d877d95e257120796e8b

src/lib/sw_engine/tvgSwRenderer.cpp
test/testDirectUpdate.cpp
test/testSceneTransform.cpp

index 3ec882e..91c0013 100644 (file)
@@ -93,29 +93,34 @@ void* SwRenderer::prepare(const Shape& shape, void* data, const RenderTransform*
 
     if (flags == RenderUpdateFlag::None) return sdata;
 
-    //invisible?
-    size_t a, sa;
-    shape.fill(nullptr, nullptr, nullptr, &a);
-    shape.strokeColor(nullptr, nullptr, nullptr, &sa);
-    if (a == 0 && sa == 0) return sdata;
-
     //TODO: Threading
 
     SwSize clip = {static_cast<SwCoord>(surface.w), static_cast<SwCoord>(surface.h)};
 
     //Shape
     if (flags & (RenderUpdateFlag::Path | RenderUpdateFlag::Transform)) {
-        shapeReset(*sdata);
-        if (!shapeGenOutline(shape, *sdata)) return sdata;
-        if (transform) shapeTransformOutline(shape, *sdata, *transform);
-        if (!shapeGenRle(shape, *sdata, clip)) return sdata;
+
+        size_t alpha = 0;
+        shape.fill(nullptr, nullptr, nullptr, &alpha);
+
+        if (alpha > 0) {
+            shapeReset(*sdata);
+            if (!shapeGenOutline(shape, *sdata)) return sdata;
+            if (transform) shapeTransformOutline(shape, *sdata, *transform);
+            if (!shapeGenRle(shape, *sdata, clip)) return sdata;
+        }
     }
 
     //Stroke
-    if (flags & RenderUpdateFlag::Stroke) {
-        shapeResetStroke(shape, *sdata);
-        if (shape.strokeWidth() > 0.01) {
-            if (!shapeGenStrokeRle(shape, *sdata, clip)) return sdata;
+    if (flags & (RenderUpdateFlag::Stroke | RenderUpdateFlag::Transform)) {
+
+        if (shape.strokeWidth() > 0.5) {
+            shapeResetStroke(shape, *sdata);
+            size_t alpha = 0;
+            shape.strokeColor(nullptr, nullptr, nullptr, &alpha);
+            if (alpha > 0) {
+                if (!shapeGenStrokeRle(shape, *sdata, clip)) return sdata;
+            }
         }
     }
 
index 799d135..e1a4c60 100644 (file)
@@ -27,6 +27,8 @@ void tvgtest()
 
     //fill property will be retained
     shape->fill(127, 255, 255, 255);
+    shape->stroke(0, 0, 255, 255);
+    shape->stroke(1);
 
     canvas->push(move(shape));
 
@@ -44,6 +46,7 @@ void transit_cb(Elm_Transit_Effect *effect, Elm_Transit* transit, double progres
     pShape->reset();    //reset path
 
     pShape->appendRect(-100 + (800 * progress), -100 + (800 * progress), 200, 200, (100 * progress));
+    pShape->stroke(30 * progress);
 
     //Update shape for drawing (this may work asynchronously)
     canvas->update(pShape);
index a66996a..975f4fa 100644 (file)
@@ -25,19 +25,21 @@ void tvgtest()
     //Prepare Round Rectangle (Scene1)
     auto shape1 = tvg::Shape::gen();
     shape1->appendRect(-235, -250, 400, 400, 50);      //x, y, w, h, cornerRadius
-    shape1->fill(0, 255, 0, 255);                //r, g, b, a
+    shape1->fill(0, 255, 0, 255);                      //r, g, b, a
+    shape1->stroke(5);                                 //width
+    shape1->stroke(255, 255, 255, 255);                //r, g, b, a
     scene->push(move(shape1));
 
     //Prepare Circle (Scene1)
     auto shape2 = tvg::Shape::gen();
     shape2->appendCircle(-165, -150, 200, 200);    //cx, cy, radiusW, radiusH
-    shape2->fill(255, 255, 0, 255);              //r, g, b, a
+    shape2->fill(255, 255, 0, 255);                //r, g, b, a
     scene->push(move(shape2));
 
     //Prepare Ellipse (Scene1)
     auto shape3 = tvg::Shape::gen();
-    shape3->appendCircle(265, 250, 150, 100);    //cx, cy, radiusW, radiusH
-    shape3->fill(0, 255, 255, 255);              //r, g, b, a
+    shape3->appendCircle(265, 250, 150, 100);      //cx, cy, radiusW, radiusH
+    shape3->fill(0, 255, 255, 255);                //r, g, b, a
     scene->push(move(shape3));
 
     scene->translate(350, 350);
@@ -64,6 +66,8 @@ void tvgtest()
     shape4->lineTo(-53, -5.5);
     shape4->close();
     shape4->fill(0, 0, 127, 127);
+    shape4->stroke(3);                             //width
+    shape4->stroke(0, 0, 255, 255);                //r, g, b, a
     scene2->push(move(shape4));
 
     //Circle (Scene2)