Commit graph

1782 commits

Author SHA1 Message Date
Mira Grudzinska
8c0fc2b25a capi: dashed stroke setter and getter modyfied
tvg_shape_set_stroke_dash() and tvg_shape_get_stroke_dash()
require an extra argument: offset
2023-08-23 12:40:27 +09:00
Mira Grudzinska
478e45f9f3 common: stroke dash offset support added
The feature is supported also in the svg loader.

@Issue: https://github.com/thorvg/thorvg/issues/1591
2023-08-23 12:40:27 +09:00
Mira Grudzinska
c1e4e0808a Revert "api: enhance Shape::stroke() method usage."
This reverts commit 6cbc1de570.
Setting def value for 'a' makes it impossible to overload
the 'stroke' api with 3 values (needed for introducing dash offset).
2023-08-23 12:40:27 +09:00
Hermet Park
899ea77695 exmamples lottie: add a time measurement. 2023-08-22 21:25:59 +09:00
Hermet Park
4127f4ce7a loader/lottie: revised the key-frame searching
Replace the linear search algorithm with binary-search.

The performance enhancement may not yield significant benefits in normal cases.
However, it becomes crucial if the animation comprises an extensive number of frames...
2023-08-22 21:25:51 +09:00
Hermet Park
345b867c38 loader/lottie: optimize the matrix computation.
Do not multiply the matrices if either one is identity.
2023-08-22 21:25:42 +09:00
Hermet Park
b240e781d9 loader/lottie: ++optimization.
Removed intermediate scenes that were nothing more than transformations.
2023-08-22 21:25:37 +09:00
Hermet Park
f399491557 loader/svg: ++optimization
flush out the used internal memory immediately.
2023-08-22 13:29:49 +09:00
Hermet Park
5d32cf1e3b loader/svg: ++optimization
share the image data to bypass the need for multiple bitmap memory copies.
2023-08-22 13:29:49 +09:00
Hermet Park
3437e4729f examples: remove Stress
we have a good stress test - Lottie
2023-08-21 19:49:05 +09:00
Hermet Park
77de62068c renderer taskscheduler: code refactoring.
removed an unnecessary internal variable.
2023-08-21 17:16:45 +09:00
Hermet Park
8f9bdebd35 renderer task-scheduler: ++thread safety
Currently, tasks are expected to be triggered from the main thread.
This ensures preventing the popping of a thread from a worker thread.

Previously, there was a potential deadlock problem...
2023-08-21 17:16:45 +09:00
Hermet Park
cd71c66703 loader/jpg: fix a sanitizer report.
Bypass the operation involving a negative value shift.

../src/loaders/jpg/tvgJpgd.cpp:434:36: runtime error: left shift of negative value -5
2023-08-21 17:16:45 +09:00
Mira Grudzinska
c2ca01a5c5 common: shape's composition fixed
In the case of a gradient stroke and a valid
fill, the composition wasn't applied correctly,
resulting in an unexpected overlap between
the fill and stroke.

@Issue: https://github.com/thorvg/thorvg/issues/445
2023-08-20 21:39:56 +09:00
Mira Grudzinska
70fff186b2 svg_loader: support other units for mask and clip
Added support for the objectBoundingBox value of
the clipPathUnits and for the userSpaceOnUse value
of the maskContentUnits.

@Issue: https://github.com/thorvg/thorvg/issues/429
2023-08-19 13:10:03 +09:00
Hermet Park
f573e1390f renderer/paint: added an option for stroking when acquiring bounding box size.
The 'Paint' function now includes an internal stroking option,
allowing the bounding box to be calculated with or without the stroke size taken into account.

This feature is particularly useful for SVG loaders,
and we might consider making the interface available for user demands in the future.
2023-08-18 22:15:55 +09:00
Hermet Park
664f028c15 loader/lottie: fix all data conversion compiler warnings on windows 2023-08-18 16:36:15 +09:00
Hermet Park
c90962a26c lottie/loader: fix memory leaks 2023-08-18 15:16:34 +09:00
Hermet Park
cf826bee5d lottie/builder: --compiler warning on MacOS 2023-08-18 13:14:06 +09:00
Hermet Park
994c1b99a5 lottie/loader: support the masking features.
Enhancing the basic masking options by providing additional support.
2023-08-17 23:03:37 +09:00
Hermet Park
3b2c040f70 loader/lottie: add the missing solid color layer. 2023-08-17 23:03:37 +09:00
Hermet Park
e7d29e166b loaders: unify duplicated b64 decoders.
- move the svg/lottie b64 decoders to tvgLzw.
- renames tvgLzw -> tvgCompressor
2023-08-17 21:28:58 +09:00
Hermet Park
846823bd7f utils/math: binary size reduction
reduced the binary size by 2kb by removing the inline code.
2023-08-17 21:28:58 +09:00
Hermet Park
e4b8f70f4f loader/svg: remove the redundant copyright.
The SVG scene builder has undergone significant changes.
It no longer retains the shadow of the original source.
2023-08-17 21:28:58 +09:00
Hermet Park
381dfb06d4 renderer paint: tiny optimization
Skip the unnecessary assignment of the value when the initial values
come.
2023-08-17 21:28:58 +09:00
RuiwenTang
66e533deee gl_engine: Fix mistake in glbuffer id check
`GL_INVALID_VALUE` is generate during `glGenBuffers` and is checked by
calling `glGetError()` inside `GL_CHECK` macro.

While the buffer id is valid if the value is not zero.
2023-08-17 21:28:37 +09:00
Mira Grudzinska
5bafdcbfa3 lottie_loader: return false for frameRate = 0
Loading a png file without giving a mimetype, resulted
in an error from the lottie loader.
2023-08-17 18:47:51 +09:00
Hermet Park
15c09f260f loader/lottie: Fix the incorrect precomp layer frame time
The frame number of the referenced layer should be
reduced by the precomp start frame.
2023-08-17 15:53:12 +09:00
Mira Grudzinska
b9c71b4e0f common: log msg++ 2023-08-16 00:36:42 +09:00
Hermet Park
5778bda4db loader/lottie: do not build layers if the frame is out. 2023-08-15 15:49:10 +09:00
Hermet Park
86aabb4df0 loader lottie: image optimization
In every frame, the image undergoes a Colorspace conversion attempt.

This approach aims to bypass the step by retaining the pre-converted image data.

I acknowledge that this might not be the best approach,
but it is proving to be quite effective at the moment.
2023-08-15 15:49:05 +09:00
Hermet Park
765b02b49d renderer/transform: removing unnecessary initialization logic
The matrix initialization logic described here does not occur frequently.
It does not warrant investing extra time in comparing the transform values.
2023-08-15 15:48:59 +09:00
Hermet Park
df43f91644 loader/lottie: optimize the header task.
To achieve full threading efficiency,
the header should return the necessary properties:
view size, framerate, and duration.

This commit adds duration parsing.

Also don't do the header task in case of single thread
because there wouldn't be parallel effects.
2023-08-15 15:48:53 +09:00
Hermet Park
9e0a3aa678 loader lottie: tiny data copy optimization.
This patch tries to skip the matrix data copy as possible.
2023-08-15 15:48:48 +09:00
RuiwenTang
8212d6f0f9 gl_engine: refactor matrix calculation
1. convert mat4 directly from exist mat3, and remove unused calculation
   code.
2. since normalized position is only meaningful in vertex shader stage.
   use logical position in fragment shader stage for all gradient
   pipeline.
2023-08-14 23:59:26 +09:00
Mira Grudzinska
b5aa6e42be svg_loader: clips with multiple transf shapes/use nodes
Up until now, loading a clip composed of multiple
shapes worked correctly provided that they did not
undergo separate transformations. Now, such a case
has been handled.
Also the 'use' node inside the clip is supported.
2023-08-11 23:16:46 +09:00
RuiwenTang
acd51a3aa0 gl_engine: use modern glsl syntax in shader source
Upgrade the used glsl version in GL shader source.

  New version can directly specify the attribute location in
  shader and the uniform block is only available in new glsl version
2023-08-11 23:14:21 +09:00
Hermet Park
80ce345660 loader\lottie: Fixed incorrect b64 decoding
Image padding size should be increased by 1 for '\0'."
2023-08-11 22:57:16 +09:00
Hermet Park
3601d3db3a loader/png: revert force colorspace conversion.
We have a base color space conversion in the renderer,
so there's no need to forcefully align with BGRA.
2023-08-11 22:57:08 +09:00
Hermet Park
7057dc594d renderer: enhance stability
introduce a paint reference count
to prevent any duplicated resource removal.
2023-08-11 15:00:09 +09:00
Hermet Park
6a59e1b715 loader: avoid attempting forceful loading when the given MIME type is not correct.
Loading images when the MIME type is incorrect is unnecessary
and often results in failure, adding unnecessary processing overhead.

Pictures should have a clear MIME type assigned by users.
2023-08-11 15:00:09 +09:00
Hermet Park
374a125280 loader/lottie: enhance stability
Addressed corner cases to prevent memory violations.
2023-08-11 15:00:09 +09:00
Hermet Park
1b020f70c4 loader lottie: support for stroke dash style
However, dash offset is still missing.
The TVG canvas needs to add the stroke offset feature.
2023-08-11 11:41:28 +09:00
RuiwenTang
9960cc4794 gl_engine: use vertex array buffer and index buffer when render primitive
VAO is new object in modern GL API, which can split and manage vertex
buffer and attribute state. This is optional in GLES and is mandatory in
GL.

Also index buffer is faster then pass cpu data in GL draw call.
2023-08-11 11:39:54 +09:00
RuiwenTang
7a35ff4d4b gl_engine: upgrade min gl version
most device supported morden gl which is:
GLES 3.0 for mobile GPU
GL 3.3 for desktop GPU
2023-08-09 23:23:57 +09:00
Hermet Park
345ef54e26 loader/lottie: add the rounded corner feature
The rounded rectangle property should be propagated to the root
through the lottie model scene-tree.
2023-08-09 21:30:25 +09:00
Hermet Park
8f4f3d6f1b loader/lottie: Add radial gradient support
This allows for the creation of basic radial gradients,
without support for focal points.
2023-08-09 21:30:25 +09:00
Hermet Park
d7c70c5371 loader/lottie: fix a missing layer timeremap.
The frame count should have been multiplied with the timeStretch property.
also newly implemented the TimeRemap(tm) property
2023-08-09 21:30:25 +09:00
Hermet Park
6f8504d3b9 loader/lottie: ++safety
- add an execeptional hanlding at parsing the assets.
- The precomp layer failed to prepare its instance in the parsing stage. This corrects the mistake.
2023-08-09 21:30:25 +09:00
RuiwenTang
9db9e003ba common: add new method to get mat4x4 directly from mat3x3
The 3x3 matrix already contains the geometric transformation
information required for 2D rendering.

We can directly convert from the 3x3 matrix to
the 4x4 matrix to facilitate subsequent GPU rendering.
2023-08-09 11:09:41 +09:00