Commit graph

342 commits

Author SHA1 Message Date
Hermet Park
ced252e0eb renderer: ++reliability in text drawing
Allow the canvas to pass through
even if text elements are not properly supported.

issue: https://github.com/thorvg/thorvg/issues/2715
2024-09-12 22:11:26 +09:00
Hermet Park
1eb3e068df sw_engine: cleaned up the blending operations.
Corrected the alpha interpolation order during blending.
This also corrected the hard mix blending result in the guitar sample.

issue: https://github.com/thorvg/thorvg/issues/2704
2024-09-12 22:09:54 +09:00
Mira Grudzinska
216167ccde sw_engine: increased accuracy in dashing
The limit on leftovers was too small, which became
noticeable for animations with trimming - currently
implemented with the dashing alg.
The limit has been increased.
2024-09-05 23:57:22 +09:00
Hermet Park
759354f7cd sw_engine: fixed incorrect image blending operations
The anti-aliased outline color was incorrectly blended
at the multiply option.

The fix can be observed in the example:
'examples/lottie/resourcesguitar.json'

in order to do this, RenderMehthod::blend() method introduced
`bool direct` for figuring out the intermediate composition.
2024-08-30 01:08:37 +09:00
Łukasz Pomietło
f324cc993d renderer/text: fix a missing text update
previously font size & italic style had been ignored
even if its attributes are changed.

Co-Authored-By: Hermet Park <hermet@lottiefiles.com>

issue: https://github.com/thorvg/thorvg/issues/2676
2024-08-30 01:00:42 +09:00
lpogic
35ffa9edf8 text: fixed a corrupted italic style application
issue: https://github.com/thorvg/thorvg/issues/2669
2024-08-30 00:57:57 +09:00
tangruiwen.mmh1103
fbae8ad095 gl_engine: fix mistake in the calculation of stroke miter limit
* correct the stroke width and color calculation with scaling
* fix the miter limit calculation to make bevel join fallback correct
2024-08-30 00:56:57 +09:00
Mira Grudzinska
1540ecb4c0 common: prevent warning - expression result unused 2024-08-23 10:46:38 +09:00
Hermet Park
222eb2720a renderer/text: --memory leak
regression by 71d3fce1dd
2024-08-23 10:46:29 +09:00
Hermet Park
9a1d169558 sw_engine/texmap: ++fixed memory access violation
Co-Authored-By: Mira Grudzinska <mira@lottiefiles.com>
2024-08-23 10:46:22 +09:00
Mira Grudzinska
a08c73b08b sw_engine: fix TexmapPolygon rastering
The y range initialization was missing a check to ensure
that the height is a positive value. This could lead to
an attempt to call malloc with a negative argument, which
cast to an unsigned value, caused a crash.
2024-08-23 10:46:07 +09:00
Hermet Park
f5337015e9 renderer: text refactoring
- assign the shape instance as mandatory.
- assign the text instance internally.
2024-08-23 10:45:55 +09:00
Hermet Park
8ca5e74902 api: corrected wrong const specifier
Setter obvisouly modifies the instance.
2024-08-23 10:45:49 +09:00
Hermet Park
65c808fc02 common: spec out TexMap
Spec out this incomplete experimental feature,
this is a still promising one, we will reintroduce
this officially after 1.0 release

size: -2kb

issue: https://github.com/thorvg/thorvg/issues/1372
2024-08-23 10:45:14 +09:00
Hermet Park
8927294374 common: spec out Scene Clipper
Scene Clipper is an unusual feature
that is too unstable and ambiguous in ThorVG.

Users can achieve the same functionality
with multiple composed shapes instead of scene clipping.

size: -2.5kb

issues:
- https://github.com/thorvg/thorvg/issues/1548
- https://github.com/thorvg/thorvg/issues/1549
- https://github.com/thorvg/thorvg/issues/1573
2024-08-15 23:18:39 +09:00
Hermet Park
331ea0cae3 lottie: ++scene rendering optimization
Apply LottieRenderPooler to RenderContext propagators.
2024-08-15 23:13:52 +09:00
Hermet Park
b88ccd2cfc renderer: rectified the bounds() behavior
Text fill is broken by 43c87b4eb5
2024-08-09 11:33:38 +09:00
Hermet Park
6ef1986fe1 renderer/paint: revise the Paint::bounds() behavior
The current Paint::bounds(transform=true) returns the coordinates
of the paint in its local coordinates after transformation.

However, it did not convert the origin to the world coordinate.

This is problematic when the user wants to determine
the paint's position and size with the origin being the canvas.
Specifically, this matters that when the paint is belonged
to a certain scene.

Now, the bounds() method returns the coordinates
of the paint's bounding box with the corrected world space.
User can figure out the actual boundary within the painted result.

Remark that, this may break the functional behavior compatibility.
2024-08-09 11:33:38 +09:00
Hermet Park
7ec8d2f392 renderer/picture: added a method to search for a paint object
This utility method allows access to a specific paint instance
by its unique identifier.

Experimental API:
- const Paint* Picture::paint(uint32_t id)
- const Tvg_Paint* tvg_picture_get_paint(Tvg_Paint* paint, uint32_t id)
2024-08-09 11:33:38 +09:00
Hermet Park
e9b69cb7eb renderer/accessor: added the id generator.
This function computes a unique identifier value based on the provided string.
You can use this to assign a unique ID to the Paint object.

Experimental APIs:
- uint32_t Accessorr::id(const char* name)
- uint32_t tvg_accessor_id(const char* name)
2024-08-09 11:33:38 +09:00
Hermet Park
7afe90ce8e renderer/accessor: revise set() api for animation support
before:
unique_ptr<Picture> Accessor::set(unique_ptr<Picture> picture, function<bool(const Paint* paint)> func)

after:
Result Accessor::set(const Picture* picture, std::function<bool(const Paint* paint, void* data)> func, void* data)
2024-08-09 11:33:38 +09:00
Hermet Park
b20d5da552 renderer: newly support the Lighten/Darken Masking options
Lighten is applied, where multiple masks intersect,
the highest transparency value is used.

Darken is applied, where multiple masks intersect,
the lowest transparency value is used.

Experimental API:
- CompositeMethod::LightenMask
- CompositeMethod::DarkenMask

issue: https://github.com/thorvg/thorvg/issues/2608
2024-08-09 11:33:38 +09:00
Stephan T. Lavavej
82aa0c2bf4 Revert "common: fix a crash on CI windows test."
This reverts commit e51dfb068a.
2024-08-09 11:33:38 +09:00
Mira Grudzinska
5ff9c08ba9 sw_engine: handle grad edge cases
For a linear gradient defined by identical start and end
points, and for a radial gradient with a radius of 0,
the rendered shape should have the color of the last
specified color stop.
The documentation has been updated accordingly.

@Issue: https://github.com/thorvg/thorvg/issues/2582
2024-08-09 11:33:38 +09:00
Mira Grudzinska
2f21e76d85 common: fix trimming
By mistake > was used instead of >=.
The issue was observed for trim when
the trim length was exactly zero.
2024-08-09 11:33:38 +09:00
Mira Grudzinska
1ef9c6be9b common: move&fix trimming wrapping logic
The logic of interpretation of trimming start and
end values has been moved to the sw_engine,
so the values provided by the user are not modified.
No logical changes in the interpretation alg.

For pairs of trim's start/end values where the distance
between begin and end is >= 1, the entire stroke should
be drawn, but instead, nothing or only part is drawn. Fixed.

Stroke trim docs fixed.
2024-08-09 11:33:38 +09:00
Hermet Park
8c4b9b2772 renderer: code refactoring
Replaced the transformation with
a strong associated data field.

This helps to reduce the binary size (-1k).
2024-08-09 10:49:26 +09:00
Hermet Park
0c709b2e43 common: code refactoring
Trimming the transform data pass,
from RenderTransform to Matrix.

No logical changes.
2024-08-09 10:37:39 +09:00
Mira Grudzinska
273fe5b46d sw_engine: fix radial coefficients calculations
In the Taylor series expansion, there was a missing
division by 2! in the term with the second derivative.

@Issue: https://github.com/thorvg/thorvg/issues/2530
2024-08-09 10:29:53 +09:00
Hermet Park
267a467dab sw_engine: rectified the image raster return value.
Return the raster image as a success unless
it fails due to any problematic condition.

The changed cases are just invisible condition
of the images.
2024-07-26 12:13:37 +09:00
Hermet Park
57e0d5b448 renderer/animation: rectified the segment value exception
A zero-range segment can be useful for a stopped motion.
There is no need to prohibit these values.
2024-07-26 11:37:16 +09:00
Mira Grudzinska
641fe5b544 sw_engine: fix linear grad issue
The restriction of the 'length' of a linear gradient
to values greater than FLT_EPSILON was causing rendering
issues in cases where it was a valid gradient with well
defined dx and dy values.

@Issue: https://github.com/thorvg/thorvg/issues/2582
2024-07-26 11:37:16 +09:00
Hermet Park
4a447abaae renderer: quick skip rendering if the opacity is zero
This also resolves a corner case bug introduced by
lottie render pooling: f06127ab93
2024-07-26 11:37:16 +09:00
Hermet Park
71a0010c2d sw_engine: ++alpha blending operation.
Reduce instructions, improving its performance by ~15%
2024-07-19 08:42:19 +09:00
Mira Grudzinska
b876402311 common: version api introduced
@Issue: https://github.com/thorvg/thorvg/issues/2543
2024-07-19 08:42:02 +09:00
Hermet Park
183749d1aa renderer: ++null check
fixed a Duplicate example crash, regression by:
f06127ab93
2024-07-19 08:41:54 +09:00
Hermet Park
cf253dd873 lottie: ++scene rendering optimization
Apply LottieRenderPooler to path/rect/ellipse/polystar.

This enhances the animation performance: ~10%
2024-07-19 08:41:38 +09:00
Mira Grudzinska
d0210a1a72 sw_engine: grayscale image support++ 2024-07-19 08:40:06 +09:00
Hermet Park
318c76119a common: replace the round() with nearbyint()
nearbyint() is 2x faster than round() in our local test.
2024-07-12 11:18:56 +09:00
Hermet Park
74f5928e84 sw_engine: ++rle optimization
Reduction memory copy by pushing span data into rle immediately.
2024-07-12 11:18:56 +09:00
Mira Grudzinska
8fceba01d2 sw_engine: fix masked translucent rect 2024-07-12 11:18:56 +09:00
Hermet Park
1c8698ce20 common/math: introduced custom atan2()
the custom atan2 algorithm by Remez.
see: https://en.wikipedia.org/wiki/Remez_algorithm

This improved the Lottie example by ~2ms.
Total atan2 performance time was reduced by 43%
2024-07-12 11:18:56 +09:00
Hermet Park
19815de7d7 renderer: ++optimization
skip locking if the thread number is 0.
2024-07-12 11:18:56 +09:00
RuiwenTang
90399665e2 gl_engine: fix aliasing in gradient rendering 2024-07-12 11:18:56 +09:00
RuiwenTang
b34fa36edb gl_engine: make sure solid color not overwrite gradient fill
If there are both gradient colors and solid colors
the gradient color is used first for rendering
2024-07-12 11:18:53 +09:00
Hermet Park
42e008f69c renderer: rectified render update flags.
Image update flag has been missed, when the image
is copied with a surface. This fixed it.

Also try to skip update if any properties were not changed.
2024-07-12 11:01:12 +09:00
Hermet Park
e12a244b9e renderer: Rectified the paint transforms.
This corrects the return value to Result::InsufficientCondition
when a custom transform is applied.

Additionally, unnecessary x and y member fields have been removed.
2024-07-12 11:01:01 +09:00
Hermet Park
f080976101 gl_engine: --deprecated warnings on macOS
macOS has officially deprecated OpenGL.
shutdown the warnings to avoid be side-tracked.
2024-07-05 12:19:34 +09:00
RuiwenTang
619a352cb2 gl_engine: fix memory leak when rendering image 2024-07-05 12:19:34 +09:00
Hermet Park
a3c5b0ec2f gl_engine: ++thread safety
The `dispose()` method can be called on a worker thread.
GL resources are released on `sync()`, ensuring guaranteed thread safety.
2024-07-05 11:04:28 +09:00