Skip to content

Add ThorVG (lottie) support to LVGL #83519

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
thomasstenersen opened this issue Jan 3, 2025 · 6 comments
Open

Add ThorVG (lottie) support to LVGL #83519

thomasstenersen opened this issue Jan 3, 2025 · 6 comments
Assignees
Labels
area: LVGL Light and Versatile Graphics Library Support Feature Request A request for a new feature

Comments

@thomasstenersen
Copy link
Collaborator

thomasstenersen commented Jan 3, 2025

Is your feature request related to a problem? Please describe.
PR #68168 updates LVGL to version 9+ which now has built-in support for handling lottie animations through ThorVG. However, to limit the scope of the PR, it does not include the necessary changes to make ThorVG work in Zephyr.

To get the added ThorVG support there are a few minor things that needs to be fixed:

  1. Fix some minor issues related to cross compilation (at least with GNU Arm toolchain) in LVGL/ThorVG:
  2. Expose strdup() in the libc
  3. Add the ThorVG sources to the LVGL module: thomasstenersen@e4665f5

Describe the solution you'd like
It looks like ThorVG is copied directly from https://github.com/thorvg/thorvg into https://github.com/lvgl/lvgl, so fixing the first issue should be done with a PR to ThorVG first before updating https://github.com/lvgl/lvgl and pulling in the update into Zephyr. Exposing strdup() in the libc can be done independently though.

Additional context
I've created a proof of context branch in my Zephyr fork. I've also added a sample (samples/subsys/display/lvgl_lottie) to showcase the feature. The sample has been tested on native_sim and stm32f746g_disco.

@thomasstenersen thomasstenersen added Feature Request A request for a new feature area: LVGL Light and Versatile Graphics Library Support labels Jan 3, 2025
@faxe1008
Copy link
Collaborator

faxe1008 commented Jan 7, 2025

I started checking those:

Usage of alloca should be fine, issue seems to be that they are including the wrong header:
thomasstenersen/lvgl@0b70f62#diff-92a7e772b0481b241d2ff321660a14464695a54de5dcd80976a9f79eb9f511acL29

So the fix is possibly to include alloca.h if __ZEPHYR__ is defined or is there more of an issue to alloca? I see that its used in some places intree.

@faxe1008
Copy link
Collaborator

faxe1008 commented Jan 8, 2025

strdup is available if _POSIX_C_SOURCE=200809L is defined.

@faxe1008
Copy link
Collaborator

faxe1008 commented Jan 8, 2025

Trying to fix the thorvg issues at the source: thorvg/thorvg#3107

@faxe1008
Copy link
Collaborator

So the fixes were upstreamed to ThorVG, waiting for the update of the library within LVGL.
See the related discussion: lvgl/lvgl#7834
ThorVG v1.0 will be released somewhere around March.

@nguterresn
Copy link

This is still an issue with Zephyr 4.1.0. The following functions have caused compilation errors due to missing reference:

  • strdup
  • alloca
  • strcasecmp

strdup is available if _POSIX_C_SOURCE=200809L is defined.

This has fixed strdup for me.

So the fix is possibly to include alloca.h if ZEPHYR is defined or is there more of an issue to alloca? I see that it's used in some places intree.

Yes, it fixes the issue:

#ifdef _WIN32
    #include <malloc.h>
#elif defined(__linux__) || defined(__ZEPHYR__)
    #include <alloca.h>
#else
    #include <stdlib.h>
#endif

However, for strcasecmp, I had to include a function as such:

static int strcasecmp(const char* s1, const char* s2) {
    while (*s1 && *s2) {
        int diff = tolower((unsigned char)*s1) - tolower((unsigned char)*s2);
        if (diff != 0)
            return diff;
        s1++;
        s2++;
    }
    return tolower((unsigned char)*s1) - tolower((unsigned char)*s2);
}

Is there a fix for this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: LVGL Light and Versatile Graphics Library Support Feature Request A request for a new feature
Projects
None yet
Development

No branches or pull requests

3 participants