Commit graph

624 commits

Author SHA1 Message Date
Sergii
4da90b2847 picture: added ability to support premultiplied for picture raw loader
[issues 1479: picture raw loader to support premultiplied](https://github.com/thorvg/thorvg/issues/1764)

api changes:
    Result Picture::load(uint32_t* data, uint32_t w, uint32_t h, bool copy);
    Result Picture::load(uint32_t* data, uint32_t w, uint32_t h, bool premultiplied, bool copy);

capi changes
    TVG_API Tvg_Result tvg_picture_load_raw(Tvg_Paint* paint, uint32_t *data, uint32_t w, uint32_t h, bool copy);
    TVG_API Tvg_Result tvg_picture_load_raw(Tvg_Paint* paint, uint32_t *data, uint32_t w, uint32_t h, bool premultiplied, bool copy);
2023-11-08 10:46:23 +09:00
Hermet Park
ebe4672eff saver/gif: Fix a clipping issue.
The Lottie loader missed handling the base clipper resizing.
This patch addresses the issue.
2023-11-06 17:47:14 +09:00
Hermet Park
a08b7f0c38 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-02 17:49:41 +09:00
Hermet Park
d3c60955fa tvg: revise the tvg binary format for 1.0 release
- The TVG binary format now consistently compresses the data.
- Removed redundant internal properties as part of this change.

Please note that this change will break compatibility with the TVG file format from version 1.0 onward.

Issue: https://github.com/thorvg/thorvg/issues/1372
2023-11-02 11:58:23 +09:00
Mira Grudzinska
25a1321243 common: stroke dash offset support with new apis.
This change just allows users to use the offset of the stroke dash.
Actually feature enhacement has been introduced by
478e45f9f3.

@APIs:
uint32_t Shape::strokeDash(const float** dashPattern) ->
uint32_t Shape::strokeDash(const float** dashPattern, float* offset = nullptr)

Result Shape::strokeDash(const float* dashPattern, uint32_t cnt) ->
Result Shape::strokeDash(const float* dashPattern, uint32_t cnt, float offset = 0.0f)

Tvg_Result tvg_shape_set_stroke_dash(Tvg_Paint* paint, const float* dashPattern, uint32_t cnt) ->
Tvg_Result tvg_shape_set_stroke_dash(Tvg_Paint* paint, const float* dashPattern, uint32_t cnt, float offset)

Tvg_Result tvg_shape_get_stroke_dash(const Tvg_Paint* paint, const float** dashPattern, uint32_t* cnt) ->
Tvg_Result tvg_shape_get_stroke_dash(const Tvg_Paint* paint, const float** dashPattern, uint32_t* cnt, float* offset)

@Issue: https://github.com/thorvg/thorvg/issues/1372
2023-10-30 11:47:51 +09:00
Hermet Park
f3a2d2a5a6 portability: addressed all compilation warnings from MSVC 2023-10-27 14:20:50 +09:00
Hermet Park
bb30db429e lottie: fixed all memory access violations. 2023-10-27 13:50:13 +09:00
Hermet Park
c77ef98fef lottie/builder: enable layer blending
Issue: https://github.com/thorvg/thorvg/issues/1737
2023-10-27 12:13:00 +09:00
Hermet Park
db55481e97 renamed stroke apis family.
float Shape::stroke(float width) -> float Shape::strokeWidth(float width)
Result Shape::stroke(uint8_t r, uint8_t g, uint8_t b, uint8_t a = 255) -> Result Shape::strokeFill(uint8_t r, uint8_t g, uint8_t b, uint8_t a = 255)
Result Shape::stroke(std::unique_ptr<Fill> f) -> Result Shape::strokeFill(std::unique_ptr<Fill> f)
Result Shape::stroke(const float* dashPattern, uint32_t cnt, float offset = 0.0f) ->  Result Shape::strokeDash(const float* dashPattern, uint32_t cnt, float offset = 0.0f)
Result Shape::stroke(StrokeCap cap) -> Result Shape::strokeCap(StrokeCap cap)
Result Shape::stroke(StrokeJoin join) -> Result Shape::strokeJoin(StrokeJoin join)
Result Shape::strokeColor(uint8_t* r, uint8_t* g, uint8_t* b, uint8_t* a = nullptr) const -> Result Shape::strokeFill(uint8_t* r, uint8_t* g, uint8_t* b, uint8_t* a = nullptr) const

@Issue: https://github.com/thorvg/thorvg/issues/1372
2023-10-27 11:46:51 +09:00
Hermet Park
5a3bc31373 lottie: ++optimization with a caching effect.
reuse clippers if they are available.

Binary: +132
2023-10-26 15:24:36 +09:00
Hermet Park
d37c500262 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-26 15:24:36 +09:00
Hermet Park
21fbdfc904 lottie: clean up code
no logical changes, only code clean-up
2023-10-26 11:22:45 +09:00
Hermet Park
e570064eba 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-24 11:49:57 +09:00
Hermet Park
a6d7a19047 api: enhance the API usage.
Allow users to omit the default type casting for added convenience.
2023-10-18 14:35:57 +09:00
Hermet Park
3123e184c8 lottie: Fixed trimpath to support simultaneous trimpath
The previous version omitted support for simultaneous trimpath,
but it is now working as intended.
2023-10-17 21:13:38 +09:00
Hermet Park
625c2405fc lottie/builder: Fix overlapped stroking outlines.
Previously, the builder accumulated the outlines and fills
in one paint to reduce the rendering context.

However, this approach won't work for Lottie
if the resource contains multiple strokes with branched groups.

We should apply the optimization
only when the specified condition is satisfied.
2023-10-17 21:13:38 +09:00
Martin Capitanio
e3a3acb6b0 loader/jpg: Fix a regression bug.
Fixes #1705
2023-10-15 11:01:09 +09:00
Hermet Park
3a2de2bc6a lottie/builder: fix a regression bug.
currently thorvg doesn't support full 3d transformation.
orthogonal projection is mandatory.

Issue: https://github.com/thorvg/thorvg/issues/1698
2023-10-13 14:26:59 +09:00
Martin Capitanio
133662c8e9 loader/svg: Fix maskContentUnits userSpaceOnUse/objectBoundingBox
Fixes #1694
2023-10-12 15:05:40 +09:00
Hermet Park
eba7f2f0d7 lottie/builder: revise the render context for saving memory.
Allocate repeater context only when it's valid.
2023-10-09 11:00:33 +09:00
Hermet Park
57038df21f Lottie: Fixed handling of multiple strokes in one layer.
Revised the rendering logic of Lottie by creating a new rendering context
using a queue when multiple strokes are requested.

Issue: https://github.com/thorvg/thorvg/issues/1642
2023-10-09 11:00:33 +09:00
Hermet Park
7ec969be29 lottie/builder: Fix incorrect stroke width scaling propagation.
The transform (scale) should be applied to the following drawing elements,
not the previous stroke.
2023-09-26 14:24:52 +09:00
Hermet Park
74b67919e0 tvg: support radial gradient focal properties
properly store/restore the radial gradient focal properties
from the tvg loader and saver
2023-09-26 13:05:27 +09:00
Hermet Park
ed23b432bb tvg: support dash offset property
properly store/restore the dash offset property
from the tvg loader and saver

Issue: https://github.com/thorvg/thorvg/issues/1617
2023-09-26 13:05:27 +09:00
Hermet Park
fdd90605c7 lottie/builder: fix a memory leak.
fixed a memory leak in an exceptional case.
2023-09-26 10:48:33 +09:00
Hermet Park
1819fed033 renderer/paint: fixed a mismatched reference count.
This correction ensures a consistent use of 'ref' and 'unref' for paints to release memory properly.
The memory leak occurred when a picture was not pushed to a valid canvas.

This issue was reported by the unit-test memory sanitizer.
2023-09-26 10:48:33 +09:00
Hermet Park
dc9e14a20f lottie/model: revise the color stop population logic.
The omitted data must be generated with interpolation.
This change supplements that logic.
2023-09-25 11:04:20 +09:00
Hermet Park
3b611e0da9 lottie: fixed data conversion complie warnings 2023-09-22 12:35:13 +09:00
Hermet Park
ec5a32bb73 lottie: enhanced the colorstop feature.
Lottie ColorStop RGB / Alpha can be dealt with individually.
Since thorvg handles this one unified set,
lottie model need to merge the data into one structure.
2023-09-21 22:11:31 +09:00
Hermet Park
e2b7bfc198 lottie model: corrected stroke default value according to the lottie-spec. 2023-09-21 22:11:31 +09:00
Hermet Park
cba2b0f724 lottie/builder: correct a parenting error.
There is a missing case where a layer didn't parent properly,
especially when the parent is the matte target.
2023-09-21 22:11:31 +09:00
Hermet Park
5b8c66f5c8 lottie/builder: fix an invalid matting result.
Previously, it ignored the matte when it was out of frames for the sake of optimization.
However, this led to an incorrect matting result.

It should make the scene invisible when the matting is invisible.
2023-09-21 22:11:31 +09:00
Hermet Park
99609c7968 lottie: fixed an incorrect view clipping problem.
this missing initialization occured an incorrect view clipping.
2023-09-19 21:55:25 +09:00
Hermet Park
2cada9c446 loader/lottie: code refactoring.
migrate transform from the group to the layer.
transformation is not necessary in group but layer.

This helps to reduce the unnecessary assigning of the transformation
in group instances.
2023-09-19 14:03:13 +09:00
Hermet Park
549f4b1308 loader/lottie: properly handle graident opacity attributes.
That property has been missed in the implementation.
2023-09-19 10:33:22 +09:00
Hermet Park
8aa12ca468 taskschduler: fix a regression deadlock issue
This fix introduces a workaround to enforce synchronous tasking on worker threads.
Sometimes, out of threads get stuck in a deadlock condition.

@Issue: https://github.com/thorvg/thorvg/issues/1636
2023-09-18 21:06:01 +09:00
Hermet Park
81599a14a0 loader/lottie: code refactoring
moved clipping logic to the coherent precomp method.
2023-09-18 10:41:00 +09:00
Hermet Park
42d7a5faed loader/lottie: correct the frame range.
Fixed some incorrect time-remapping logic,
Also, the last frame should not be taken into account for the drawing.
2023-09-18 10:41:00 +09:00
Hermet Park
87dee3c1f7 loader/lottie: fix a memory leak
A dangling scene instance should be deleted properly.
2023-09-18 10:41:00 +09:00
Hermet Park
00ab8c254d loader/lottie: fix a missing opacity propagation.
the propagated opacity size should be accumulated.
2023-09-14 21:14:33 +09:00
Hermet Park
e4330f7089 loader/lottie: implemented missing hold interpolation.
path/colorstop has been missed to implement that feature.
2023-09-14 01:04:37 +09:00
Hermet Park
1bcbac71ab loader/lottie: fix a invalid matte source access.
parser ignored a matte source has no target.
this fixes the corner case.
2023-09-13 13:16:13 +09:00
Hermet Park
6b3bd8b27a loader/lottie: fix a precomposition+matting.
the matting target with a precomp lost the referencing in
the building the structure. this fixes it.
2023-09-13 10:11:24 +09:00
Hermet Park
2998eb18fc loader/lottie: fix an invalid memory access crash. 2023-09-12 20:56:38 +09:00
Hermet Park
3752ad93b3 loader/lottie: do not draw zero size content
skip rendering by setting opacity zero, if the scale factor is zero.
2023-09-12 20:55:16 +09:00
Hermet Park
f3c8d10b90 loader/lottie: fix a dash gap size.
fix a bug that was introduced by a mistake.
2023-09-08 15:01:28 +09:00
Hermet Park
e14e108d4a loader/lotte: ++clean code 2023-09-08 15:01:28 +09:00
Hermet Park
516e8bf042 loader/lottie: minimum support for 3D transform
It lacks perspective projection information,
so it transforms 3D axes with orthogonal projection.
2023-09-07 17:59:52 +09:00
Hermet Park
b5fcc90e5d loader/lottie: fix a wrong precomp time remapping.
the remapped frame number should be applied to the only referenced
precomp layer.
2023-09-07 17:59:52 +09:00
Hermet Park
a49ac81543 loader/lottie: support the repeater property 2023-09-07 12:17:16 +09:00