Commit graph

364 commits

Author SHA1 Message Date
Hermet Park
dd6ad0fc6e api: clean form++ 2024-09-06 14:32:02 +09:00
Sergii Liebodkin
e2e4fc6964
wg_engine: external device handles (web integration)
move instance, adapter and device creation from renderer to application
its necessary for web integration, because browser have its own mechanics to create hardware handles
this changes makes webgpu canvas more universal to use in case of system and web applications

issue: https://github.com/thorvg/thorvg/issues/2410
2024-09-06 13:08:58 +09:00
Hermet Park
71d3fce1dd renderer: text refactoring
- assign the shape instance as mandatory.
- assign the text instance internally.
2024-08-21 14:51:53 +09:00
Hermet Park
c75311d239 api: corrected wrong const specifier
Setter obvisouly modifies the instance.
2024-08-21 14:50:40 +09:00
Mira Grudzinska
5448b1b9cd docs: description++ 2024-08-20 18:44:39 +09:00
Hermet Park
8598348ec0 doc: ++enhancement in Picture::load()
addressed supported raw data format.

issue: https://github.com/thorvg/thorvg/issues/2648
2024-08-20 11:53:40 +09:00
Hermet Park
5332876fe8 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-20 11:14:54 +09:00
Elliott Sales de Andrade
966aeb5ee3 build: Override dependency for use as subproject
A pkgconfig file is already provided, which enables using `thorvg` once
it is installed. However, this file is not, and cannot be, available at
setup time if using `thorvg` as a subproject.

In such cases, Meson provides the `override_dependency` mechanism for a
subproject to tell its parent how to use it.
2024-08-19 17:42:06 +09:00
Mira Grudzinska
f79558eb62 API: deprecate the appendArc() api
@Issue: https://github.com/thorvg/thorvg/issues/2632
2024-08-16 13:30:58 +09:00
Hermet Park
407fc84796 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-13 10:21:54 +09:00
Hermet Park
43c87b4eb5 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-07 12:02:22 +09:00
Hermet Park
ee3293401b 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-07 12:02:22 +09:00
Hermet Park
ed9eee897a 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-07 12:02:22 +09:00
Hermet Park
45352c9a1f API: introduce a Paint ID member as a reserved field
The "id" is a reserved field to specify a paint instance in a scene.
in this change, it assigns the layer id to the lottie scene as well.
2024-08-07 12:02:22 +09:00
Hermet Park
d62b913455 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-07 12:02:22 +09:00
Hermet Park
49f3395631 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-07 11:04:38 +09:00
Mira Grudzinska
58797ffafd 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-01 14:25:29 +09:00
Mira Grudzinska
7c87d8e632 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-07-31 14:32:04 +02:00
Hermet Park
b388bf06d5 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-25 20:12:32 +09:00
Mira Grudzinska
17e0bcd332 common: version api introduced
@Issue: https://github.com/thorvg/thorvg/issues/2543
2024-07-18 12:47:58 +09:00
Hermet Park
eb86ac539c 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-07 21:43:30 +09:00
Hermet Park
889d1d1fa2 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-07-05 21:25:58 +09:00
Hermet Park
e4c4a95495 api: ++description
issue: https://github.com/thorvg/thorvg/issues/2494
2024-07-02 18:21:11 +09:00
Josh Soref
e061fa6628
common: fix 178+ spelling errors 2024-07-01 21:58:46 +09:00
Hermet Park
d6e64c0619 doc: polishing++ 2024-06-28 16:14:57 +09:00
Hermet Park
1ad00f987c apis: promotes to official apis.
C++
- GlCanvas::gen()

CAPI
- TVG_COMPOSITE_METHOD_INVERSE_LUMA_MASK
2024-06-26 15:16:26 +09:00
Hermet Park
a7c7539674 doc: removed useless information for easier maintainence.
That basic information is addressed in the Results section.
We can only add information that pertains to a specific scenario.
2024-06-25 11:11:33 +09:00
Mira Grudzinska
f202137acd docs: add missing args description 2024-06-24 21:41:12 +09:00
Hermet Park
9fb8a49d52 renderer/canvas: ++exceptional handling.
do not allow change the target if the condition is not satisfied.
2024-06-24 01:29:57 +09:00
Mira Grudzinska
e8b5062657 docs: descriptions++ 2024-06-20 23:12:34 +09:00
Mira Grudzinska
6544747e70 common: fix returned value
In the case of requesting to unload a font that
has not been previously loaded, InsufficientCondition
should be returned, not InvalidArgument.
2024-06-17 11:45:25 +09:00
Hermet Park
45bf996a19 doc: updated the WgCanvas api doc 2024-06-12 12:45:47 +09:00
Sergii Liebodkin
7e493f91f2
wg_engine: cross-platform support
it provide changes public API for webgpu canvas interface to provide nessessary handles to native window for different platforms:

API Change:
- Result target(void *instance, void *surface, uint32_t w, uint32_t h) noexcept;
2024-06-12 12:39:37 +09:00
Mira Grudzinska
d8a720fb7e ttf_loader: support loading from memory
New text API for loading fonts from memory
is introduced. This is necessary to enable
embedded fonts support.
2024-06-11 20:59:39 +09:00
Mira Grudzinska
10cdfff20d docs: resolve doxygen warnings 2024-06-09 12:01:54 +09:00
Hermet Park
ade5eb2e8d api: corrected return type.
NonSupport indicates unsupported options due to disabled features
or lack of system support. InvalidArgument indicates the case
such as incorrect parameter values.
2024-06-05 23:03:05 +09:00
Mira Grudzinska
91187cd963
common: clarification of returned types
The functions setting stroke's features always
returned a true. Returnig a boolen was a remnant
from a previous implementation. Since now they
never return false, they can be void functions.
The APIs description has been corrected.
2024-06-05 12:36:37 +09:00
Mira Grudzinska
33f5ea34c0 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-05 11:55:36 +09:00
Hermet Park
c784ed7362 renderer/canvas: tweak the viewport behavior.
reset the viewport context when target buffer is reset.
2024-05-20 14:44:15 +09:00
Hermet Park
42409987e2 renderer/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-05-18 18:10:50 +09:00
Hermet Park
38bd34b01f animation/lottie: improved the precision of frame values.
Refined the logic for updating frame numbers
to ensure greater accuracy in value precision.

issue: https://github.com/thorvg/thorvg/issues/2266
2024-05-14 15:28:48 +09:00
Hermet Park
7a9ba52d0c doc: adds the api version history 2024-04-30 14:32:07 +02:00
Lucas Niu
3af9faf116 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-04-14 23:54:26 +09:00
Hermet Park
50707482ba lottie: rectify the frame updates.
Currently, tvg ignores the frame value if the difference
is less than 0.001. In most cases, updating the frames
when the change is less than 1ms is just an unnecessary
burden on the system.

Instead, this ensures that the perfect last frame is reached.

issue: https://github.com/thorvg/thorvg/issues/2147
2024-04-11 10:54:02 +09:00
Hermet Park
1efb72ce94 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-05 01:11:14 +09:00
Hermet Park
d6504ed35d doc: List the parameters in their respective order. 2024-03-28 14:01:17 +09:00
Hermet Park
e4775727eb api: Promote experimental Animation APIs to official status.
These APIs have been thoroughly tested and verified.

New API:
- Result Animation::frame(float no)
- Picture* Animation::picture() const
- float Animation::curFrame() const
- float Animation::totalFrame() const
- float Animation::duration() const
- static Animation::std::unique_ptr<Animation> gen()

New CAPI:
- Tvg_Animation* tvg_animation_new()
- Tvg_Result tvg_animation_set_frame(Tvg_Animation* animation, float no)
- Tvg_Paint* tvg_animation_get_picture(Tvg_Animation* animation)
- Tvg_Result tvg_animation_get_frame(Tvg_Animation* animation, float* no)
- Tvg_Result tvg_animation_get_total_frame(Tvg_Animation* animation, float* cnt)
- Tvg_Result tvg_animation_get_duration(Tvg_Animation* animation, float* duration)
- Tvg_Result tvg_animation_del(Tvg_Animation* animation)

issue: https://github.com/thorvg/thorvg/issues/2067
2024-03-27 16:18:42 +09:00
Hermet Park
754a4aeaea renderer/gl_engine: Refine GlCanvas Interface
Refactor the GlCanvas::target() interface to allow
passing the drawing target ID from the user side.

Previously, it performed the drawing on the currently set FBO target.

Beta API change:

Result GlCanvas::target(uint32_t* buffer, uint32_t stride, uint32_t w, uint32_t h)
-> Result GlCanvas::target(int32_t id, uint32_t w, uint32_t h)
2024-03-13 10:13:02 +02:00
Hermet Park
1e4bf308da renderer/loader: revamping the caching mechanism.
The previous loader cache mechanism encountered a problem
when the user changed the content of the cached data.

In such cases, a new request would not be processed
because the renderer would use the previously cached content.

So far, the TVG cache mechanism utilizes a pointer hash key
for the fastest hashing mechanism available.
One limitation is that it assumes the address is unique for the data.

To resolve this, we modified the caching policy.
Now, the renderer will not cache copied data;
it will only cache the given data when it is deemed shareable.

issue: https://github.com/thorvg/thorvg/issues/2020
2024-03-06 14:34:58 +09:00
Hermet Park
1d9ea58be3 api: promote to official APIs.
New API:
- CanvasEngine::All
- SwCanvas::Colorspace::ABGR8888S
- SwCanvas::ColorSpace::ARGB8888S
2023-12-27 16:42:26 +09:00