mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-09 14:13:43 +00:00
examples: revise the usage.
Remove the canvas buffer clear call when the solid bg is introduced.
This commit is contained in:
parent
71cc7c2e30
commit
27b49dcf45
3 changed files with 11 additions and 6 deletions
|
@ -28,15 +28,16 @@
|
||||||
|
|
||||||
static unique_ptr<tvg::Animation> animation;
|
static unique_ptr<tvg::Animation> animation;
|
||||||
static Elm_Transit *transit;
|
static Elm_Transit *transit;
|
||||||
|
static bool updated = false;
|
||||||
|
|
||||||
void tvgUpdateCmds(tvg::Canvas* canvas, tvg::Animation* animation, float progress)
|
void tvgUpdateCmds(tvg::Canvas* canvas, tvg::Animation* animation, float progress)
|
||||||
{
|
{
|
||||||
if (!canvas) return;
|
if (updated || !canvas) return;
|
||||||
canvas->clear(false);
|
|
||||||
|
|
||||||
//Update animation frame only when it's changed
|
//Update animation frame only when it's changed
|
||||||
if (animation->frame(animation->totalFrame() * progress) == tvg::Result::Success) {
|
if (animation->frame(animation->totalFrame() * progress) == tvg::Result::Success) {
|
||||||
canvas->update();
|
canvas->update();
|
||||||
|
updated = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,8 +102,12 @@ void tvgSwTest(uint32_t* buffer)
|
||||||
|
|
||||||
void drawSwView(void* data, Eo* obj)
|
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) {
|
if (swCanvas->draw() == tvg::Result::Success) {
|
||||||
swCanvas->sync();
|
swCanvas->sync();
|
||||||
|
updated = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -61,9 +61,8 @@ void tvgUpdateCmds(tvg::Canvas* canvas, float progress)
|
||||||
{
|
{
|
||||||
if (!canvas) return;
|
if (!canvas) return;
|
||||||
|
|
||||||
/* Update shape directly.
|
//It's not necessary to clear canvas since it has a solid background and retaining the paints.
|
||||||
You can update necessary properties of this shape. */
|
//canvas->clear(false);
|
||||||
canvas->clear(false);
|
|
||||||
|
|
||||||
//Reset Shape
|
//Reset Shape
|
||||||
if (pShape->reset() == tvg::Result::Success) {
|
if (pShape->reset() == tvg::Result::Success) {
|
||||||
|
|
|
@ -142,7 +142,8 @@ void tvgSwTest(uint32_t* buffer)
|
||||||
|
|
||||||
void drawSwView(void* data, Eo* obj)
|
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
|
//canvas update
|
||||||
auto before = ecore_time_get();
|
auto before = ecore_time_get();
|
||||||
|
|
Loading…
Add table
Reference in a new issue