Commit graph

230 commits

Author SHA1 Message Date
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
RuiwenTang
059c452249 gl_engine: fix gradient color interpretation error
Fix when gradient position is same as some starting or ending point
of a gradient stop, the output color is blank
2024-06-24 14:37:22 +09:00
Sergii Liebodkin
eadf66e178 wg_engine: fix color buffer corruption with wgpu-opengl wrapper (linux)
In a case of usage stencil buffer only we need to turn off an color target writes. In other case color buffer fill be filled by unxepcted color if fragment shader did not return any value.
It happens in a case on OpenGL realization of webgpu, that used in linux

Befire:

After:
2024-06-24 14:37:15 +09:00
RuiwenTang
1879a2ff0e gl_engine: fix GradientStroke ignored by tessellator
Fix the GlRenderer not take GradientStroke into consider when prepare
Geometry vertices.
2024-06-24 14:36:51 +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
RuiwenTang
25dbf4aacf gl_engine: Support StrokeCap in GlTessellator
Add new function `strokeSquare` and `strokeRound` to handle StrokeCap
during Path tessellation
2024-06-24 14:34:20 +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
a71fd6652a lottie: fixed a missing slot overriding update.
the Lottie scene should be updated when the slot overriding
is updated. Previously, it only depended on the frame update.

issue: https://github.com/thorvg/thorvg/issues/2303
2024-06-24 14:30:46 +09:00
Sergii Liebodkin
9c8b10603e wg_engine: Fill Rule winding optimization
[issues 1479: Fill Rule](#1479)

In this solution we dont need to find silhouette, that is not a cheep operation (decreasing performance in 2 times)

For winding, you can select separate operations for front and back faces (increment for front, decrement for back)
After rendering the fan, the value in the stencil buffer will be the winding number. You can fill the appropriate portion by rendering a screen-sized quad with stencil testing enabled and the stencil function set according to which winding rule you wish to use.

For even-odd, you don't need to distinguish front and back faces; you can just use INVERT as the operation.
2024-06-24 14:30:39 +09:00
Hermet Park
a93c348207 renderer/canvas: tweak the viewport behavior.
reset the viewport context when target buffer is reset.
2024-06-24 14:29:42 +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
3433a50b4a renderer/canvas: revise the logic.
introduce a status variable to identify
the condition precisely.
2024-06-24 14:20:21 +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
Sergii Liebodkin
09751f63cd wg_engine: Text support
[issues 1479: Text](#1479)

EvenOdd fill rule reorganized: using global bbox of whole path for fill
2024-06-24 14:19:34 +09:00
Hermet Park
9ca8eacd65 infra/gl_enigne: fallback use gles v2 if the system doesn't have v3.
let's keep this for a while until our minimum requirement is clear.
2024-06-24 14:14:08 +09:00
Hermet Park
a3fe9c25f2 wg_engine: code refactoring
Use the override specifier so that
a compiler could warn any human mistake.
2024-06-24 14:14:02 +09:00
Hermet Park
edbd2d7728 gl_engine: updated GLES minimum requirement from v2 to v3
GLES v3 was introduced many years ago;
we are now dropping support for GLES v2.

issue: https://github.com/thorvg/thorvg/issues/2269
2024-06-24 14:11:32 +09:00
Mira Grudzinska
d27a9782d4 common: fix a precision issue in appendArc api
For angles close to multiples of pi/2, precision
based on FLT_EPSILON was insufficient. It either
led to the creation of an additional cubic segment
filled with erroneous values or NaNs, or it resulted
in the drawing of an angle for a sweep close to 0.
2024-06-24 12:35:03 +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
RuiwenTang
06fc52ff22 gl_engine: fix stencil logical not correct
Fix the stencil reference and compile function cause rendering not
correct
2024-06-24 12:31:41 +09:00
RuiwenTang
3414a45039 gl_engine: optimize tessellation performance
* restrict the scissor box of composite task
* do not tessellate stroke or fill geometry if there is no Fill or
  Stroke color
* use actually transformed curve to calculate polyline count when doing
  curve flatten
2024-06-24 12:31:32 +09:00
RuiwenTang
a6974a9495 gl_engine: fix rendering error caused by viewport and stencil state
Fix some error:
* glViewport not controlled by framebuffer, and need to set manually when
target framebuffer is changed.
* change even-odd stencil operation, so no need to do third draw call to
  clear stencil buffer
* fix the missing `GlCanvas::update` calls in Lottoe and LottieExtension
2024-06-24 12:27:17 +09:00
Sergii Liebodkin
ddc6fc7f0b wg_engine: blending and composition optimization
[issues 1479: Masking, InvMasking, LumaMasking, InvLumaMasking](#1479)

Computes composition and blending using simgle pass istead of two full screen passes
2024-06-24 12:24:53 +09:00
Mira Grudzinska
4d8ad56cc5 common: fix composition while masking
Using a mask (any type) with alpha set to less
than 255 through the fill(r, g, b, a) API resulted
in incorrect compositions of fill and stroke.
Incorrect results were also observed for luma masks,
as their alpha is calculated based on the other color
channels.

@issue: https://github.com/thorvg/thorvg/issues/1653
2024-06-24 12:23:46 +09:00
RuiwenTang
56de3bb3ca gl_engine: fix gradient rendering error
* Fix error when handle GradientTransform calculation. And move the inv
calculation into gradient vertex shader.
* Fix cubic tessellation not close the last point
2024-06-24 12:23:38 +09:00
Sergii Liebodkin
642fd77a3a wg_engine: update mesh generations and render mechanics
[issues 1479: lottie](#1479)

- optimaze stroking algorithm by prevent vector normalizations
- using render meshes heaps to reduce webgpu instances re-creations
- using single instance of pilylines for standard operations such as trim and split
- "on-the-fly" strokes generations with dash pattern
- "on-the-fly" mesh objects generation in a process of path decoding
- merge strokes into single mesh by each shape
2024-06-24 12:21:10 +09:00
Sergii Liebodkin
f73f3c8b53 wg_engine: added preallocated index buffers for triangle fans
[issues 1479: lottie](#1479)
2024-06-24 12:21:10 +09:00
Sergii Liebodkin
cebf723076 wg_engine: added math and polyline structures for geometry generating optimizations
[issues 1479: lottie](#1479)
2024-06-24 12:21:10 +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
RuiwenTang
216d958e97 gl_engine: using depth buffer to support path clip
* Append depth buffer attachment in tvgGlRenderPass
* using depth test if Shape has path clip
2024-06-24 12:17:38 +09:00
Hermet Park
bfed28e86e common: code refactoring
introduced mathDeg2Rad() and mathRad2Deg() for a common implementation.
2024-06-24 12:12:19 +09:00
RuiwenTang
b7eb72a27d gl_engine: fix some typo inside GlRenderer
* Fix a typo error when prepare blit task
* Prevent repeated texture generation during task preparation
2024-06-24 12:12:10 +09:00
RuiwenTang
574783be16 gl_engine: using normal texture rendering in final color blit
Since blit msaa framebuffer to another msaa framebuffer may generate
GLError in some platforms. Use normal texture rendering to blit the final
color buffer onto target framebuffer.
2024-06-24 12:10:18 +09:00
Hermet Park
026d85f6a8 lottie: code refactoring.
keep the coding style.
2024-06-24 12:05:59 +09:00
Lucas Niu
194bd8f01d lottie: Support the Animation Segment(Marker)
A single animation might have a desinated markers with naming: 0 ~ 0.5 (sector A), 0.5 ~ 1.0  (sector B). Selecting one of them using a marker name(sector A) and could play only that part with animation controllers.

usage:
- `animation->segment("sectionA") // Named segment(Marker)`
- `auto cnt = animation->markerCnt()`
- `auto name = animation->markers(index)`
- `animation->segment(0, 0.5) // Segment`
- `animation->segment(&begin, &end)`

Co-authored-by: Jinny You <jinny@lottiefiles.com>
2024-06-24 12:00:25 +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
710d1f99ae renderer/loader: fix a font loader memory leak 2024-04-07 15:15:59 +09:00
Sergii Liebodkin
366c1be6bd wg_engine: vertex, index and unifroms buffers, render objects caching
[issues 1479: lottie](#1479)

Vertex, Index and uniform buffers now updates instead of recreate.
Implemented pools form mesh objects and render shapes data

it increase performance in 30-40% in massive animations scenes
2024-04-07 15:15:59 +09:00
Hermet Park
4746b2cf7b gl_engine: hotfix for the main surface drawing issue.
GL might need to generate a default target FBO
when the given target ID indicates the main surface.

However, users may want to draw visuals directly onto the main surface.

This policy must be reviewed thoroughly.
2024-04-07 15:15:59 +09:00
RuiwenTang
cde17a4fc6 gl_engine: change all shader output premultiplied alpha color 2024-04-07 15:15:59 +09:00
Hermet Park
efc7199e51 renderer/loader: ensure unique scene instances for each Lottie loader
The Lottie loader now utilizes an individual scene instance per loader.
This guarantees that each instance retains a unique frame number,
essential for maintaining the integrity of animation states.

As a result, sharing loaders between Lottie animations is prohibited
to uphold frame context isolation.

This may be subject to optimization review in the future.
2024-04-06 12:48:30 +09:00
Hermet Park
34bb27bfc9 renderer/saver: enhanced safety
enhanced safety by taking into account the object reference counting.
2024-04-06 12:48:30 +09:00
Hermet Park
1632ad9ee5 lottie: removed unused code.
Currently, thorvg has no plan to support dotlottie format.
2024-04-06 12:48:30 +09:00