Commit graph

24 commits

Author SHA1 Message Date
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
94f304275e renderer: minor optimization
reduce the path flag writing
2024-06-23 18:17:14 +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
Mira Grudzinska
8c4879f15d 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-05-08 22:08:36 +09:00
Hermet Park
be7437e0a3 common: code refactoring
introduced mathDeg2Rad() and mathRad2Deg() for a common implementation.
2024-04-15 20:35:33 +09:00
vtorri
04977c43f1
[common] code clean up
use MATH_PI and MATH_PI2 instead of M_PI and M_PI_2
2024-03-22 23:48:25 +09:00
Hermet Park
103252642e lottie: code refactoring.
Maintains compact lines of code and functions without altering logic,
consistently prioritizing simplicity in software complexity metrics.
2024-03-03 14:04:34 +09:00
Mira Grudzinska
0c602291cb common: Changing the rounded rect starting point
According to the SVG standard, drawing a rectangle
starts at (x+rx, y) point. Till now it was (x+w, y+ry).
The difference was visible only for dashed strokes.
2024-03-03 12:54:56 +09:00
Mira Grudzinska
6ec88ed486 common: Changing the circle/ellipse starting point
According to the SVG standard, drawing a circle/ellipse
should start at the '3 o'clock' position and proceed
in a clock-wise direction. Until now, this point was
set at '12 o'clock'.
The differences in the outcome were visible for dashed
strokes.

issue: https://github.com/thorvg/thorvg/issues/1686
2024-03-03 12:53:10 +09:00
Hermet Park
2f7bfb6c8c renderer/shape: rectified the round rectangle start position.
adjusted the starting position of the rounded rectangle to 90 degrees
to ensure compatibility with the Lottie trim path effect.

This modification follows the earlier circle correction applied to the rectangle.

issue: https://github.com/thorvg/thorvg/issues/1933
2024-01-24 13:24:32 +09:00
Hermet Park
7389593235 renderer/shape: fixed a regression bug
the bug was introduced in 9bf8bb018d.

Migrated the circle commands to the rectangle, which is currently necessary.
Retained the previous circle commands for backward compatibility.
2024-01-13 12:25:02 +09:00
Hermet Park
9bf8bb018d renderer/shape: refine the circle draw commands.
Adjusted the path's start point to 90 degrees
to align the origin consistently with other path commands.

No compatibility issue, this only could affect the trimpath effects.
2024-01-12 10:57:46 +09:00
Jinny You
2c6c8d3b21
updated copyright date (#1866) 2023-12-28 10:43:25 +09:00
Hermet Park
273850a972 renderer/shape: Apply the magic number kappa to achieve rounded corners.
The magic number kappa (0.552284), which is associated with the bezier curve,
has been introduced. This formula is supposed to be applied to the rounded corners
of the rectangle to ensure consistent drawing results.

Issue: https://github.com/thorvg/thorvg/issues/1824
2023-12-11 09:14:46 +09:00
Mira Grudzinska
25a1321243 common: stroke dash offset support with new apis.
This change just allows users to use the offset of the stroke dash.
Actually feature enhacement has been introduced by
478e45f9f3.

@APIs:
uint32_t Shape::strokeDash(const float** dashPattern) ->
uint32_t Shape::strokeDash(const float** dashPattern, float* offset = nullptr)

Result Shape::strokeDash(const float* dashPattern, uint32_t cnt) ->
Result Shape::strokeDash(const float* dashPattern, uint32_t cnt, float offset = 0.0f)

Tvg_Result tvg_shape_set_stroke_dash(Tvg_Paint* paint, const float* dashPattern, uint32_t cnt) ->
Tvg_Result tvg_shape_set_stroke_dash(Tvg_Paint* paint, const float* dashPattern, uint32_t cnt, float offset)

Tvg_Result tvg_shape_get_stroke_dash(const Tvg_Paint* paint, const float** dashPattern, uint32_t* cnt) ->
Tvg_Result tvg_shape_get_stroke_dash(const Tvg_Paint* paint, const float** dashPattern, uint32_t* cnt, float* offset)

@Issue: https://github.com/thorvg/thorvg/issues/1372
2023-10-30 11:47:51 +09:00
Hermet Park
db55481e97 renamed stroke apis family.
float Shape::stroke(float width) -> float Shape::strokeWidth(float width)
Result Shape::stroke(uint8_t r, uint8_t g, uint8_t b, uint8_t a = 255) -> Result Shape::strokeFill(uint8_t r, uint8_t g, uint8_t b, uint8_t a = 255)
Result Shape::stroke(std::unique_ptr<Fill> f) -> Result Shape::strokeFill(std::unique_ptr<Fill> f)
Result Shape::stroke(const float* dashPattern, uint32_t cnt, float offset = 0.0f) ->  Result Shape::strokeDash(const float* dashPattern, uint32_t cnt, float offset = 0.0f)
Result Shape::stroke(StrokeCap cap) -> Result Shape::strokeCap(StrokeCap cap)
Result Shape::stroke(StrokeJoin join) -> Result Shape::strokeJoin(StrokeJoin join)
Result Shape::strokeColor(uint8_t* r, uint8_t* g, uint8_t* b, uint8_t* a = nullptr) const -> Result Shape::strokeFill(uint8_t* r, uint8_t* g, uint8_t* b, uint8_t* a = nullptr) const

@Issue: https://github.com/thorvg/thorvg/issues/1372
2023-10-27 11:46:51 +09:00
Hermet Park
989b995189 renderer: revise the internal paints structure.
Get rid of the polymorphism function table,
use the switch directly instead.

We profiled, both binary & performance is better than before.

Tested on a local machine (single thread):
- Lottie: 2ms improved
- Binary: -0.5kb
2023-10-27 11:24:44 +09:00
Hermet Park
b2499739ee renderer/shape: enable returning count values only 2023-10-26 13:02:54 +09:00
Hermet Park
6e3674b904 canvas/paint: ++exception handling
enhanced reference count verification
to prevent unintentional deletion of used composition targets.
2023-10-26 11:22:39 +09:00
Hermet Park
64a444aeb6 loader/lottie: support focal property in the radial gradient 2023-09-05 10:29:12 +09:00
Hermet Park
e0d1c947e6 infra: renamed the files for the consistency. 2023-09-04 17:26:43 +09:00
Hermet Park
24711e485c infra: renames the source folders
lib -> renderer
bin -> tools
utils -> common
2023-08-28 13:11:24 +09:00
Renamed from src/lib/tvgShape.cpp (Browse further)