Commit graph

2701 commits

Author SHA1 Message Date
Hermet Park
f84b2331da lottie: support default slot overriding
issue: https://github.com/thorvg/thorvg/issues/2915
2024-11-09 17:28:52 +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
RuiwenTang
0bb419c0b0 gl_engine: Support new radial gradient data struct and calculation
Change the shader and uniform struct to support new radial gradient.
The mathematical calculation comes from https://skia.org/docs/dev/design/conical/
2024-11-08 19:15:48 +09:00
Sergii Liebodkin
627f358f49 wg_engine: support gradient focal point
Implemented gradien focal points
Issue https://github.com/thorvg/thorvg/issues/2728
Issue https://github.com/thorvg/thorvg/issues/2936
2024-11-08 18:47:38 +09:00
RuiwenTang
95d99ee74b gl_engine: Fix memory leak in the IndexBuffer object
The CPU buffer cache in the IndexBuffer object needs to be cleared, otherwise it will cause memory leaks and reduce performance per frame
2024-11-08 18:38:15 +09:00
Hermet Park
4aaa0dafc4 common: code refactoring
replaced internal string usage with char*
2024-11-08 15:26:04 +09:00
Hermet Park
9b9a0308c8 sw_engine: hotfix range broken
hotfix for release. need to review the logic again
2024-11-08 00:47:46 +09:00
Hermet Park
2b32c24712 lottie: corrected drop-shadow handling
opacity value type should be float with range 0 ~ 256
2024-11-08 00:47:46 +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
50a7f3957b capi: support gl, webgpu canvas APIs
New APIs:
 - Tvg_Canvas* tvg_glcanvas_create(void)
 - Tvg_Result tvg_glcanvas_set_target(Tvg_Canvas* canvas, int32_t id, uint32_t w, uint32_t h)
 - Tvg_Canvas* tvg_wgcanvas_create(void)
 - Tvg_Result tvg_wgcanvas_set_target(Tvg_Canvas* canvas, void* instance, void* surface, uint32_t w, uint32_t h, void* device)

issue: https://github.com/thorvg/thorvg/issues/2855
2024-11-06 17:17:12 +09:00
Hermet Park
f68d053ddb capi: clean up code 2024-11-06 17:17:12 +09:00
Sergii Liebodkin
52356b023d wg_engine: fix scene blending
In a case of scenes without masking white clear color used, instead of black color

Issue https://github.com/thorvg/thorvg/issues/2592
Issue https://github.com/thorvg/thorvg/issues/2921
2024-11-06 01:11:15 +09:00
Hermet Park
2ad6753680 lottie: support drop shadow effect
issue: https://github.com/thorvg/thorvg/issues/2153
issue: https://github.com/thorvg/thorvg/issues/2718
2024-11-06 00:56:11 +09:00
Hermet Park
e0365142a7 renderer: support SceneEffect DropShadow
Apply a drop shadow effect with a Gaussian Blur filter.

API Addition:
 - enum class SceneEffect::DropShadow

Parameters:
 - color_R(int)[0 - 255]
 - color_G(int)[0 - 255]
 - color_B(int)[0 - 255]
 - opacity(int)[0 - 255]
 - angle(float)[0 - 360]
 - distance(float)
 - blur_sigma(float)[> 0]
 - quality(int)[0 - 100]

issue: https://github.com/thorvg/thorvg/issues/2718
2024-11-06 00:56:11 +09:00
Sergii Liebodkin
93ebd388c7 wg_engine: implement dash offset
Introduced dash offset param for stroke dashes
Issue https://github.com/thorvg/thorvg/issues/2592
2024-11-05 12:05:49 +09:00
Sergii Liebodkin
505ebe9fe6 wg_engine: fix close command logic
On a close path command creates a new object started form the closed point
issue: https://github.com/thorvg/thorvg/pull/2923
2024-11-05 11:55:38 +09:00
Hermet Park
85b83563d6 lottie: clean up code 2024-11-04 13:09:16 +09:00
Hermet Park
87761dc7c7 lottie/slot: revise gradient fill support
Revise gradient fill data parsing by adding support
for the color stop count (p) parameter in slot data.

issue: https://github.com/thorvg/thorvg/issues/2795
2024-11-04 11:43:36 +09:00
Hermet Park
c75ec0f333 lottie: code clean up 2024-11-01 22:44:39 +09:00
Jinny You
4f2e725da0 lottie/text: Support text alignment options
Introduced new properties:
- group alignment
- text grouping (words, line)

Issue: #2178
2024-11-01 22:11:45 +09:00
Hermet Park
f1cd65a876 lottie: corrected a shallow keyframe data copy bug
The previous assignment operator was missed due to a template error,
which has now been corrected.

issue: https://github.com/thorvg/thorvg/issues/2797
2024-11-01 12:40:38 +09:00
Mira Grudzinska
0a43beb89b sw_engine: fix render fill region
Shape's bbox represents only fill's render region.
Render region of fill and stroke is stored in SwTask.
This was visible while rendering shapes with a stroke -
fill was to big.

@Issue: https://github.com/thorvg/thorvg/issues/2908

Co-Authored-By: Hermet Park <hermet@lottiefiles.com>
2024-10-31 23:08:27 +09:00
Sergii Liebodkin
8b27efc99f wg_engine: fix cubic splines and circles tesselation quality
Tesseletion factor now depends on scale matix of the shape
2024-10-31 20:24:35 +07:00
Sergii Liebodkin
f13c72e3d7 wg_engine: fix equals gradient offsets
In case if gradient offsets are equal the last color are used instead of first
2024-10-31 19:05:56 +07:00
Mira Grudzinska
144fecc3a1 lottie: fix text range selector translation
Scaling the entire scene caused unintended scaling
of the translation in the text range selector.
2024-10-30 11:37:43 +09:00
Mira Grudzinska
d9be58d4b7 lottie: fix transformations in text range selector
Since the translate API was used while text updating,
the subsequent range selector transformations gets overwritten
when updating the shape (scale and rotate, adding another
translation will persist). This caused unexpected results.
Fixed by using the transform API when additional transformations
are needed - also fixes applying more than one range selector.
2024-10-29 11:23:22 +09:00
Sergii Liebodkin
1d78835609 wg_engine: fix artifacts with zero length segmants on path
Fixed cases, if path have equals neighbors points on the path
2024-10-29 11:02:09 +09:00
RuiwenTang
a855666e41 gl_engine: seperate the index buffer from vertex buffer
WebGL has a strict rule that does not allow the same GLBuffer
to be bound to both ARRAY_BUFFER and ELEMENT_ARRAY_BUFFER at the same time.
(https://registry.khronos.org/webgl/specs/latest/1.0/#5.14.5)

To support WebGL in the future, a separate GLBuffer is used to store index data.
2024-10-29 00:00:19 +09:00
Sergii Liebodkin
975ddb68ca wg_engine: fixed image and scene normal blend
Pre-multiplied color on alpha chanel applied
2024-10-28 23:35:37 +09:00
Sergii Liebodkin
c57e2e6c9f wg_engine: multisampling support
Used native hardware MSAA x4

Full multisampling support including custom blend and compositions.
Must be verified on web and 4K resolution for performance issues
2024-10-25 00:14:04 +09:00
Hermet Park
bace4e3e9e renderer: --shadow variable compiler warning 2024-10-24 21:33:47 +09:00
Sergii Liebodkin
0815366763 wg_engine: clippath optimization
Full review of clipping workflow.

Before we are used separate render target for each clip path and compute shader to find clip path intersections with AND logic.
Now we are using depth buffer and transactions from depth to stencil and back to get AND logic intersections,
Compute shaders, layouts and pipelines was removed
2024-10-24 17:49:17 +09:00
Mira Grudzinska
a1296960eb svg: prevent runtime error
runtime error: applying non-zero offset 1 to null pointer
Observed for Bespoke-leather-belt-2016012857.svg
2024-10-24 13:56:47 +07:00
Hermet Park
798968e83a svg: clean up code 2024-10-24 00:37:49 +09:00
Mira Grudzinska
422674b4c9 api: add focal parameters to the radial apis
API modification:
- Result RadialGradient::radial(float cx, float cy, float radius)
- Result RadialGradient::radial(float cx, float cy, float r, float fx, float fy, float fr)
- Result RadialGradient::radial(float* cx, float* cy, float* radius)
- Result RadialGradient::radial(float* cx, float* cy, float* r, float* fx = nullptr, float* fy = nullptr, float* fr = nullptr)

@Issue: https://github.com/thorvg/thorvg/issues/2860
2024-10-23 11:10:14 +09:00
Sergii Liebodkin
b851d98805 wg_engine: use tvg math constants
Use tvg pi constant instead of cmath. better mingw compiler support on windows
2024-10-22 16:26:55 +03:00
Hermet Park
2d47585c98 renderer: hotfix a broken svg file sharing
Do not allow data sharing among same svg instances.
This should be addressed properly.
2024-10-22 14:27:04 +09:00
Hermet Park
41c1171197 sw_engine: corrected the blur feathering region.
issue: https://github.com/thorvg/thorvg/issues/2892
2024-10-22 13:49:14 +09:00
Hermet Park
c14382f3e3 svg: wrapping a paint with a scene
Apply scene when a clipper or masking was required.

This is a prerequisite task for migrating
the clip()/mask() features from Paint to Scene.
2024-10-22 13:48:13 +09:00
Hermet Park
765f927dd0 gl_engine: code clean up
ensure consistency in coding style.
2024-10-20 13:04:24 +09:00
Hermet Park
c4c262fb16 png, gl_engine: fixed an wrong png colorspace.
issue: https://github.com/thorvg/thorvg/pull/2880
2024-10-20 13:04:24 +09:00
Hermet Park
7c06fdd7b1 sw_engine: fixed linear gradient filling masking.
properly filtering alpha channel of the 8bits linear gradient
masking drawing.

issue: https://github.com/thorvg/thorvg/issues/2204
2024-10-19 20:40:07 +09:00
RuiwenTang
c3772d11af gl_engine: ignore masking alpha when calculate inv luma masking 2024-10-19 14:04:43 +09:00
Mira Grudzinska
dfd7693158 lottie: offset does not depend on shape direction
According to tests in AE, the offset direction should
not depend on the direction of the shape. A positive
offset value expands the shape, while a negative value
contracts it. Fixed.
2024-10-18 18:02:35 +09:00
Hermet Park
b4304b6d1f gl_engine: code refactoring
- clean up code
- resolve some data casting compiler warnings
2024-10-18 13:40:34 +09:00
Mira Grudzinska
9109656800 sw_engine: fix _rasterDirectImage
Since the source buffer is 32 bits, not 8 bits,
both alpha and inverse alpha need to be calculated.
2024-10-18 12:15:02 +09:00
Mira Grudzinska
d9bbd433e8 lottie: correct the array reserved size
The color input will contain at least colorStops.count * 4
elements (not including alpha). Since the alpha offset values
don't have to much colorStops, estimation is used.
2024-10-18 12:10:11 +09:00
Mira Grudzinska
78285e1cfd lottie: fix offset
For long Bezier curves compared to the offset value,
the offsetting algorithm caused deformation. The problem
became evident after adding mask extension, as the simple
shapes defined there are based on Bezier curves rather
than as shapes like a circle/rect/etc, which is the case
for the offset. Now fixed.
2024-10-18 12:09:45 +09:00
Hermet Park
b2622193b2 gl_engine: initialize members properly.
corrected a regression of uninitialized data value access.
2024-10-18 01:06:36 +09:00
Hermet Park
1e9609c6f7 wg_engine: merged math functions with common
issue: https://github.com/thorvg/thorvg/issues/2313
2024-10-17 21:08:00 +09:00