Commit graph

2459 commits

Author SHA1 Message Date
Hermet Park
4ebbd0aefc examples: ++safety.
Guarantee the resource free at the termination.
2024-01-02 20:34:12 +09:00
Hermet Park
ab744fc164 svg: ensure that all allocated memory.
observed a memory leak at a corner case.
2024-01-02 20:34:12 +09:00
Hermet Park
38c625d070 renderer: enhanced shared surface handling with mutex implementation
Introduced a dedicated mutex for each surface instance
to ensure safe sharing between the loader, renderer, and engine.

This enhancement allows for secure modification and access to bitmap data,
addressing potential concurrency issues.

Multiple Picture instances can now safely share a single loader instance,
optimizing performance.

This change builds upon the previous Loader Cache improvements:
ff6ea4b6c4
2024-01-02 20:34:12 +09:00
Hermet Park
102414d56f lottie: resolve a thread sanitizer report.
Issue: https://github.com/thorvg/thorvg/issues/1874
2024-01-02 20:34:12 +09:00
Hermet Park
15d1def0ec renderer/loader: improve thread safety
activeLoaders can be accessed by loaders within the worker thread.

the issue came up with the Loader cache feature:
ff6ea4b6c4

Issue: https://github.com/thorvg/thorvg/issues/1874
2024-01-02 20:34:12 +09:00
Hermet Park
4d344c888e sw_engine: resolve a thread sanitizer report.
Synchronize before accessing the shared bbox.

Issue: https://github.com/thorvg/thorvg/issues/1874
2024-01-02 20:34:12 +09:00
Hermet Park
65ff0ba1b1 renderer/taskscheduler: Resolve a thread sanitizer report.
Since each thread worker accesses the 'threads.count' variable,
delay the thread starting until initialization is completed.
2024-01-02 20:34:12 +09:00
Hermet Park
60282f51f8 renderer/loader: code refactoring.
Removed internal unique_ptr usage for a more compact size.
2024-01-02 20:34:12 +09:00
Hermet Park
4997f55e6c Revert "svg: removed an unnecessary nested scene."
A regression bug is occured.
clipper is also required to be transformed with loader->resize()...

This reverts commit e62a8668e7.
2024-01-02 20:34:12 +09:00
Hermet Park
884a505d6a text/ttf: fixed all memory violations. 2024-01-02 20:34:12 +09:00
Hermet Park
56d4628ee1 svg: removed an unnecessary nested scene. 2024-01-02 20:34:12 +09:00
Jinny You
92288c8291 updated copyright date (#1866) 2024-01-02 20:34:12 +09:00
Hermet Park
2ae8613a25 gl_engine: fix a compiler warning.
../src/renderer/gl_engine/tvgGlRenderer.cpp:450:24: warning: comparison of integer expressions of different signedness: ‘int’ and ‘uint32_t’ {aka ‘unsigned int’} [-Wsign-compare]
  450 |     for (auto i = 0; i < mComposePool.count; i++) {
      |
2024-01-02 20:34:12 +09:00
Hermet Park
9ef2288ae7 api: promote to official APIs.
New API:
- SwCanvas::Colorspace::ABGR8888S
- SwCanvas::ColorSpace::ARGB8888S
2024-01-02 20:34:11 +09:00
Hermet Park
0553729818 doc: remove unnecessary doxy guide. 2024-01-02 20:34:11 +09:00
Hermet Park
04e9e82dbf Update README.md 2024-01-02 20:34:11 +09:00
RuiwenTang
2db45c7ba0 gl_engine: fix svg gradient position not correct
* change the color and stop size to 16 in shader and buffer block
* calculate transform when upload gradient info to gpu pipeline
2024-01-02 20:34:11 +09:00
Hermet Park
43b85e4dae Update README.md 2024-01-02 20:34:11 +09:00
Hermet Park
5a31531db1 Update README.md 2024-01-02 20:34:11 +09:00
Hermet Park
0764de76fd doc: updated the guide. 2024-01-02 20:34:11 +09:00
Hermet Park
dab0380398 examples/text: Added Text example. 2024-01-02 20:34:11 +09:00
Hermet Park
54528b6ac9 renderer: introduce a ThorVG Text interface.
Introduced New APIs under the experimental tags.

- Result Text::font(const char* name, float size, const char* style = nullptr);
- Result Text::text(const char* text);
- Result Text::fill(uint8_t r, uint8_t g, uint8_t b);
- static Result Text::load(const std::string& path);
- static Result Text::unload(const std::string& path);
- static Text::std::unique_ptr<Text> gen();
- static Text::uint32_t identifier()

@Issue: https://github.com/thorvg/thorvg/issues/969
2024-01-02 20:34:11 +09:00
Hermet Park
e53ee5881f renderer/loader: support ttf loader.
Applied 2 more internal LoaderMgr interfaces for
gobally manage the font data resources.

The next function is introduced for lookup the existing loader
with the font name (key)
- static LoaderMgr::LoadModule* loader(const char* key);

The next function is introduced to free the existing loader
with the loader source(file path)
- static bool retrieve(const string& path);

Additionally implements the base loader to bind the ttf loader.
2024-01-02 20:34:11 +09:00
Hermet Park
03c53d3227 loader/ttf: introduce a new sfnt(scalable font) loader.
ttf is an industry standard format that is the most widely used
in the products. Now thorvg supports the basic features of
the font to supplement the text drawing.

The implementation is followed the ttf spec,
the covered features are:

- horizontal layouting with kerning.
- utf8 -> utf32 converted glyph drawing.

To use the feature, please enable ttf loader:
$meson -Dloaders="ttf_beta, ..."

@Issue: https://github.com/thorvg/thorvg/issues/969
2024-01-02 20:34:11 +09:00
Hermet Park
49d26691e5 common: Revise internal loader interfaces.
We are introducing the FontLoader, which slightly differs
from the ImageLoader in terms of features. To adequately
support both, we have separated the loader functionalities
into FontLoader and ImageLoader. This allows us to optimally
adapt the LoadModule for each case.
2024-01-02 20:34:11 +09:00
Hermet Park
6ef979f2a0 sw_engine/fill: fix a linear filling scaling issue.
The condition is not valid,
Let it draw the fill as it's requested.

Issue: https://github.com/thorvg/thorvg/issues/1834
2024-01-02 20:34:11 +09:00
Hermet Park
700af87a77 Update README.md 2024-01-02 20:34:11 +09:00
Sergii Liebodkin
5ba19a8a7f wg_engine: shape bbox based rendering (optimization)
Before the current changes, all surfaces were painted using a full-screen overlay, no matter how large the object was rendered. This approach is redundant and required reorganization. At the moment, all objects are rendered using an overlay equal to the box of the object itself, which reduces the cost of filling the surface.
Also surfaces and images were divided into different entities, which reduces the pressure on memory.
Also geometry data for rendering and geometry data for calculations in system memory were logically separated.
2024-01-02 20:34:11 +09:00
Sergii Liebodkin
4164b36c8a wg_engine: Added shape opacity value usage
[issues 1479: Opacity](#1479)

Usage example:

    // prepare a shape (Rectangle + Rectangle + Circle + Circle) with opacity
    auto shape1 = tvg::Shape::gen();
    shape1->appendRect(0, 0, 200, 200);                //x, y, w, h
    shape1->appendRect(100, 100, 300, 300, 100, 100);  //x, y, w, h, rx, ry
    shape1->appendCircle(400, 400, 100, 100);          //cx, cy, radiusW, radiusH
    shape1->appendCircle(400, 500, 170, 100);          //cx, cy, radiusW, radiusH
    shape1->fill(255, 255, 0);                         //r, g, b
    shape1->opacity(128)                               //opacity
    canvas->push(std::move(shape1));
2024-01-02 20:34:11 +09:00
Hermet Park
bcdf877339 loader/svg: optimize the path conversion.
Push the path data into a given shape directly.
This will skip unnecessary memory copies.

Issue: https://github.com/thorvg/thorvg/issues/1848
2024-01-02 20:34:11 +09:00
Hermet Park
a59950ea97 Welcome to our new official ThorVG developer. 2024-01-02 20:34:11 +09:00
Jinny You
501b2b060c web: Add a readme 2024-01-02 20:34:11 +09:00
Jinny You
b8d64c5ecd web: Add config to support npm module 2024-01-02 20:34:11 +09:00
Jinny You
e3f3a97f8d web: Add examples
- `index.html` : basic example
- `benchmark.html` : to check FPS, memory usage, latency(ms)
2024-01-02 20:34:11 +09:00
Jinny You
306a30185f web: Implement features
- define separated model for better readability of interface
- implemented thorvg basic features

added features:
- Add version info
- Support setBgColor
- Support save2gif
- Support bounce mode
- Support intermission
- Support skipping needless animation by dom visible
2024-01-02 20:34:11 +09:00
Jinny You
58f44100bc web: Add wasm loading logic 2024-01-02 20:34:11 +09:00
Jinny You
a88653194b web: Add library build script 2024-01-02 20:34:11 +09:00
Jinny You
8ce484c7df web: Add lit element
- introduce a `lit`(https://lit.dev)
- lit is most popular web component builder
- with lit, we can build high-performance WP with less code
2024-01-02 20:34:11 +09:00
Jinny You
fb63a9a937 web: Set up eslint 2024-01-02 20:34:11 +09:00
Jinny You
0d209b5440 web: Set up typescript 2024-01-02 20:34:11 +09:00
Jinny You
26a3a61a60 web: Add gitignore 2024-01-02 20:34:11 +09:00
Jinny You
c3d5cb1925 web: Add a package manifest info 2024-01-02 20:34:11 +09:00
Jinny You
7838c1d3d1 wasm: Update emscripten build config
enabled options:
- EXPORT_ES6 > to import glue code in es6 module system
- SINGLE_FILE > to build library as a single JS file, single file reduces loading latency
- MODULARIZE > proper option to build es6 module (optimized)
- EXPORTED_RUNTIME_METHODS > allow es6 module based glue code to import FS
2024-01-02 20:34:11 +09:00
Jinny You
87722991f7 wasm: Revise the wasm binding for lottie-player
- removed and replaced `tvgWasm`
2024-01-02 20:34:11 +09:00
Sergii Liebodkin
003464b7e5 wg_engine: refactor context handles
New approach provide:
- instance, adaptor, device and default queue
- device capabilitieas
- command buffer executor
- error handling
2024-01-02 20:34:11 +09:00
Sergii Liebodkin
e797cf63f4 wg_engine: refactor render targets handling
For further development of features, we need to create off-screen buffers that will allow us to implement functionality related to composition and blending, as well as for loading data to system memory from the framebuffer. Separating the framebuffer into a separate entity allows you to create several instances of them, switch between them, and blend them according to given rules.

For current time we have only a single render target instance, that have a handle to drawing into surface surface, like a native window.

New approach allows:
- offscreen rendering
- render pass handling
- switching between render targets
- ability to render images, strokes and shapes into independent render targets
2024-01-02 20:34:11 +09:00
RuiwenTang
d3169ea8fe gl_engine: fix wrong scissor value cause content not fully rendered 2024-01-02 20:34:11 +09:00
Hermet Park
2efdae710d renderer: minor optimization.
reduce the binary size.
2024-01-02 20:34:11 +09:00
RuiwenTang
c8833e970d gl_engine: optimize framebuffer creation and save some runtime memory
since the framebuffer will draw back to parent RenderPass, it can be
reused in next compose rendering.

So instead of create framebuffer every time when beginCompose is called, we
trying to reuse the framebuffer created before in the same stack level
2024-01-02 20:34:11 +09:00
Hermet Park
83e3cb24ff doc: polish up the doxygen.
- applied @retval for those const values.
- applied @return for return value description.
2024-01-02 20:34:11 +09:00