Commit graph

3351 commits

Author SHA1 Message Date
Mira Grudzinska
00f6600499 svg_loader: fix clipping in use/symbol nodes
Clipping for the <use> node when a <symbol> was used,
was being overridden when 'overflowVisible' was 'true'
(the default value), which caused the 'clip-path' applied
to the <use> node to have no visible effect.
The clipping for the <use> node (without <symbol> node) was
transformed in an incorrect order, resulting in a visually
incorrect results.

@Issue: https://github.com/thorvg/thorvg/issues/3392
2025-05-24 01:37:24 +09:00
Hermet Park
ea6cfdf3da lottie/expressions: --memory leak 2025-05-24 01:37:24 +09:00
Hermet Park
e1beceba80 lottie: fixed a invalid memory access
looping doesn't make sense if the animation
doesn't have frames. use the current frame number.
2025-05-24 01:37:24 +09:00
Hermet Park
1b37743b2c renderer: fixed a clippging update isssue
ThorVG did not consider updates to the clipping path
when a paint object was modified after being added to the scene.

This fix ensures that any updates to clipping are correctly
reflected during rendering.

issue: https://github.com/thorvg/thorvg/issues/3403
2025-05-24 01:37:24 +09:00
Hermet Park
8b2024a8f4 lottie/expressions: hotfix
issue: https://github.com/thorvg/thorvg/issues/3400
2025-05-24 01:37:24 +09:00
Mira Grudzinska
852424e69d ttf: prevent crash while converting utf8 to unicode
If wrong utf8 sequence if given as an input, decoding
return nullptr and it has to be handled correctly.
2025-05-24 01:37:24 +09:00
Mira Grudzinska
ee8eebfef8 lottie: safety++
Prevents a crash when the font family in the text document
does not match any font in the provided font list.
2025-05-24 01:37:24 +09:00
Hermet Park
55c0849746 loaders: explicit variable scope to improve portability
issue: https://github.com/godotengine/godot/pull/105093
2025-05-24 01:37:24 +09:00
Hermet Park
126265feb9 lottie/expressions: tiny optimization
reuse the user callback data by the reference count.
2025-05-24 01:37:21 +09:00
Jinny You
08fa801461 lottie/text: added range selector flags
Duplicated text document properties (fill color, stroke color, and stroke width) to the text range.

If these properties are not defined in the range selector, ThorVG incorrectly overrides them with default values.

The correct behavior is to preserve the original values. The added flags address this issue.

Co-Authored-By: Hermet Park<hermet@lottiefiles.com>
2025-05-22 16:58:24 +02:00
Mira Grudzinska
91bd6f35b9 bump up version v0.15.12 2025-04-05 12:24:05 +09:00
Hermet Park
dd416e326d loaders: ++static loader thread safty
make it sync before deleting the loaders.
2025-04-03 22:31:07 +02:00
Hermet Park
96d4ab1590 lottie/expressions: support wiggle effect
usage: wiggle(freq, amp, octaves=1, amp_mult=.5, t=time)

issue: https://github.com/thorvg/thorvg/issues/1640
2025-04-03 22:28:04 +02:00
Hermet Park
558a9991de lottie: improve the compatiblity
merge the scene with more accurate condition to allow
the evenodd pathes among the lottie render tree.
2025-04-03 22:17:03 +02:00
Hermet Park
4e5ff3ea9a lottie: safety++
Don't apply matte — it's already been pushed into the scene.
This is a corner-case bug that occurs when the Lottie data
violates the specification.
2025-04-03 22:10:21 +02:00
Hermet Park
7d8bb168d2 ttf: ++thread safety
Properly allow the ttf loader sharable among threads.

issue: https://github.com/thorvg/thorvg/issues/3165
2025-04-03 21:31:52 +02:00
Hermet Park
ba00675559 renderer: safety++
introduced a threshold for the minimum dash size
to prevent excessive fragmentation.

issue: https://github.com/thorvg/thorvg/issues/3332
2025-04-03 21:17:54 +02:00
Hermet Park
aa697d9311 sw_engine: hotfix a out of bound image access.
this simply revert logic from the previous change:
https://github.com/thorvg/thorvg/pull/2552

issue: https://github.com/thorvg/thorvg/issues/3327
2025-04-03 21:13:46 +02:00
Hermet Park
6708fae17b common: ++loader thread safety
fortitfy the thread safety
in multi-threaded resource loading.

issue: https://github.com/thorvg/thorvg/issues/3306
2025-04-03 21:09:21 +02:00
Sergii Liebodkin
72a1b0339b gl_engine: luma visual differneces fix
https://github.com/thorvg/thorvg/issues/3045
2025-04-03 20:03:28 +02:00
Mira Grudzinska
7730b1d632 svg_loader: handle embedded fonts
It is possible to embed fonts directly into an SVG file.
Support for parsing and loading embedded fonts has been added.

@Issue: https://github.com/thorvg/thorvg/issues/1897
2025-04-03 18:56:45 +02:00
Jinny You
097d3814ea lottie/slot: fix image deep copy logic
When the datas are copied with deep copy, memory issue caused (SEGV on unknown address) due to these reasons:

1. `mimeType` is nullptr when it's not embedded(base64) data

2. datas(b64Data, mimeType) should not be clear, it's used for next slot copy in same pair.
2025-04-03 14:28:02 +02:00
Mira Grudzinska
61360cf6db bump up version v0.15.11 2025-03-12 21:02:51 +01:00
Mira Grudzinska
731f137d2d svg: fix incorrect assignment of <stop> elements
If the svg contained an unsupported element with <stop> elements,
they were incorrectly assigned to the last loaded gradient. Now fixed.

@Issue: https://github.com/thorvg/thorvg/issues/3321
2025-03-12 21:02:51 +01:00
Hermet Park
c554205238 sw_engine: fix a incorrect rle cell position.
All cells that are on the left of the clipping region
go to the - 1 horizontal position.

issue: https://github.com/thorvg/thorvg/issues/2657
2025-03-12 21:02:51 +01:00
Hermet Park
fe383d44e7 lottie: --compiler warnings
In member function ‘constexpr LottieGenericProperty<LottieScalarFrame<float>, float>& LottieGenericProperty<LottieScalarFrame<float>, float>::ope>    inlined from ‘LottieFloat& LottieStroke::dashValue()’ at ../src/loaders/lottie/tvgLottieModel.h:60:104,
    inlined from ‘void LottieParser::parseStrokeDash(LottieStroke*)’ at ../src/loaders/lottie/tvgLottieParser.cpp:623:82:
../src/loaders/lottie/tvgLottieProperty.h:297:8: warning: ‘<anonymous>.LottieGenericProperty<LottieScalarFrame<float>, float>::value’ may be used>  297 | struct LottieGenericProperty : LottieProperty
      |        ^~~~~~~~~~~~~~~~~~~~~
../src/loaders/lottie/tvgLottieModel.h: In member function ‘void LottieParser::parseStrokeDash(LottieStroke*)’:
../src/loaders/lottie/tvgLottieModel.h:60:104: note: ‘<anonymous>’ declared here
   60 |             for (uint8_t i = 0; i < dashattr->size; ++i) newValues[i] = LottieFloat(dashattr->values[i]);
      |
2025-03-12 21:02:44 +01:00
Jinny You
7c27ae021d lottie/slot: Support expressions overriding
issue: #3168

Co-Authored-By: Hermet Park <hermet@lottiefiles.com>
2025-03-12 20:26:39 +01:00
Jinny You
dec4b141ec lottie/slot: fix potential memory leak when overriding twice
Co-Authored-By: Hermet Park <hermet@lottiefiles.com>
2025-03-12 20:26:39 +01:00
Mira Grudzinska
c6960502eb sw_engine: hanndle empty clips
Generating the outline may return false, e.g., if the shape
is completely trimmed. If such a shape was used as a clip,
an attempt to generate 'rle' will still be made. In such a case,
a crash will occur because the outline is nullptr.
2025-03-12 20:26:39 +01:00
Mira Grudzinska
572e5ef9b1 ttf_loader: handling contours starting with OFF_CURVE
It might happen that the first point doesn't belong
to the contour - such cases were observed as artifacts
till now.

@Issue: https://github.com/thorvg/thorvg/issues/3268
2025-03-12 20:26:38 +01:00
Mira Grudzinska
5114a87e3d gl_engine: fix line join while dashing
While dashing, changing the path command each time caused
a new 'move to' command to be added, even when dash segments
across different path commands should have been connected.

@Issue: https://github.com/thorvg/thorvg/issues/3231
2025-03-12 20:26:38 +01:00
Mira Grudzinska
4f7d94cd8b gl_engine: fix differences in dashing among engines
The differences resulted from discrepancies between
the engines in applying equality or inequality signs.

@Issue: https://github.com/thorvg/thorvg/issues/3265
2025-03-12 20:26:38 +01:00
Jinny You
52dc586089 lottie/expressions: Fix incorrect evaluation result check condition
A JavaScript code line may return undefined, but this should not be treated as an error.

For example, consider the following two lines of code:
- `var $bm_rt = 30` (Statement) → result: `undefined`
- `$bm_rt = 30` (Expression) → result: `30`

Both lines execute the same operation, but the JavaScript interpreter (REPL JS) evaluates them differently.

Therefore, an evaluation result of undefined should not be blocked, as it does not indicate a failed code execution.
2025-03-12 20:26:38 +01:00
Hermet Park
4ea95d8707 loader: fixed potential memory leaks in font handling
Simply loading a font doesn't mean it is in use.
Fixed the loader's reference count to prevent incorrect increments.
2025-03-12 20:26:38 +01:00
pharuxtan
07da6c5870 sw_engine: fix internal types of rasterXYFlip
Before the C++ compiler couldn't decide the template of std::min (that happen if `int` type is not an `int32_t`), so explicitly changing all types to int32_t fixes this.
2025-03-12 20:26:38 +01:00
Mira Grudzinska
41b340bbdb gl_engine: add offset support in dashed strokes
Offset is correctly applied to dashed strokes,
properly shifting the dash pattern.

@Issue: https://github.com/thorvg/thorvg/issues/3217
@Issue: https://github.com/thorvg/thorvg/issues/3223
@Issue: https://github.com/thorvg/thorvg/issues/3191
2025-03-12 20:26:32 +01:00
Mira Grudzinska
5b15db0c8e gl_engine: fix dashing
Incorrect condition for drawing segments in cubics;
missing checks.

@Issue: https://github.com/thorvg/thorvg/issues/2729
@Issue: https://github.com/thorvg/thorvg/issues/3222
2025-03-12 02:10:32 +01:00
Mira Grudzinska
0e633bd009 sw_engine: fix update issue
In cases where the fill was changed while the stroke existed
but remained unchanged, the stroke would disappear because it
was being reset during the shape preparing (shapeReset).
Fixed by disabling the reset of stroke rle from shape reseting.

Also the shape should be prepared not only when the RenderUpdateFlag
is set to Color, but also when it is set to Gradient.

@Issue: https://github.com/thorvg/thorvg/issues/3237
2025-03-12 02:10:32 +01:00
Mira Grudzinska
589e93fa74 lottie: parsing embedded fonts data (#3220)
Only parsing and font loading is added with
a very basic text update while building the scene.

@Issue: https://github.com/thorvg/thorvg/issues/3184
2025-03-12 02:10:32 +01:00
Hermet Park
7a1df343cc lottie: properly copy missing property values 2025-03-12 02:10:32 +01:00
Mira Grudzinska
1354613d59 lottie: ++ dashed stroke support
Until now lottie loader supported only a single
dash-gap pair, and only the case where only the dash
was provided was handled correctly. When both values
were provided, the gap was incorrectly increased by
the dash value. If more values were supplied, only
the last pair was considered.

@Issue: https://github.com/thorvg/thorvg/issues/3191
2025-03-12 02:10:32 +01:00
Hermet Park
7968b9668e sw_engine: fixed a broken dropshadow
corrected a mismatched stride value of the
direct drawing target buffer.

issue: https://github.com/thorvg/thorvg/issues/3146
2025-03-12 02:10:32 +01:00
Mira Grudzinska
0a76a4f0a3 gl_engine: fix color burn/dodge edge cases
Aligned with sw_engine implementation.
2025-03-12 02:10:32 +01:00
Mira Grudzinska
6a00eb8db0 sw_engine: fix color burn/dodge edge cases
Dodge d / (1 - s):
- handle d = 0 first to avoid 0/0 when s = 1
- for d != 0 and s = 1, the formula results in d/0 (infinity),
  which maps to 1 in the 0-1 range (or 255 in the 0-255 range)

Burn 1 - (1 - d) / s:
- handle d = 1 first to avoid 0/0 when s = 0
- for d != 1 and s = 0, the formula results in  1 - 0/0 -> 1 - inf = -inf
  Negative infinity in the 0-1 range corresponds to the minimum possible
  value, which is 0 (255 if we operate in 0-255 range).
2025-03-12 02:10:32 +01:00
Hermet Park
bca94d244c bump up version v0.15.10 2025-01-30 21:09:27 +09:00
Hermet Park
782f067b22 renderer: hotfix a null memory copy 2025-01-30 21:09:27 +09:00
Hermet Park
173edf62a1 portability: added cstdint header properly.
gcc15 is more strict at the header inclusion,
thorvg header should specify it since it reply on it.

issue: https://github.com/godotengine/godot/pull/102022#discussion_r1929547647
2025-01-30 20:37:01 +09:00
Hermet Park
09ebf10432 lottie: revise the effect parsing logic
Unify the common parts of the parsing logic
by applying a strategy pattern,
allowing the behavior to vary based on the effect type.

This helps to reduce the size and improved the parsing safety.
2025-01-30 20:36:02 +09:00
Mira Grudzinska
8f7103e109 gl_engine: add support for stroke/fill ordering 2025-01-30 20:32:45 +09:00
Hermet Park
89e98b6fcb sw_engine: Improved the blur performance by 12%
Applied the compromised approach for the gaussian blur
since the effect is a bit burdensome for cpu processing
as animatable effects.

- Optimized performance and quality with negligible observable differences.
- Disabled the border option until specific use cases are identified.
2025-01-30 20:24:20 +09:00