Upgrade to Pro — share decks privately, control downloads, hide ads and more …

ThorVG's Lottie Model in Action

Jinny You
February 20, 2024

ThorVG's Lottie Model in Action

A presentation about How ThorVG manages the Lottie file format and renders into the canvas.

By the session, Engineers will understand about a few ThorVG's mechanisms.

1. Introduction to ThorVG
2. ThorVG Lottie Model Mechanism
3. Lottie Parser mechanism
4. ThorVG’s Cross-Platform Capabilities

Jinny You

February 20, 2024
Tweet

More Decks by Jinny You

Other Decks in Programming

Transcript

  1. - Vector Graphics Engine - Light-weight (under 300kb) - Drawing

    APIs - Path, Rect, Circle - Native & Web(wasm) API - Supports Lottie - Platform independent capability
  2. Vector Graphics - Mathematical formula - Scalable - Smaller file

    size *.svg, .ai, .lottie - A set of pixels - Realistic - Low quality when scaled *.jpg, .png, .gif
  3. - Written in C++ (C-friendly) - Portable - Efficient -

    Tiny size - Low-level language - High portability - Intrinsic threading / memory pools / Caching mechanism - Light-weight (Small binary size)
  4. Lottie android Lottie ios Lottie web - All different language

    - Individual implementation - High-cost maintenance - Unoptimized performance & size
  5. Lottie android Lottie ios Lottie web - Rendered by different

    libraries - Different rendering result - Can’t predict animation result - Highly depends on the platform
  6. Lottie android Lottie ios Lottie web - Well-predictable animation -

    Same rendering result - Optimized performance & size - Low-cost maintenance ThorVG
  7. - Developers do not need to rework for each platform

    and programming languages. - Designers will not struggle to accommodate different device outputs. - End-users will have consistent experiences provided by service. ThorVG
  8. Feature coverage ✅ - Transform - Masks - Matte -

    Shape - Precomp - Image - Text (Glyph, Fonts) 🚧 - Expressions - Shape Modifier (MergePath, … ) - Layer Effect (Blending, Filter …) - Advanced Text (Font Origin, Path, Range Selector)
  9. - JSON file format - Vector Graphics Animation - Supports

    AE features: - Solids - Shape layers - Masks - Alpha mattes - Trim paths - Dash patterns Lottie File format
  10. <<interface>> Load Module <<interface>> RenderMethod API C++ TVG PNG JPG

    SVG Lottie Native Apps API JS/WASM Web Apps (frontend) sample.lottie (json) JSON Parser Lottie Scene Composer Lottie Interpreter I/O Picture Shape Scene Canvas Call APIs to compose TVG Scene TVG SceneTree Request Frame SwCanvas GlCanvas Task Scheduler <<shareable>> Path / Stroke / Fill Scene Shape Scene Shape Shape Compositor CompLayer ShapeLayer SolidLayer CompLayer ShapeLayer … Scene Shape Scene Shape Shape TVG SceneTree (Retainable) Call Call Text Lottie Loader ThorVG Single Binary [so/dll/wasm] Canvas Engine Extra Format Loaders Paint SW GL (beta) WG (beta) TTF Out WGCanvas
  11. ThorVG Lottie Parser ThorVG Lottie Builder ThorVG Lottie Model ThorVG

    Lottie Property ThorVG Core Engine (tvg::Renderer) ThorVG Lottie Loader Drawing Vector Graphics: - Rect, Circle, Path… Load lottie asset into memory Parse each attributes Build lottie animation Object, Group, Layer, Shape … Point, Color, Opacity, Fill, Path …
  12. ThorVG Lottie Parser ThorVG Lottie Builder ThorVG Lottie Model ThorVG

    Lottie Property ThorVG Core Engine (tvg::Renderer) ThorVG Lottie Loader Drawing Vector Graphics: - Rect, Circle, Path… Load lottie asset into memory Parse each attributes Build lottie animation Object, Group, Layer, Shape … Point, Color, Opacity, Fill, Path …
  13. ThorVG Lottie Parser ThorVG Lottie Builder ThorVG Lottie Model ThorVG

    Lottie Property ThorVG Core Engine (tvg::Renderer) ThorVG Lottie Loader Drawing Vector Graphics: - Rect, Circle, Path… Load lottie asset into memory Parse each attributes Build lottie animation Object, Group, Layer, Shape … Point, Color, Opacity, Fill, Path … “ Data ” Model
  14. Data Model: Lottie Object - Lottie element’s base structure. -

    Extends to specific layers and shapes - Has explicit type LottieObject + name + type LottieGroup LottieShape LottieLayer LottiePath LottieRect LottiePolyStar LottieEllipse LottieTransform LottieImage LottieStroke LottieRepeater LottieTrimPath LottieRoundedCorner // ShapeModifier
  15. Lottie Object Lottie Group Lottie Shape Lottie Property Lottie Stroke

    Lottie Image Lottie Fill Lottie Layer ThorVG Data Model Lottie Point Lottie Float Lottie Opacity Lottie Color Lottie TextDoc Lottie Position Lottie ColorStop Lottie Font
  16. Lottie Path Lottie Rect Lottie PolyStar Lottie Ellipse … ThorVG’s

    own lottie data model in C++ ThorVG Data Model
  17. ThorVG Lottie Parser ThorVG Lottie Loader ThorVG Lottie Model ThorVG

    Lottie Property Lottie Render Process ThorVG Core Engine (tvg::Renderer) ThorVG Lottie Builder tvg:: Software Raster Engine tvg:: WebGPU Raster Engine or
  18. Lottie Composition : Connecting interface among the renderer, loader, builder

    and data model Lottie Object Lottie Image Lottie Font Lottie Composition Lottie Object
  19. ThorVG Lottie Parser ThorVG Lottie Builder ThorVG Lottie Model ThorVG

    Lottie Property ThorVG Core Engine (tvg::Renderer) ThorVG Lottie Loader Drawing Vector Graphics: - Rect, Circle, Path… Load lottie asset into memory Parse each attributes Build lottie animation Object, Group, Layer, Shape … Point, Color, Opacity, Fill, Path …
  20. Lottie Loader Lottie Loader - The Lottie JSON loading interface

    - Load and manage file data in memory - Handle file size, frame info - Provide frame controls - Integrate lottie animation with the renderer
  21. Lottie Loader Lottie Parser parsing(“lottie.json”) return lottie model Lottie Parser

    Compositor CompLayer ShapeLayer SolidLayer CompLayer ShapeLayer … <JSON Parser> Rapid Json
  22. Lottie Parser Lottie Parser <JSON Parser> Rapid Json ThorVG Lottie

    Model Compositor CompLayer ShapeLayer SolidLayer CompLayer ShapeLayer …
  23. ThorVG Lottie Parser ThorVG Lottie Builder ThorVG Lottie Model ThorVG

    Lottie Property ThorVG Core Engine (tvg::Renderer) ThorVG Lottie Loader Drawing Vector Graphics: - Rect, Circle, Path… Load lottie asset into memory Parse each attributes Build lottie animation Object, Group, Layer, Shape … Point, Color, Opacity, Fill, Path …
  24. Compositor ShapeLayer SolidLayer CompLayer ShapeLayer … TVG Lottie Model RootLayer

    NullLayer Group Transform Shape Stroke Fill <Shape> +Path +Fill +Stroke +Transform <Shape > +Path +Fill +Stroke +Transform <Shape > +Path +Fill +Stroke +Transform TVG SceneTree <Scene> +transform +composition <Picture> +Transform +Bitmap +Scene <Scene> +transform +composition Transform Lottie Builder
  25. Compositor ShapeLayer SolidLayer CompLayer ShapeLayer … TVG Lottie Model RootLayer

    NullLayer Group Transform Shape Stroke Fill <Shape> +Path +Fill +Stroke +Transform <Shape > +Path +Fill +Stroke +Transform <Shape > +Path +Fill +Stroke +Transform TVG SceneTree <Scene> +transform +composition <Picture> +Transform +Bitmap +Scene <Scene> +transform +composition Transform Lottie Builder
  26. Compositor ShapeLayer SolidLayer CompLayer ShapeLayer … TVG Lottie Model RootLayer

    NullLayer Group Transform Shape Stroke Fill Transform Lottie Builder
  27. 1. Lottie Data Model 2. Loader, Parser and Compositor 3.

    Builder : How ThorVG renders Wrap Up
  28. <<interface>> Load Module <<interface>> RenderMethod API C++ TVG PNG JPG

    SVG Lottie Native Apps API JS/WASM Web Apps (frontend) sample.lottie (json) JSON Parser Lottie Scene Composer Lottie Interpreter I/O Picture Shape Scene Canvas Call APIs to compose TVG Scene TVG SceneTree Request Frame SwCanvas GlCanvas Task Scheduler <<shareable>> Path / Stroke / Fill Scene Shape Scene Shape Shape Compositor CompLayer ShapeLayer SolidLayer CompLayer ShapeLayer … Scene Shape Scene Shape Shape TVG SceneTree (Retainable) Call Call Text Lottie Loader ThorVG Single Binary [so/dll/wasm] Canvas Engine Extra Format Loaders Paint SW GL (beta) WG (beta) TTF Out WGCanvas
  29. Q&A