From f03cff2353170899ad48492c95c11a6b27e603e7 Mon Sep 17 00:00:00 2001 From: Hermet Park Date: Fri, 23 Feb 2024 12:20:43 +0900 Subject: [PATCH] examples: ++threading stability. Ensure synchronous calls are made after updating the canvases. --- src/examples/AnimateMasking.cpp | 10 ++++++++-- src/examples/Animation.cpp | 1 + src/examples/DirectUpdate.cpp | 3 ++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/examples/AnimateMasking.cpp b/src/examples/AnimateMasking.cpp index ce5229f0..c97519cd 100644 --- a/src/examples/AnimateMasking.cpp +++ b/src/examples/AnimateMasking.cpp @@ -26,8 +26,9 @@ /* Drawing Commands */ /************************************************************************/ -tvg::Shape *pMaskShape = nullptr; -tvg::Shape *pMask = nullptr; +static tvg::Shape *pMaskShape = nullptr; +static tvg::Shape *pMask = nullptr; +static bool updated = false; void tvgDrawCmds(tvg::Canvas* canvas) @@ -67,6 +68,8 @@ void tvgDrawCmds(tvg::Canvas* canvas) picture2->composite(std::move(mask), tvg::CompositeMethod::AlphaMask); if (canvas->push(std::move(picture2)) != tvg::Result::Success) return; + + updated = true; } @@ -93,6 +96,7 @@ void drawSwView(void* data, Eo* obj) { if (swCanvas->draw() == tvg::Result::Success) { swCanvas->sync(); + updated = false; } } @@ -109,6 +113,7 @@ void tvgUpdateCmds(tvg::Canvas* canvas, float progress) pMask->translate(0 , progress * 300 - 100); canvas->update(); + updated = true; } void transitSwCb(Elm_Transit_Effect *effect, Elm_Transit* transit, double progress) @@ -149,6 +154,7 @@ void drawGLview(Evas_Object *obj) if (glCanvas->draw() == tvg::Result::Success) { glCanvas->sync(); + updated = false; } } diff --git a/src/examples/Animation.cpp b/src/examples/Animation.cpp index b95778db..c5f67be5 100644 --- a/src/examples/Animation.cpp +++ b/src/examples/Animation.cpp @@ -147,6 +147,7 @@ void drawGLview(Evas_Object *obj) if (glCanvas->draw() == tvg::Result::Success) { glCanvas->sync(); + updated = false; } } diff --git a/src/examples/DirectUpdate.cpp b/src/examples/DirectUpdate.cpp index f0b001da..0dca0fb3 100644 --- a/src/examples/DirectUpdate.cpp +++ b/src/examples/DirectUpdate.cpp @@ -25,7 +25,7 @@ /************************************************************************/ /* Drawing Commands */ /************************************************************************/ -tvg::Shape* pShape = nullptr; +static tvg::Shape* pShape = nullptr; static bool updated = false; void tvgDrawCmds(tvg::Canvas* canvas) @@ -148,6 +148,7 @@ void drawGLview(Evas_Object *obj) if (glCanvas->draw() == tvg::Result::Success) { glCanvas->sync(); + updated = false; } }