Commit graph

149 commits

Author SHA1 Message Date
Hermet Park
d3a900701f 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-09-30 15:21:27 +09:00
Hermet Park
4345d6b8a5 API: revise the APIs.
deprecate the `identifier()` APIs by replacing them with `type()`.

ThorVG is going to introduce an instance `id()`,
and this could be confused with the `identifier()` methods.

with this new type() method can reduce the memory size
by removing unncessary type data.

New Experimental C APIs:
- enum Tvg_Type
- Tvg_Result tvg_paint_get_type(const Tvg_Paint* paint, Tvg_Type* type)
- Tvg_Result tvg_gradient_get_type(const Tvg_Gradient* grad, Tvg_Type* type)

New Experimental C++ APIs:
- Type Paint::type() const
- Type Fill::type() const
- Type LinearGradient::type() const
- Type RadialGradient::type() const
- Type Shape::type() const
- Type Scene::type() const
- Type Picture::type() const
- Type Text::type() const

Deprecated C APIs:
- enum Tvg_Identifier
- Tvg_Result tvg_paint_get_identifier(const Tvg_Paint* paint, Tvg_Identifier* identifier)
- Tvg_Result tvg_gradient_get_identifier(const Tvg_Gradient* grad, Tvg_Identifier* identifier)

Deprecated C++ APIs:
- enum class Type
- uint32_t Paint::identifier() const
- uint32_t Fill::identifier() const
- static uint32_t Picture::identifier()
- static uint32_t Scene::identifier()
- static uint32_t Shape::identifier()
- static uint32_t LinearGradient:identifier()
- static uint32_T RadialGradient::identfier()

Removed Experimental APIs:
- static uint32_t Text::identifier()

issue: https://github.com/thorvg/thorvg/issues/1372
2024-09-30 12:55:16 +09:00
Hermet Park
ce50165103 common: Fix a compilation failure on VS 2017
issue: https://github.com/thorvg/thorvg/issues/2512
2024-09-30 12:49:06 +09:00
Hermet Park
3390ff21fc sw_engine: support the grayscale scaled-image drawing 2024-09-30 12:46:56 +09:00
Mira Grudzinska
ceae547062 sw_engine: fix aa
For shapes with a stroke that has opacity, anti-aliasing
should be applied to a fill.
The use of a transparent gradient stroke will also be handled
correctly.
2024-09-30 12:45:40 +09:00
Hermet Park
74cd0ba0e7 common: code refactoring
replaced min/max with the standard library
2024-09-30 12:45:14 +09:00
Josh Soref
e3c66db301 common: fix 178+ spelling errors 2024-09-30 12:41:38 +09:00
Mira Grudzinska
f3e0dc3432 sw_engine: improve grad quality
For gradients with fill spread set as repeat,
the lack of anti-aliasing between the last and
the first color caused noticeable jagged edges.
Interpolation was introduced between them,
visually improving the gradient quality.
2024-09-30 12:37:15 +09:00
Hermet Park
5f4468236c sw_engine: ++thread safety
Synchronize the engine process precisely
before updating internal data.
2024-06-27 14:42:27 +09:00
Hermet Park
2fb79eca7d sw_engine: fix missing fill/stroke raster
properly update the fill/stroke when the path
has been changed
2024-06-27 14:42:27 +09:00
Mira Grudzinska
58e24f63a4 sw_engine: fix stroke miterlimit precision
Since the value was casted to int the results
were different than expected.
2024-06-27 14:42:27 +09:00
Hermet Park
8b5d2e4a13 sw_engine: ++exception handling
prevent the out of range anti-aliasing frames.

issue: https://github.com/thorvg/thorvg/issues/2401
2024-06-27 14:42:27 +09:00
Hermet Park
8332ee3b95 sw_engine: hotfix avx/neon 8 bit rasterizer.
recte/rle 8 bit rasterizer has been broken,
make it work safely with c raster version.

issue: https://github.com/thorvg/thorvg/issues/2146
2024-06-27 14:42:27 +09:00
Hermet Park
56d3885f24 sw_engine: fix a crash issue.
set the anti-aliasing frame info properly, in an exceptional case.

issue: https://github.com/thorvg/thorvg/issues/2391
2024-06-24 14:51:40 +09:00
Hermet Park
59194b8ab2 sw_engine: fix a missing anti-aliasing
enable fill anti-aliasing when the stroke is trimming.
2024-06-24 14:51:34 +09:00
Hermet Park
5a6d31a2e9 renderer: code clean up 2024-06-24 14:44:15 +09:00
Mira Grudzinska
b95fa3a7bd sw_engine: fix fastTrack condition
When checking the fastTrack condition,
it's necessary to exclude the outlines
with a Bezier curve (Move-Cubic-Line,
Move-Cubic-Close, Move-Line-Cubic).

@Issue: https://github.com/thorvg/thorvg/issues/2379
2024-06-24 14:43:54 +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
Mira Grudzinska
f0b0ea3edb sw_engine: fix trimming
For the 'simultaneous' trimming option, the maximum
stroke length from all subpaths was determined and
used to scale the trim of each subpath. As a result,
if the subpaths had different lengths, this scaling
was incorrect.
Now, the length is determined separately for each
subpath and is used to scale the trimming of its stroke.

@Issue: https://github.com/thorvg/thorvg/issues/2335
2024-06-24 14:42:25 +09:00
Mira Grudzinska
e6f4b5a2a8 common: strokeTrim api introduced
New api sets/gets the trim of the stroke
along the defined path segment, allowing
control over which part of the stroke is
visible.

@issue: https://github.com/thorvg/thorvg/issues/2190
2024-06-24 14:37:53 +09:00
Mira Grudzinska
f14be7c33b common: fix typos & remove unused var 2024-06-24 14:36:43 +09:00
Mira Grudzinska
c88d6cbdf3 sw_engine: fix dashing
Fixing the problem with handling a specific
case where the length of the remaining line
to be drawn and the dash line length were
exactly the same
2024-06-24 14:36:29 +09:00
Niklas Fiekas
5204426667 sw_engine: fix -Wcalloc-transposed-args 2024-06-24 14:34:05 +09:00
Hermet Park
407fcf69e3 common: code refactoring
Replace the math functions with operator overloading.
This should potentially reduce the code size.
2024-06-24 14:33:49 +09:00
Hermet Park
c8adda4690 sw_engine: code clean up 2024-06-24 14:31:10 +09:00
Hermet Park
0e6fa01ac9 math: introduced a custom floating epsilon
Rather than aiming for extremely high accuracy,
a compromise can achieve with better performance.

This modification helps prevent unnecessary image rotation.

issue: https://github.com/thorvg/thorvg/issues/2265
2024-06-24 14:31:01 +09:00
Hermet Park
090ebfba86 xrenderer/engines: support the canvas viewport function.
The viewport function defines the rectangular area of the canvas
that will be used for drawing operations.

It is used to clip the rendering output to the boundaries of the rectangle.
Apps can use this function to set the drawing region within the canvas.

When the ThorVG canvas is partially inside the screen area such as during scrolling
it could help enhance rendering performance.

New Experimental API:
- Result Canvas::viewport(int32_t x, int32_t y, int32_t w, int32_t h) noexcept;

Issue: https://github.com/thorvg/thorvg/issues/2274
2024-06-24 14:20:46 +09:00
Hermet Park
5b3a045f15 renderer/engines: added mainSurface() interface.
This interface expects the main surface of the raster engine.
2024-06-24 14:19:43 +09:00
b224aa9765 sw_engine/neon: arm neonRasterPixel32 function to support aarch64
Improved the speed through neon processing.

Improvements Rate:
Lottie: (0.026321/0.026779) = +1.8%
Performance: (0.015411/0.015732) = +2.1%

issue: https://github.com/thorvg/thorvg/issues/30
2024-06-24 12:34:49 +09:00
b5b52d6d61 sw_engine : arm neonRasterGrayscale8 function to support aarch64
Improved the speed through neon processing.

Improvements Rate:
Lottie: (0.025986/0.026201) = +4.7%
Performance: (0.014163/0.014785) = +4.3%

issue: https://github.com/thorvg/thorvg/issues/30
2024-06-24 12:33:26 +09:00
Mira Grudzinska
179e2eb218 sw_engine: fix max length of trimmed strokes
The error was visible when multiple shapes were
simultaneously trimmed. The length of a single
shape was zeroed out only in selected cases,
which caused accumulation that could lead to
incorrect extension of the variable determining
the maximum length.

@issue: https://github.com/thorvg/thorvg/issues/2173
2024-06-24 12:18:32 +09:00
9904d7b468 sw_engine : type cast compile error 2024-06-24 12:00:17 +09:00
6b27226390 sw_engine: Implement AVX and NEON optimizations for RasterGrayscale 2024-06-24 12:00:04 +09:00
EunSik Jeong
6d3ea78d96 sw_engine/neon : Fix compilation error 2024-04-07 15:15:59 +09:00
Hermet Park
043b14d681 sw_engine/stroke: hotfix the memory access violation
ensure that the number of contour/close data is properly paired.

issue: https://github.com/thorvg/thorvg/issues/2129
2024-04-06 12:48:30 +09:00
Hermet Park
6688f03396 sw_engine: revised the trimpath dash line logic
Support the TrimPath modes (individual/simultaneous)
internally in the engine to handle them efficiently.
2024-04-06 12:48:30 +09:00
Hermet Park
e4f7fffacc sw_engine: hotfix a regression bug of line drawing.
fixed one more corner case problem, just observed.
it's a side effect by 925009c4a5
2024-04-06 12:48:30 +09:00
Hermet Park
68e4d35f7b sw_engine: stabilize the contour composition logic.
there has been a logical error that breaks the contour
composition context. This fixes it.

issue: https://github.com/thorvg/thorvg/issues/2093
2024-04-06 12:08:23 +09:00
Hermet Park
051969c61c sw_engine: rectify consecutive line drawings.
There are differences in behavior compared to the SVG spec,
especially when consecutive line drawings occur without a moveTo command
following a closePath command.

Actually, thorvg didn't care the behavior in that scenario,
this update ensures the scenario is handled correctly
to align with the SVG specification.

issue: https://github.com/thorvg/thorvg/issues/1487
2024-04-06 12:08:23 +09:00
Vincent Torri
2f196b514f [common] code clean up
use fmodf() instead of fmod()
2024-04-06 12:08:23 +09:00
Lorcán Mc Donagh
612b52a3e3 sw_engine: fix radial gradient when focal point is outside circle on ARM/Apple Silicon
sw_engine: radial gradient
[issues 2014: radial gradient](#2014)

Radial gradient results in a corrupted image when the focal point is outside the circle on Apple Silicon.
This happens because some compilers use FMA to optimize the a = dr² - dx² - dy² calculation,
which cause loss of precision.

We rely on temporary variables to prevent FMA.
We could also use compiler specific float contraction control pragmas to avoid this if this doesn't work in the future
2024-04-06 12:08:21 +09:00
Mira Grudzinska
203d892cbd sw_engine: fix a regression bug
After introducing the length measurement
of approximate and exact Bezier curves in
a8c0030d80
the calculation of the outline length still
used the approximate functions, while further
calculations took the exact value into account.
This discrepancy led to the creation of artifacts.

@Issue: https://github.com/thorvg/thorvg/issues/2021
2024-04-06 12:08:21 +09:00
Hermet Park
604c4dc0b0 sw_engine: fix a regression bug.
stroke line drawing has been broken at a certain case,
this reverts a part of change from the old optimization:

d81f5d29fb

note that this change wouldn't affect any performance.

issue: https://github.com/thorvg/thorvg/issues/2015
2024-04-06 12:08:21 +09:00
Hermet Park
c08c11db7d common: code refactoring
refactor common code to consolidate Bezier and line
function implementations into a single location.
2024-04-06 12:08:21 +09:00
Hermet Park
71c636e33c Revert "Revert "sw_engine: Increasing accuracy for dashed curves""
This reverts commit e49f9125b2.
2024-04-06 12:08:21 +09:00
Hermet Park
c01c8338d7 Revert "sw_engine: Increasing accuracy for dashed curves"
This reverts commit a8c0030d80.
2024-04-06 12:08:21 +09:00
Mira Grudzinska
d399ae922a sw_engine: Increasing accuracy for dashed curves
Dashed curves require greater precision in calculating
their lengths and while splitting Bezier curves.
Otherwise, it results in visual discrepancies compared
to the expected outcomes.
Approximate functions 'bezLengthApprox' and 'bezAtApprox'
used for calculations in the lottie loader.

issue: https://github.com/thorvg/thorvg/issues/1686
2024-04-06 12:08:21 +09:00
Mira Grudzinska
e718940f81 sw_engine: fixing stroke outline
In the case of non-uniform scaling for
thick strokes, artifacts were visible.
The calculations took into account the angle
resulting from the already transformed points,
whereas the untransformed points should have
been considered - the transformation is taken
into account in the next step.

@issue: https://github.com/thorvg/thorvg/issues/1915
2024-04-06 12:08:21 +09:00