Commit graph

2267 commits

Author SHA1 Message Date
Hermet Park
3dba4f12f8 bump up version v0.11.6 2023-12-15 10:43:38 +09:00
Vincent Torri
6ef8c9d78c include missing headers for strcmp(), strdup() and realloc() 2023-12-15 10:21:55 +09:00
Hermet Park
dea58a242b 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
2023-12-15 10:19:41 +09:00
Jinny You
9baa15ecdb lottie/builder: fix crash by null reference 2023-12-15 10:19:14 +09:00
Jinny You
8264860023 loader/jpg: Fix warning 2023-12-15 10:19:02 +09:00
Sergii Liebodkin
0517dd7441 [Issues 1811: Compiller shadowing warning](https://github.com/thorvg/thorvg/issues/1811)
Godot CI compilation issue fixed
2023-12-15 10:18:49 +09:00
Hermet Park
3a3e06b172 bump up version v0.11.5 2023-11-24 12:25:52 +09:00
Hermet Park
5780772ef7 lottie/builder: revert the clipper cache.
This ia a buggy,
We will revisit this optimization with a perfect solution.
2023-11-24 12:25:52 +09:00
Hermet Park
b5f3c303d3 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
2023-11-24 12:25:25 +09:00
Hermet Park
4f97a8dc19 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
2023-11-24 12:25:25 +09:00
Hermet Park
2e423e5c2a 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
2023-11-24 12:25:25 +09:00
Hermet Park
ed9f46a1fc 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
2023-11-24 12:25:25 +09:00
Sergii Liebodkin
36d8cd12e6 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
2023-11-24 12:25:25 +09:00
Hermet Park
7aa8f07946 lottie/parser: Fix the shapes parsing logic.
Currently, it assumes "ty":"gr" for the related shapes children,
which can be skipped since the children will be in the "it" scope.

Some Lottie data is missing the "ty":"gr" field,
and ThorVG couldn't display the content properly.
It can ignore it with the context understanding.
2023-11-24 12:25:25 +09:00
Hermet Park
1a4135f08f bump up version v0.11.4 2023-11-10 13:58:07 +09:00
Hermet Park
aa90a9a603 examples: show users the best practice usage. 2023-11-10 13:57:29 +09:00
Hermet Park
1adc41291a sw_engine: ++null safety 2023-11-10 12:19:01 +09:00
Hermet Park
f94ce21689 lottie/builder: Fix a broken animation
The animation couldn't be triggered on a single thread.
Regression bug introduced by 29b5bc372d
2023-11-10 12:18:55 +09:00
Hermet Park
4ad1e66ffe lottie/loader: Corrected an issue with the return value when loading fails.
Previously, Picture::load(const char* data, uint32_t size, const std::string& mimeType, bool copy = false)
would return 'Success' even when the data is invalid.

This issue only occurred when the number of threads is set to 0.
2023-11-10 12:18:47 +09:00
Hermet Park
8a5d14c6b5 gif: corrected the wrong aspect ratio scaling. 2023-11-06 20:18:52 +09:00
Hermet Park
99b57dc2b8 saver/gif: Fix a clipping issue.
The Lottie loader missed handling the base clipper resizing.
This patch addresses the issue.
2023-11-06 20:17:48 +09:00
Hermet Park
1b80e3e460 saver/gif: up to date the gif encoder.
this fixes the memory sanitizer report:

../src/savers/gif/gif.h:315:31: runtime error: index 255 out of bounds for type 'unsigned char [255]'
../src/savers/gif/gif.h:113:54: runtime error: index 255 out of bounds for type 'unsigned char [255]'

Issue: https://github.com/thorvg/thorvg/issues/1758
2023-11-06 20:17:42 +09:00
Hermet Park
4588fe1119 binding/wasm: remove layer functionality.
We will revisit this function later with a proper design.
2023-11-06 20:17:35 +09:00
Hermet Park
b4808103cf binding/wasm: updated save features
- removed the compression option
- added an animation save function.
2023-11-06 20:17:29 +09:00
Hermet Park
28d070aa1b binding/wasm: updated save features
- removed the compression option
- added an animation save function.
2023-11-06 20:17:22 +09:00
JunsuChoi
2da608eef2 saver GifSaver: Introduce GifSaver for animation
Add save() API that takes tvg::Animation as a parameter.
This API uses gif.h to create each animation frame as a gif frame.
Gif creation do not support threads because they must be added sequentially.
Please see example/GifSaver.cpp

ex)
auto animation = tvg::Animation::gen();
auto picture = animation->picture();
picture->load(EXAMPLE_DIR"/walker.json");
auto saver = tvg::Saver::gen();
saver->save(std::move(animation), EXAMPLE_DIR"/test.gif");
saver->sync();

New API:
Result Saver::save(std::unique_ptr<Animation> animation, const std::string& path, uint32_t quality = 100, uint32_t fps = 0);

Issue: https://github.com/thorvg/thorvg/issues/1712
2023-11-06 20:16:32 +09:00
RuiwenTang
5949a994c8 gl_engine: fix memory out of bounds error in GlGpuBuffer
If buffer data is larger than memory alignment, need to make sure there
is enough memory in current stage buffer
2023-11-03 17:04:41 +09:00
Hermet Park
bcb35ba33b renderer: maintain consistency in the logging domain. 2023-11-03 17:04:19 +09:00
Hermet Park
4070495032 loaders/png: fixed data conversion warnings on Windows
../src/loaders/external_png/tvgPngLoader.cpp(110): warning C4244: '=': conversion from 'float' to 'uint32_t', possible loss of data
../src/loaders/external_png/tvgPngLoader.cpp(111): warning C4244: '=': conversion from 'float' to 'uint32_t', possible loss of data
../src/loaders/external_png/tvgPngLoader.cpp(112): warning C4244: '=': conversion from 'float' to 'uint32_t', possible loss of data
2023-11-03 17:04:04 +09:00
Hermet Park
1beec19586 renderer: ++safety
these member values can be accesssed without update() call.
2023-11-03 17:03:46 +09:00
Hermet Park
914621ebde wasm: fix a regression bug.
The Animation::frame() method has been modified.
It will now return InsufficientCondition,
if the frame value is the same as the previous one.

In addition to this change, we have also updated its usage accordingly.
2023-11-03 17:03:36 +09:00
Hermet Park
26cf0f47cd bump up version v0.11.3 2023-10-27 14:21:34 +09:00
Hermet Park
28acef19a2 portability: addressed all compilation warnings from MSVC 2023-10-27 14:21:34 +09:00
Hermet Park
ae67a126e1 lottie: fixed all memory access violations. 2023-10-27 13:51:13 +09:00
Hermet Park
d60b5b1721 renderer/paint: added a blend update flag.
Keep track of the update changes accurately.
We can utilize this value change in the backend engine.
2023-10-27 12:28:47 +09:00
Hermet Park
9b9889b228 lottie/builder: enable layer blending
Issue: https://github.com/thorvg/thorvg/issues/1737
2023-10-27 12:28:40 +09:00
Hermet Park
4ad0b79eec renderer: revise the internal paints structure.
Get rid of the polymorphism function table,
use the switch directly instead.

We profiled, both binary & performance is better than before.

Tested on a local machine (single thread):
- Lottie: 2ms improved
- Binary: -0.5kb
2023-10-27 12:28:32 +09:00
Hermet Park
fe259d0414 lottie: ++optimization with a caching effect.
reuse clippers if they are available.

Binary: +132
2023-10-27 12:27:47 +09:00
Hermet Park
f223f2f6ac 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
2023-10-27 12:26:35 +09:00
Hermet Park
b001c0736c renderer/shape: enable returning count values only 2023-10-27 12:24:20 +09:00
Hermet Park
c71ae85953 lottie: clean up code
no logical changes, only code clean-up
2023-10-27 12:24:12 +09:00
Hermet Park
7b323e5749 canvas/paint: ++exception handling
enhanced reference count verification
to prevent unintentional deletion of used composition targets.
2023-10-27 12:24:01 +09:00
Hermet Park
dc02e131e9 animation/lottie: updated the frame count unit.
replace the frame count unit from the int32_t to float
since animations could smoothly interpolate key-frames.

This notificably improve the animation smoothness in Lottie

Beta API changes:
Result Animation::frame(uint32_t no) -> Result Animation::frame(float no)
uint32_t Animation::curFrame() const -> float Animation::curFrame() const
uint32_t Animation::totalFrame() const -> float Animation::totalFrame() const
2023-10-27 12:23:38 +09:00
Hermet Park
e17cc45ba8 examples/lottie: added more show cases 2023-10-27 12:22:35 +09:00
Hermet Park
63613992c4 sw_engine/raster: optimized the scaled image rasterization
Unified common logic for scaled image raster operations,
Avoid on-spot pixel computation as possible.

Tested on local machine (single thread)

Lottie: 0.057s -> 0.053s (-0.004s)
2023-10-27 12:17:58 +09:00
Hermet Park
35ddc5fe56 sw_engine/math: fine-tuning optimization
Try to minimize the use of sqrt() and arctan() calls
when possible. These calls can be relatively expensive
when accumulated within a single frame.

Also repalce the division with shift operation.
since split cubic function is one of the significant hot-spots
in the data processing, we could earn a noticable enhancement.

Tested on single thread local machine:

Lottie: 0.080 -> 0.052s (-0.028s)
Performance: 0.023 -> 0.022 (-0.001s)
Binary: +34
2023-10-27 12:17:30 +09:00
Hermet Park
7cccabad40 sw_engine/math: Enhance trigonometric functions.
Streamlining computations with floating-point operations in rotation
thereby improving 'thorvg' speed.

Also use the well-optimized posix math functions instead of
custom math.

Test on my local machine.

Lottie: -0.008s (0.073 -> 0.065)
Performance: -0.0013s (0.0154 -> 0.0141)
Binary: -323
2023-10-27 12:17:13 +09:00
Hermet Park
b01fe9bf44 bump up version v0.11.2 2023-10-20 13:32:13 +09:00
Hermet Park
5a57c76386 sw_engine raster: fixed a default alpha blending bug.
alpha value has been missed by a mistake,
a regression by c50d2fd

Issue: https://github.com/thorvg/thorvg/issues/1716
2023-10-20 13:31:33 +09:00
Hermet Park
3fb37dd42a lottie: Fixed trimpath to support simultaneous trimpath
The previous version omitted support for simultaneous trimpath,
but it is now working as intended.
2023-10-20 13:31:09 +09:00