sw_engine: fix shape rendering skip issue.
authorHermet Park <chuneon.park@samsung.com>
Wed, 9 Sep 2020 01:52:45 +0000 (10:52 +0900)
committerHermet Park <chuneon.park@samsung.com>
Wed, 9 Sep 2020 02:05:08 +0000 (11:05 +0900)
tvg canvas must draw retained shapes for every draw call
even though user missed call update() for shapes.

that case canvs must draw shapes without update,
it means drawing them within previous condition.

Change-Id: If15933bd1a04cd3c55dc04a7913f4833094b2b5d

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

index e69aaa4..07926b4 100644 (file)
@@ -138,28 +138,37 @@ bool SwRenderer::target(uint32_t* buffer, uint32_t stride, uint32_t w, uint32_t
 
 bool SwRenderer::preRender()
 {
-    rasterClear(surface);
-
-    //before we start rendering, we should finish all preparing tasks
-    for (auto task : tasks) {
-        task->get();
-
-        uint8_t r, g, b, a;
-        if (auto fill = task->sdata->fill()) {
-            rasterGradientShape(surface, &task->shape, fill->id());
-        } else{
-            task->sdata->fill(&r, &g, &b, &a);
-            if (a > 0) rasterSolidShape(surface, &task->shape, r, g, b, a);
-        }
-        task->sdata->strokeColor(&r, &g, &b, &a);
-        if (a > 0) rasterStroke(surface, &task->shape, r, g, b, a);
-    }
+    return rasterClear(surface);
+}
+
+
+bool SwRenderer::postRender()
+{
     tasks.clear();
 
     return true;
 }
 
 
+bool SwRenderer::render(const Shape& shape, void *data)
+{
+    auto task = static_cast<SwTask*>(data);
+    task->get();
+
+    uint8_t r, g, b, a;
+    if (auto fill = task->sdata->fill()) {
+        rasterGradientShape(surface, &task->shape, fill->id());
+    } else{
+        task->sdata->fill(&r, &g, &b, &a);
+        if (a > 0) rasterSolidShape(surface, &task->shape, r, g, b, a);
+    }
+    task->sdata->strokeColor(&r, &g, &b, &a);
+    if (a > 0) rasterStroke(surface, &task->shape, r, g, b, a);
+
+    return true;
+}
+
+
 bool SwRenderer::dispose(TVG_UNUSED const Shape& sdata, void *data)
 {
     auto task = static_cast<SwTask*>(data);
index 35fce30..016e444 100644 (file)
@@ -34,8 +34,10 @@ public:
     void* prepare(const Shape& shape, void* data, const RenderTransform* transform, RenderUpdateFlag flags) override;
     bool dispose(const Shape& shape, void *data) override;
     bool preRender() override;
+    bool postRender() override;
     bool target(uint32_t* buffer, uint32_t stride, uint32_t w, uint32_t h, uint32_t cs);
     bool clear() override;
+    bool render(const Shape& shape, void *data) override;
 
     static SwRenderer* gen();
     static bool init();
index 69105c3..96de6a6 100644 (file)
@@ -9,6 +9,15 @@ void tvgDrawCmds(tvg::Canvas* canvas)
 {
     if (!canvas) return;
 
+    //Shape (for BG)
+    auto bg = tvg::Shape::gen();
+    bg->appendRect(0, 0, WIDTH, HEIGHT, 0, 0);
+
+    //fill property will be retained
+    bg->fill(255, 255, 255, 255);
+
+    if (canvas->push(move(bg)) != tvg::Result::Success) return;
+
     //Shape
     auto shape = tvg::Shape::gen();