Commit graph

2097 commits

Author SHA1 Message Date
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
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
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
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
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
a6378fc673 wg_engine: apply tvg coding style. 2024-01-02 20:34:11 +09:00
Sergii Liebodkin
9742cfe293 wg_engine: pipelines and bind groups refactoring
- shader and system types synchronized
- pipelens and bind groups description separated
- pipelines description simplified
2024-01-02 20:34:11 +09:00
Hermet Park
f173b45e04 renderer/picture: fixed a regression
reverted a wrong change from the previous code refactoring
in 5643348472
2024-01-02 20:34:11 +09:00
Hermet Park
74a7c45214 common: clean up the code. 2024-01-02 20:34:11 +09:00
Vincent Torri
7e438a665c include missing headers for strcmp(), strdup() and realloc() 2024-01-02 20:34:10 +09:00
Hermet Park
bbf3cec2cc common/array: code refactoring.
Use a default constructor with reservation.
2024-01-02 20:34:10 +09:00
Hermet Park
79facf3656 renderer/scheduler: --binary size by 2.2kb
replace the stl with own lightweight data structures.
2024-01-02 20:34:10 +09:00
Hermet Park
6f19c581e8 infra: renamed the folders, images -> resources.
these folders might have more than images.
2024-01-02 20:34:10 +09:00
Hermet Park
f594806dd3 renderer/shape: Apply the magic number kappa to achieve rounded corners.
The magic number kappa (0.552284), which is associated with the bezier curve,
has been introduced. This formula is supposed to be applied to the rounded corners
of the rectangle to ensure consistent drawing results.

Issue: https://github.com/thorvg/thorvg/issues/1824
2024-01-02 20:34:10 +09:00
Hermet Park
c0a1f82033 renderer/loader: optimization++
removed the internal unique_ptr usage to reduce the binary size(-553)
2024-01-02 20:34:10 +09:00
Jinny You
118516f015 lottie/builder: fix crash by null reference 2024-01-02 20:34:10 +09:00
Jinny You
d173e62530 loader/jpg: Fix warning 2024-01-02 20:34:10 +09:00
Sergii Liebodkin
cb737f174c [Issues 1811: Compiller shadowing warning](https://github.com/thorvg/thorvg/issues/1811)
Godot CI compilation issue fixed
2024-01-02 20:34:10 +09:00
RuiwenTang
269537a411 gl_engine: support advance compose method 2024-01-02 20:34:10 +09:00
Hermet Park
221005bb25 lottie/builder: revert the clipper cache.
This ia a buggy,
We will revisit this optimization with a perfect solution.
2024-01-02 20:34:10 +09:00
Hermet Park
f64ee28079 Loaders: Introduced a loader cache.
The loader cache is applied to conserve memory.

If the input data is already present in loaders,
the loader cache will promptly return the active loader.

This results in a lot of memory savings for the duplicated resources.

binary diff: -400 bytes
2024-01-02 20:34:10 +09:00
Hermet Park
8cc8cf3b02 common: Move the list to the gl_engine side.
Unfortunately, the usage of this list is not intuitive,
so can be confusing. Placed it only for gl.
2024-01-02 20:34:10 +09:00
Hermet Park
815eb23856 lottie/builder: ++size optimization
Replaced std::queue with inlist for optimizing binary size (-1.3kb).
2024-01-02 20:34:10 +09:00
Hermet Park
49137b3851 common/inlist: added a inline list data structure.
Inline lists mean that their nodes' pointers are part of the same memory as the data.
This has the benefit of fragmenting memory less and avoiding node->data indirection.
2024-01-02 20:34:10 +09:00
Hermet Park
52a90d54ee lottie/builder: corrected polystar rotation.
There was likely a mistake in the rotation value set;
there was no reason to multiply it by 2.

Issue: https://github.com/thorvg/thorvg/issues/1773
2024-01-02 20:34:10 +09:00
Hermet Park
1fbdf7bbb6 renderer, loader: minor code refactoring.
- sync with its file name
- remove unnecessary section comments
- compact binary size (-300)
- private Task::run() methods from the loaders
2024-01-02 20:34:10 +09:00
Hermet Park
92d7727c2a Lottie/builder: revert a static cache optimization.
There are some matting masking bugs observed,
Reverted the commit. We will revisit it later.

commit d37c500262
Author: Hermet Park <hermet@lottiefiles.com>
Date:   Wed Oct 25 18:55:05 2023 +0900

    lottie: introduced static layer cache.

    lottie builder doesn't need to rebuild the layer object
    if it has no any animation frame data.

    That case, we can cache the layer scene in order to reuse it.

    Tested on local machine (single thread):
    - Lottie: appx. 2ms enhanced.
    - Binary: +204
2024-01-02 20:34:10 +09:00
Hermet Park
5c2be47e57 lottie/builder: hotfix, invalid stroking scaling.
There is a buggy workaround code that rewinds the stroke scaling.

Issue: https://github.com/thorvg/thorvg/issues/1730
2024-01-02 20:34:10 +09:00
Sergii Liebodkin
51e98eebdb Add support for textures color space formats
[Issues 1479: pictures](https://github.com/thorvg/thorvg/issues/1479)

Formats supported:
    ABGR8888
    ARGB8888
    ABGR8888S
    ARGB8888S
2024-01-02 20:34:10 +09:00
Hermet Park
ec1510ee08 gif/saver: fix a invalid memory access 2024-01-02 20:34:10 +09:00
Hermet Park
b8b8188879 sw_engine: fixed a bug where strokes were not showing.
Basic shapes were trimmed entirely when they were outside of the canvas,
even if they had a big enough stroke to be partially on the canvas.

This fixes the issue.

Issue: https://github.com/thorvg/thorvg/issues/1785
2024-01-02 20:34:10 +09:00
Sergii Liebodkin
802fb3efc6 examples: fixed manual loading of binary data (jpg, png, raw ect)
To load binary data operations must be performed in binary mode rather than text.
The issue appears on windows platform, especially for PNG loading
2024-01-02 20:34:10 +09:00
Hermet Park
0665837899 gif/encoder: fixed memory violation.
There was an invalid palette data access
when no frame data had been changed, detected by memory sanitizer.
2024-01-02 20:34:10 +09:00
Sergii Liebodkin
c5b642e3e7 wg_engine: introduced images drawing support
[issues 1479: pictures](https://github.com/thorvg/thorvg/issues/1479)

    auto picture = tvg::Picture::gen();
    picture->load("images/test.png");
    picture->translate(0, 0);
    picture->size(100, 100);
    picture->opacity(255);
    canvas->push(std::move(picture));
2023-12-26 18:36:45 +09:00