Commit graph

40 commits

Author SHA1 Message Date
Sergii Liebodkin
37cffba620 wasm: fix thorvg wasm binding
Fixed initialization and termination of the engine in wasm binding
2025-04-24 22:28:37 +09:00
Sergii Liebodkin
e24c743ab3 wasm binding fixed for wg engine
fixed wrong logic in wg engine initialization process, where initializer return seccuss status in any case
2025-04-23 21:20:47 +09:00
Hermet Park
fa332dbc84 binding/wasm: code refactoring
removed a bunch of #ifdefs and consolidated
implementations across engines.
2025-03-28 23:02:58 +09:00
Jinny You
588bcf5264 wasm: fix build error when WebGPU is disabled (SW/GL only)
Fixed a build error that occurred when the WebGPU feature was disabled due to a missing feature check condition. The issue affected building with the software and OpenGL only backends.

issue: #3356
2025-03-27 17:48:20 +09:00
Jinny You
bf5cea982c common: Support .lot extension
Add support for the .lot extension to recognize Lottie animation files, as this introduces an additional extension for Lottie.

issue: #3248
2025-02-27 16:46:30 +09:00
Hermet Park
ce96024e99 wasm: refine the logic for clarity
1. return null canvas when engine is not avaiable.
2. remove the ifdef for unnecessary taret calls.
2025-02-27 16:40:45 +09:00
Jinny You
583fb6503c wasm: optimize default font size
Enable default font compression to reduce WASM size.

The LZSS algorithm is a simple compression method with advantages in decompression performance.

Font data is optimized without external compression dependencies, reducing the embedded font size to 9KB (-40%).
2025-02-27 16:30:27 +09:00
Jinny You
3737632e13 wasm: support default font initialization
Load default font data during initialization. This enables the web system to load when the system font cannot be used.

Added a binary-embeddable font file resource. This file has quite small size while containing essential glyphs.

- DM Sans: https://github.com/googlefonts/dm-fonts
2025-02-20 18:47:01 +09:00
Jinny You
42457a25c9 wasm: fix ambigious symbols 2025-02-20 15:46:20 +09:00
Jinny You
4aba0caaad wasm: fix build issue in sw/wg build only case
- resolved EMSCRIPTEN_WEBGL_CONTEXT_HANDLE declaration problem.
- currentContext() should be also called after `mContext` is initialized.
2025-01-15 21:27:00 +09:00
Hermet Park
a12accbc93 updated copyright 2025-01-03 14:32:31 +09:00
Hermet Park
76203c3dbb gl_engine: ensure the gl context switching
This only covers emscripten environment,
need to cover other system.

issue: #3023

Co-Authored-By: Hermet Park <hermet@lottiefiles.com>
2024-12-31 12:07:52 +09:00
Jinny You
8237eea4e9 wasm: handle WebGPU initialization failure case 2024-12-13 14:53:55 +09:00
Jinny You
5d617c0821 wasm: remove ASYNCIFY to reduce binary size
The binary size recently increased due to the ASYNCIFY option, which was required for WebGPU initialization.

To prevent unnecessary binary size growth, ThorVG will no longer depend on asynchronous processes such as `emscripten_sleep` (ASYNCIFY or JSPI).

As a result, the combined WASM binary size has been significantly reduced to less than 1MB.

Size comparison: 1559KB → 998KB (-36%)
2024-12-13 14:53:55 +09:00
Jinny You
aaa5c05cd0 wasm: update canvas API usage from clear() to remove()
Following ThorVG API changes (#1372), updated the canvas handling:
- Replaced Canvas::clear() calls with Canvas::remove()
- Updated Canvas::draw() usage to handle buffer clearing
2024-12-11 14:19:53 +09:00
Jinny You
bb5ba81149 wasm: switch to Emscripten-specific WebGPU header
Use <emscripten/html5_webgpu.h> for browser-specific WebGPU support.
2024-12-04 19:00:18 +09:00
Jinny You
7e66bde4fb wasm: fix build error
Added missing parameter for `GlCanvas->target`
2024-11-27 16:48:26 +09:00
RuiwenTang
af5e0e3ef9 gl_engine: support cross compile GL backend into WASM
Support cross compile the GL backend code into WASM.
The code needs WebGL 2.0 API so, the compile flags contains `MAX_WEBGL_VERSION` and `FULL_ES3`
Also add binding code to initialize the WebGL context and GLCanvas.
2024-11-26 17:12:49 +09:00
Hermet Park
0f409a654a renderer: reserved colorspace option in target api
API Modification:
- Result WgCanvas::target(void* device, void* instance, void* target, uint32_t w, uint32_t h, int type = 0)
 -> Result WgCanvas::target(void* device, void* instance, void* target, uint32_t w, uint32_t h, ColorSpace cs, int type = 0)
- Tvg_Result tvg_wgcanvas_set_target(Tvg_Canvas* canvas, void* device, void* instance, void* target, uint32_t w, uint32_t h, int type)
 -> Tvg_Result tvg_wgcanvas_set_target(Tvg_Canvas* canvas, void* device, void* instance, void* target, uint32_t w, uint32_t h, Tvg_Colorspace cs, int type)
2024-11-26 12:04:30 +09:00
Sergii Liebodkin
3805f26aff wg_engine: multicanvas support
Added multicanas support
Issue https://github.com/thorvg/thorvg/issues/2745
2024-11-22 12:34:26 +09:00
Jinny You
a85470b5d5 wasm: Enhance gif saving without data copy
Removed data copy for gif saving.

Binding function `save` has changed:
- bool save(string data, string mimetype)
2024-11-18 14:55:14 +09:00
Hermet Park
ed01ef717e api: revise the spec
Remove the requirement for unique_ptr in the function prototypes.
This change will simplify the API usage, making it more streamlined
and user-friendly. However, memory management will now be the
responsibility of the user.

C++ API Modification:
- Result Paint::mask(std::unique_ptr<Paint> target, MaskMethod method) -> Result Paint::mask(Paint* target, MaskMethod method)
- Result Paint::clip(std::unique_ptr<Paint> clipper) -> Result Paint::clip(Paint* clipper)
- virtual Result Canvas::push(std::unique_ptr<Paint> paint) -> virtual Result Canvas::push(Paint* paint)
- std::unique_ptr<LinearGradient> LinearGradient::gen() -> LinearGradient* LinearGradient::gen()
- std::unique_ptr<RadialGradient> RadialGradient::gen() -> RadialGradient* RadialGradient::gen()
- Result Shape::strokeFill(std::unique_ptr<Fill> f) -> Result Shape::strokeFill(Fill* f)
- Result Shape::fill(std::unique_ptr<Fill> f) -> Result Shape::fill(Fill* f)
- std::unique_ptr<Shape> Shape::gen() -> Shape* Shape::gen()
- std::unique_ptr<Picture> Picture::gen() -> Result Picture::push(Paint* paint)
- std::unique_ptr<Scene> Scene::gen() -> Scene* Scene::gen()
- Result Text::fill(std::unique_ptr<Fill> f) -> Result Text::fill(Fill* f)
- std::unique_ptr<Text> Text::gen() -> Text* Text::gen()
- std::unique_ptr<SwCanvas> SwCanvas::gen() -> SwCanvas* SwCanvas::gen()
- std::unique_ptr<GlCanvas> GlCanvas::gen() -> GlCanvas* GlCanvas::gen()
- std::unique_ptr<Animation> Animation::gen() -> Animation* Animation::gen()
- Result Saver::background(std::unique_ptr<Paint> paint) -> Result Saver::background(Paint* paint)
- Result Saver::save(std::unique_ptr<Paint> paint, const char* filename, uint32_t quality = 100) -> Result Saver::save(Paint* paint, const char* filename, uint32_t quality = 100)
- std::unique_ptr<Saver> Saver::gen() -> Saver* Saver::gen()
- std::unique_ptr<Accessor> Accessor::gen() -> Accessor* Accessor::gen()

C++ API removal:
- template<typename T = tvg::Paint> std::unique_ptr<T> cast(Paint* paint)
- template<typename T = tvg::Paint> std::unique_ptr<T> cast(Paint* paint)

issue: https://github.com/thorvg/thorvg/issues
2024-11-09 12:29:15 +09:00
Hermet Park
9a134fcb90 api: revise the apis for v1.0
replaced std::string with char* in API parameters.

API Modification:
- Result Picture::load(const std::string& path) -> Result Picture::load(const char* filename)
- Result Picture::load(const char* data, uint32_t size, const std::string& mimeType, const std::string& rpath = "", bool copy = false) -> Result Picture::load(const char* data, uint32_t size, const char* mimeType, const char* rpath = "", bool copy = false)
- Result Text::load(const std::string& path) -> Result Text::load(const char* filename)
- Result Text::load(const char* name, const char* data, uint32_t size, const std::string& mimeType = "ttf", bool copy = false) -> Result Text::load(const char* name, const char* data, uint32_t size, const char* mimeType = "ttf", bool copy = false)
- Result Text::unload(const std::string& path) -> Result Text::unload(const char* filename)
- Result Saver::save(std::unique_ptr<Paint> paint, const std::string& path, uint32_t quality = 100) -> Result Saver::save(std::unique_ptr<Paint> paint, const char* filename, uint32_t quality = 100)
- Result Saver::save(std::unique_ptr<Animation> animation, const std::string& path, uint32_t quality = 100, uint32_t fps = 0) -> Result Saver::save(std::unique_ptr<Animation> animation, const char* filename, uint32_t quality = 100, uint32_t fps = 0)

issue: https://github.com/thorvg/thorvg/issues/1372
2024-11-06 21:32:45 +09:00
Hermet Park
0e45fabb3d spec out tvg binary format
issue: https://github.com/thorvg/thorvg/issues/2721
2024-10-12 21:07:31 +09:00
Hermet Park
9bc900206b api: polish the thorvg API usages.
API Modification:
- SwCanvas::Colorspace -> ColorSpace

API Addition:
- ColorSpace::Unknown

issue: https://github.com/thorvg/thorvg/issues/1372
2024-10-12 15:38:03 +09:00
Hermet Park
132213110c wasm: fix a build break 2024-10-01 17:11:28 +09:00
Jinny You
7ec697aa77 wasm: Handle WebGPU part for integration
Updated the WebGPU engine API to align with the latest interface.

Static/Single instance, adapter and device to support multiple canvases on the browser.

Moved the WGPU request part to `initWGInstance` helper function. This must only be called once even, when multiple players are involved.

Issue: #2695
2024-09-23 17:12:30 +09:00
Jinny You
747967638d wasm: fix typo 2024-08-27 17:33:56 +09:00
Jinny You
58db802ac1 wasm: code refactoring
Introduced the abstract EngineMethod to handle
different engines more effectively using polymorphism.

Co-authored-by: Jinny You <jinny@lottiefiles.com>
2024-08-21 17:17:50 +09:00
Jinny You
d704a2503a bindings/wasm: Support WebGPU
Updated WASM binding to bring WebGPU on the web player.

binding will generate a WASM binary, which can render animation through both SW and WG raster engine.

A raster engine will be chosen by parameter `engine`, when initializing.
2024-08-20 17:26:23 +09:00
Hermet Park
5ae556cf13 wasm: thorvg canvas resize problem.
The canvas syncs before changing a target buffer.

issue: https://github.com/thorvg/thorvg/issues/2580
2024-08-12 18:35:31 +09:00
Josh Soref
e061fa6628
common: fix 178+ spelling errors 2024-07-01 21:58:46 +09:00
Jinny You
6870953713 wasm: Support viewport API
wasm binding for viewport API in web.

see: #2276
2024-05-30 10:56:18 +09:00
Hermet Park
c9f05526a8 wasm: code clean up
binary reduction by -188
2024-05-21 16:05:53 +09:00
Hermet Park
d37ed535d1 wasm: update the gif conversion function
re-implement the gif conversion function with the correct approach.
The input data is not reusable as it undergoes modifications during parsing.

To address this, the function now creates a backup of the original data for use in GIF conversion.

This also resolves issues where the GIF viewport was incorrectly matched.

This implementation may be revisited upon
the availability of Animation::duplicate().
2024-04-05 01:10:39 +09:00
Hermet Park
059939f2ed wasm: optimize TVG saving Logic
Optimized the saving logic for TVG.

Copying the picture is unnecessary;
the logic now directly utilizes the currently held picture.
2024-04-05 01:10:39 +09:00
Jinny You
1c04cab904 wasm: Add canvas clear on update
Fixed bug that canvas draws wrong frame at alpha area
2024-01-04 17:14:42 +09:00
Jinny You
5f088a2357 wasm: Revise saver methods 2024-01-03 13:51:42 +09:00
Jinny You
2c6c8d3b21
updated copyright date (#1866) 2023-12-28 10:43:25 +09:00
Jinny You
99a841b404 wasm: Revise the wasm binding for lottie-player
- removed and replaced `tvgWasm`
2023-12-20 15:45:14 +09:00
Renamed from src/bindings/wasm/tvgWasm.cpp (Browse further)