thorvg / thorvg.flutter

ThorVG for Flutter System
https://www.thorvg.org
MIT License
2 stars 0 forks source link

Native threading support #5

Open tinyjin opened 1 month ago

tinyjin commented 1 month ago

Native application could leverage threading feature.

Currently, thorvg.flutter initializes with 0 config, which means this won't thread.

We might need to check to use thread.

explicit TvgLottieAnimation()
{
    errorMsg = NoError;

    // No threading
    if (Initializer::init(CanvasEngine::Sw, 0) != Result::Success)
    {
        errorMsg = "init() fail";
        return;
    }

    canvas = SwCanvas::gen();
    if (!canvas) errorMsg = "Invalid canvas";

    animation = Animation::gen();
    if (!animation) errorMsg = "Invalid animation";
}

We can drive Widget parameters for user so they can decided how many thread they want to enable. Something like this:

Lottie.network(
  'https://lottie.host/6d7dd6e2-ab92-4e98-826a-2f8430768886/NGnHQ6brWA.json',
  renderConfig: RenderConfig(
    threads: 4
   )
),
hermet commented 1 month ago

@tinyjin Suggest the default thread as 4.