Commit graph

21 commits

Author SHA1 Message Date
Mira Grudzinska
031dd647bc sw_engine: fix too small memory alloc for spans
In some clipping cases, the memory allocated for storing spans
was too small. As a result, the entire clipped area might not
have been rendered.
This has been resolved by adding an experimental factor to increase
the size of allocated memory.

@issue: https://github.com/thorvg/thorvg/issues/3461
2025-05-24 01:37:24 +09: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
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
Hermet Park
cb0691fee0 sw_engine: corrected the rle cell building
Properly build the cell cover value
when a new cell value is just overlapped.

This fixes certain weird visual artifacts at a corner case.

issue: https://github.com/thorvg/thorvg/issues/2929
2025-01-02 15:08:43 +01:00
Hermet Park
8585b27abf sw_engine: fixed a rendering bug when the invalid clipper is applied.
Shapes with boundaries outside the rendering area are ignored as non-visible.
The issue arises when such a shape serves as a clipper.
The expected behavior is for the entire clipee to be cut out,
but previously, the clipee remained fully visible as if no clip was applied.

The fix identifies these clippers and skips rendering clipees.

Please note that we can skip rendering at the Paint update stage
if the clipper's viewport is outside the canvas.
This optimization can improve performance, but only for this specific case.
The downside of the approach is that it disrupts multi-processing for clipper updates.
As a result, that approach was discarded.

issue: https://github.com/thorvg/thorvg/issues/3003
issue: https://github.com/thorvg/thorvg/issues/2684

Co-Authored-By: Mira Grudzinska <mira@lottiefiles.com>
2024-12-19 16:29:21 +01:00
Dragoș Tiselice
c5a7d76109 sw_engine: replaced longjmp with returns
Since longjmp is not yet fully supported on Wasm (emscripten uses
JS to make the jumps and requires slow jumps), but also because
longjmp is hard to reason about, this patch replaces it with
return values. The logic stays exactly the same.
2024-12-05 12:20:12 +01:00
Mira Grudzinska
cb2a15528d sw_engine: split long lines to avoid overflow
@Issue: https://github.com/thorvg/thorvg/issues/2651
2024-10-22 00:39:14 +09:00
Mira Grudzinska
52def8dc27 sw_engine: ++exception handling
Prevent the infinite loop in the worst case

@Issue: https://github.com/thorvg/thorvg/issues/2651
2024-10-04 00:34:16 +09:00
Hermet Park
aece166cb7 sw_engine: ++stability
cut the Bezier curve based on the number of points
and transform it into a straight line when it's very small.

issue: https://github.com/thorvg/thorvg/issues/2759
2024-10-03 19:02:26 +09:00
Hermet Park
7a0c12ed8b api: Introduced Paint::clip() API
Separate clip function from the Composite()
clipping and composition can be used together.

This helps avoid the introduction of nested scenes
when composition and clipping overlap.

Deprecated:
- enum class CompositeMethod::ClipPath
- enum Tvg_Composite_Method::TVG_COMPOSITE_METHOD_CLIP_PATH

Experimental API:
- Result Paint::clip(std::unique_ptr<Paint> clipper)
- Tvg_Result tvg_paint_set_clip(Tvg_Paint* paint, Tvg_Paint* clipper)

Issue: https://github.com/thorvg/thorvg/issues/1496
2024-09-30 16:44:22 +09:00
Hermet Park
a25366b283 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-09-30 16:44:21 +09:00
Hermet Park
f4cd6b8d8c sw_engine: code refactoring.
just renamed internal name shorter.
2024-09-30 15:23:21 +09:00
Hermet Park
8e6e224284 sw_engine: ++rle optimization
Reduction memory copy by pushing span data into rle immediately.
2024-09-30 15:23:15 +09:00
Josh Soref
e3c66db301 common: fix 178+ spelling errors 2024-09-30 12:41:38 +09:00
Hermet Park
3c3ad144a7 Revert "sw_engine: revert the threshold."
This reverts commit dad797445b.

Misidentified the key issue. It will be reviewed again.
2024-06-24 14:43:07 +09:00
Hermet Park
f9c86fc38a sw_engine: revert the threshold.
Somehow, it breaks the window unit-test, revert the value.

regression by: 51a2936b28
2024-06-24 14:43:00 +09:00
Hermet Park
7fd552fab0 sw_engine: fine-tuning RLE performance.
the arranged value is examined with the local test,
improved the speed twice for a corner-case that
extreamly huge size shape.
2024-06-24 14:42:54 +09:00
Hermet Park
b0540929e5 common/array: code refactoring
Make the array interface pair begin()/end() for consistency.
2024-04-06 12:08:21 +09:00
Jinny You
92288c8291 updated copyright date (#1866) 2024-01-02 20:34:12 +09:00
Hermet Park
5a73bcaa8f common/array: code refactoring
easy access to a specific data with a operator.
2023-08-29 12:28:38 +09:00
Hermet Park
24711e485c infra: renames the source folders
lib -> renderer
bin -> tools
utils -> common
2023-08-28 13:11:24 +09:00
Renamed from src/lib/sw_engine/tvgSwRle.cpp (Browse further)