From 27b49dcf4507c9c23f4fc0c171ab0e0517ef7e08 Mon Sep 17 00:00:00 2001 From: Hermet Park Date: Wed, 17 Jan 2024 17:26:29 +0900 Subject: [PATCH] examples: revise the usage. Remove the canvas buffer clear call when the solid bg is introduced. --- src/examples/Animation.cpp | 9 +++++++-- src/examples/DirectUpdate.cpp | 5 ++--- src/examples/Lottie.cpp | 3 ++- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/examples/Animation.cpp b/src/examples/Animation.cpp index 201eed38..9edbd357 100644 --- a/src/examples/Animation.cpp +++ b/src/examples/Animation.cpp @@ -28,15 +28,16 @@ static unique_ptr animation; static Elm_Transit *transit; +static bool updated = false; void tvgUpdateCmds(tvg::Canvas* canvas, tvg::Animation* animation, float progress) { - if (!canvas) return; - canvas->clear(false); + if (updated || !canvas) return; //Update animation frame only when it's changed if (animation->frame(animation->totalFrame() * progress) == tvg::Result::Success) { canvas->update(); + updated = true; } } @@ -101,8 +102,12 @@ void tvgSwTest(uint32_t* buffer) void drawSwView(void* data, Eo* obj) { + //It's not necessary to clear buffer since it has a solid background + //swCanvas->clear(false); + if (swCanvas->draw() == tvg::Result::Success) { swCanvas->sync(); + updated = false; } } diff --git a/src/examples/DirectUpdate.cpp b/src/examples/DirectUpdate.cpp index 2c20052c..9383379d 100644 --- a/src/examples/DirectUpdate.cpp +++ b/src/examples/DirectUpdate.cpp @@ -61,9 +61,8 @@ void tvgUpdateCmds(tvg::Canvas* canvas, float progress) { if (!canvas) return; - /* Update shape directly. - You can update necessary properties of this shape. */ - canvas->clear(false); + //It's not necessary to clear canvas since it has a solid background and retaining the paints. + //canvas->clear(false); //Reset Shape if (pShape->reset() == tvg::Result::Success) { diff --git a/src/examples/Lottie.cpp b/src/examples/Lottie.cpp index 690ed110..649e0c3a 100644 --- a/src/examples/Lottie.cpp +++ b/src/examples/Lottie.cpp @@ -142,7 +142,8 @@ void tvgSwTest(uint32_t* buffer) void drawSwView(void* data, Eo* obj) { - swCanvas->clear(false); + //It's not necessary to clear buffer since it has a solid background + //swCanvas->clear(false); //canvas update auto before = ecore_time_get();