From 9a6eff8ce29dc2d338ff8cca1cd2934faadbeb62 Mon Sep 17 00:00:00 2001 From: Hermet Park Date: Fri, 2 Feb 2024 12:28:17 +0900 Subject: [PATCH] examples: updated DirectUpdate sample Properly guide a sample usage to guarantee the sync call. --- src/examples/DirectUpdate.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/examples/DirectUpdate.cpp b/src/examples/DirectUpdate.cpp index 9383379d..0f4de61d 100644 --- a/src/examples/DirectUpdate.cpp +++ b/src/examples/DirectUpdate.cpp @@ -26,6 +26,7 @@ /* Drawing Commands */ /************************************************************************/ tvg::Shape* pShape = nullptr; +static bool updated = false; void tvgDrawCmds(tvg::Canvas* canvas) { @@ -55,11 +56,13 @@ void tvgDrawCmds(tvg::Canvas* canvas) shape->strokeWidth(1); if (canvas->push(std::move(shape)) != tvg::Result::Success) return; + + updated = true; } void tvgUpdateCmds(tvg::Canvas* canvas, float progress) { - if (!canvas) return; + if (updated || !canvas) return; //It's not necessary to clear canvas since it has a solid background and retaining the paints. //canvas->clear(false); @@ -73,6 +76,7 @@ void tvgUpdateCmds(tvg::Canvas* canvas, float progress) //Update shape for drawing (this may work asynchronously) canvas->update(pShape); + updated = true; } } @@ -110,6 +114,7 @@ void drawSwView(void* data, Eo* obj) { if (swCanvas->draw() == tvg::Result::Success) { swCanvas->sync(); + updated = false; } }