Commit graph

297 commits

Author SHA1 Message Date
Hermet Park
f5337015e9 renderer: text refactoring
- assign the shape instance as mandatory.
- assign the text instance internally.
2024-08-23 10:45:55 +09:00
Hermet Park
8ca5e74902 api: corrected wrong const specifier
Setter obvisouly modifies the instance.
2024-08-23 10:45:49 +09:00
Mira Grudzinska
2447e02932 docs: description++ 2024-08-23 10:45:39 +09:00
Hermet Park
7a37735110 doc: ++enhancement in Picture::load()
addressed supported raw data format.

issue: https://github.com/thorvg/thorvg/issues/2648
2024-08-23 10:45:29 +09:00
Hermet Park
65c808fc02 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-23 10:45:14 +09:00
Elliott Sales de Andrade
eb462c6e32 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-23 10:35:35 +09:00
Hermet Park
82563bf29a doc: hotfix 2024-08-20 11:50:29 +09:00
Hermet Park
8927294374 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-15 23:18:39 +09:00
Hermet Park
6ef1986fe1 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-09 11:33:38 +09:00
Hermet Park
7ec8d2f392 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-09 11:33:38 +09:00
Hermet Park
e9b69cb7eb 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-09 11:33:38 +09:00
Hermet Park
e082602064 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-09 11:33:38 +09:00
Hermet Park
7afe90ce8e 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-09 11:33:38 +09:00
Hermet Park
b20d5da552 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-09 11:33:38 +09:00
Mira Grudzinska
5ff9c08ba9 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-09 11:33:38 +09:00
Mira Grudzinska
1ef9c6be9b 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-08-09 11:33:38 +09:00
Hermet Park
57e0d5b448 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-26 11:37:16 +09:00
Mira Grudzinska
b876402311 common: version api introduced
@Issue: https://github.com/thorvg/thorvg/issues/2543
2024-07-19 08:42:02 +09:00
Hermet Park
e12a244b9e 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-12 11:01:01 +09:00
Hermet Park
7299295f05 api: ++description
issue: https://github.com/thorvg/thorvg/issues/2494
2024-07-05 10:55:26 +09:00
Hermet Park
b6597fc1ef apis: promotes to official apis.
C++
- GlCanvas::gen()

CAPI
- TVG_COMPOSITE_METHOD_INVERSE_LUMA_MASK
2024-06-27 14:42:27 +09:00
Hermet Park
8259bb9d4e 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-27 14:42:27 +09:00
Mira Grudzinska
01b99f1cf5 docs: add missing args description 2024-06-27 14:42:27 +09:00
Hermet Park
4b01c0ef52 renderer/canvas: ++exceptional handling.
do not allow change the target if the condition is not satisfied.
2024-06-27 14:42:27 +09:00
Mira Grudzinska
33640eae83 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-24 14:52:27 +09:00
Hermet Park
41ffcf2bdf doc: updated the WgCanvas api doc 2024-06-24 14:50:34 +09:00
Sergii Liebodkin
47b9866f8b 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-24 14:50:28 +09:00
Mira Grudzinska
ec77d8bd89 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-24 14:50:13 +09:00
Mira Grudzinska
733f0996d8 docs: resolve doxygen warnings 2024-06-24 14:43:48 +09:00
Hermet Park
d5f41c85d3 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-24 14:42:46 +09:00
Mira Grudzinska
61de65e10b 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-24 14:42:12 +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
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
827a00b076 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-06-24 14:12:00 +09:00
Hermet Park
b615348df1 doc: adds the api version history 2024-06-24 12:29:36 +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
Hermet Park
ca7aec5fff 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-06-24 11:58:48 +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
Hermet Park
04b5525db4 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-04-06 12:08:23 +09:00
Hermet Park
5d10e514d7 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-04-06 12:08:21 +09:00
Hermet Park
fa393f1c52 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-04-06 12:08:21 +09:00
Hermet Park
9ef2288ae7 api: promote to official APIs.
New API:
- SwCanvas::Colorspace::ABGR8888S
- SwCanvas::ColorSpace::ARGB8888S
2024-01-02 20:34:11 +09:00
Hermet Park
0553729818 doc: remove unnecessary doxy guide. 2024-01-02 20:34:11 +09:00
Hermet Park
54528b6ac9 renderer: introduce a ThorVG Text interface.
Introduced New APIs under the experimental tags.

- Result Text::font(const char* name, float size, const char* style = nullptr);
- Result Text::text(const char* text);
- Result Text::fill(uint8_t r, uint8_t g, uint8_t b);
- static Result Text::load(const std::string& path);
- static Result Text::unload(const std::string& path);
- static Text::std::unique_ptr<Text> gen();
- static Text::uint32_t identifier()

@Issue: https://github.com/thorvg/thorvg/issues/969
2024-01-02 20:34:11 +09:00
Hermet Park
83e3cb24ff doc: polish up the doxygen.
- applied @retval for those const values.
- applied @return for return value description.
2024-01-02 20:34:11 +09:00
Hermet Park
27843d2557 savers: provides a background setting.
Allow users to set a custom background with a saver.

API:
- Result Saver::background(std::unique_ptr<Paint> paint);
2023-12-26 18:30:06 +09:00
Hermet Park
a37649cd1f doc: make it up missing parameter information. 2023-12-26 18:21:01 +09:00
Hermet Park
2c382e3d9b doc: keep the style clean & neat 2023-12-26 18:17:41 +09:00
Jinny You
059a950d42 docs: Remove all warnings from doxygen 2023-12-26 18:17:41 +09:00