JunsuChoi
dea08681c0
loader/svg: Support hsl color format
...
Support parsing of hsl(hue, saturation, brightness) color type
and conversion to rgb color.
2024-04-02 22:59:13 +09:00
JunsuChoi
fdebb15dcb
loader/svg: Check whether href id of use is parent or not
...
When finding the 'nodeFrom' referenced by `<use>`,
if it is the parent, it is not referenced.
https://www.w3.org/TR/SVG2/struct.html#UseElement
Specification:
If the referenced element is a (shadow-including) ancestor
of the ‘use’ element, then this is an invalid circular reference
and the ‘use’ element is in error.
related issue: https://github.com/thorvg/thorvg/issues/2078
SVG_FILE_65171.svg
SVG_FILE_65172.svg
2024-03-28 22:53:57 +09:00
JunsuChoi
46448a1520
loader/svg: Do recalc after gradient inheritance
...
Inherit gradientUnits and recalculate each element
radial(cx, cy, r,...), linear(x1, y1, x2, y2).
related issue: https://github.com/thorvg/thorvg/issues/2078
2024-03-28 22:52:45 +09:00
Vincent Torri
2ec9fdb932
[common] code clean up
...
use fmodf() instead of fmod()
2024-03-23 11:45:11 +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
JunsuChoi
c9e4feb9dc
loader/svg: Remove duplicate if-check in pathAppendArcTo
...
The if-check to skip-rule when drawing an arc path is already checked in line 476.
In addition, since the float type equal check is performed in the range of 1/256,
unintentional skiped may occur. Therefore, remove duplicate code.
https://www.w3.org/TR/SVG2/paths.html#ArcOutOfRangeParameters
test file: SVG_FILE_147893.svg
related issue: https://github.com/thorvg/thorvg/issues/1255
2024-03-20 11:33:12 +09:00
JunsuChoi
d32c90cbbf
svg: Improve valid check for url(#id)
...
Improve parenthesis checking and space checking.
- There must be only one pair of parentheses.
- There cannot be spaces(and ') between id strings.
Issue: https://github.com/thorvg/thorvg/issues/1983
Co-authored-by: Hermet Park <hermet@lottiefiles.com>
2024-02-22 21:51:19 +09:00
Hermet Park
043b6b9f4f
common/array: code refactoring
...
Make the array interface pair begin()/end() for consistency.
2024-02-19 19:09:30 +09:00
JunsuChoi
53e2ecd81c
loader/svg: Fix empty id to null
...
empty id is invalid. Therefore, set it to null and make it is not used.
issue: https://github.com/thorvg/thorvg/issues/1977
2024-02-15 10:29:13 +09:00
JunsuChoi
b55c1415c0
loader/svg: Fix zero check of arc's rx and ry
...
Please refer to the specifications.
https://www.w3.org/TR/SVG/paths.html#ArcOutOfRangeParameters
If either rx or ry is 0, then this arc is treated as a straight line
segment(a "lineto") joining the endpoints.
2024-01-29 09:54:03 +02:00
JunsuChoi
6015e2eb32
loader/svg: Apply specification of out-of-range elliptical arc parameters
...
The three specifications below apply.
Specification: https://www.w3.org/TR/SVG/paths.html#ArcOutOfRangeParameters
-
If the endpoint (x, y) of the segment is identical to the current point
(e.g., the endpoint of the previous segment),
then this is equivalent to omitting the elliptical arc segment entirely.
-
If either rx or ry is 0, then this arc is treated
as a straight line segment(a "lineto") joining the endpoints.
-
If either rx or ry have negative signs, these are dropped;
the absolute value is used instead.
2024-01-29 09:54:03 +02:00
Hermet Park
67d8d9f36c
svg_loader: code refactoring
...
removed duplicate matrix multiply function.
2024-01-22 19:03:59 +09:00
Mew Pur Pur
de00104566
svg_loader: Add missing implementation of skewX and skewY in transform-list
2024-01-22 18:52:37 +09:00
Hermet Park
0eafcfd1b0
loader: code refactoring
...
Ensure scene data is freed when it's dangled in the loader.
2024-01-11 10:12:04 +09:00
JunsuChoi
02ae718277
loader/svg: Skip check for quotes inside quotes
...
Single or double quotation marks that occur before
closing the quotation mark are ignored.
2024-01-08 22:26:02 +09:00
Hermet Park
fbcfb3f865
svg: ensure that all allocated memory.
...
observed a memory leak at a corner case.
2023-12-31 10:45:26 +09:00
Hermet Park
415276ae1c
Revert "svg: removed an unnecessary nested scene."
...
A regression bug is occured.
clipper is also required to be transformed with loader->resize()...
This reverts commit e62a8668e7
.
2023-12-28 18:46:42 +09:00
Hermet Park
e62a8668e7
svg: removed an unnecessary nested scene.
2023-12-28 18:06:33 +09:00
Jinny You
2c6c8d3b21
updated copyright date ( #1866 )
2023-12-28 10:43:25 +09:00
Hermet Park
bd37e8ba37
common: Revise internal loader interfaces.
...
We are introducing the FontLoader, which slightly differs
from the ImageLoader in terms of features. To adequately
support both, we have separated the loader functionalities
into FontLoader and ImageLoader. This allows us to optimally
adapt the LoadModule for each case.
2023-12-25 12:40:12 +09:00
Hermet Park
40d46e9f8a
loader/svg: optimize the path conversion.
...
Push the path data into a given shape directly.
This will skip unnecessary memory copies.
Issue: https://github.com/thorvg/thorvg/issues/1848
2023-12-20 20:34:58 +09:00
JunsuChoi
6d9d051acf
loader/svg: Do not draw shapes with invalid path information
...
If appendPath() returns InvalidArguments(not Success)
,do not create a tvg::Shape.
2023-12-20 16:18:18 +09:00
Hermet Park
5643348472
common: clean up the code.
2023-12-14 15:59:38 +09:00
Hermet Park
a9d39eaf56
renderer/loader: optimization++
...
removed the internal unique_ptr usage to reduce the binary size(-553)
2023-12-08 23:35:19 +09:00
Hermet Park
ff6ea4b6c4
Loaders: Introduced a loader cache.
...
The loader cache is applied to conserve memory.
If the input data is already present in loaders,
the loader cache will promptly return the active loader.
This results in a lot of memory savings for the duplicated resources.
binary diff: -400 bytes
2023-11-23 18:21:28 +09:00
Hermet Park
f2c29063d2
api: updated the recent changed api again.
...
Reordered by the data packing size.
Also removed a wrong capi default parameter value.
Result Picture::load(const char* data, uint32_t size, const std::string& mimeType, bool copy = false, const std::string& rpath = "")
-> Result load(const char* data, uint32_t size, const std::string& mimeType, const std::string& rpath = "", bool copy = false)
Tvg_Result tvg_picture_load_data(Tvg_Paint* paint, const char *data, uint32_t size, const char *mimetype, bool copy, const char* resourcePath)
-> Tvg_Result tvg_picture_load_data(Tvg_Paint* paint, const char *data, uint32_t size, const char *mimetype, const char* resourcePath, bool copy);
2023-11-23 11:59:38 +09:00
Jinny You
132be91de4
lottie/loader: support external image from memeory lottie
...
I've added new parameter, const string& resourcePath, to load external image on lottie.
Result load(const char* data, uint32_t size, const string& mimeType, bool copy, const string& resourcePath)
Note: tvgLoadModule will have new overrided method `open`, not to effect to other changes except animation.
Issue: #1793
2023-11-22 18:04:35 +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
Martin Capitanio
133662c8e9
loader/svg: Fix maskContentUnits userSpaceOnUse/objectBoundingBox
...
Fixes #1694
2023-10-12 15:05:40 +09:00
Hermet Park
8aa12ca468
taskschduler: fix a regression deadlock issue
...
This fix introduces a workaround to enforce synchronous tasking on worker threads.
Sometimes, out of threads get stuck in a deadlock condition.
@Issue: https://github.com/thorvg/thorvg/issues/1636
2023-09-18 21:06:01 +09:00
Hermet Park
e0d1c947e6
infra: renamed the files for the consistency.
2023-09-04 17:26:43 +09:00
Mira Grudzinska
fd014df1a9
loader/svg: support the focal property in the radial gradient.
...
@Issue: https://github.com/thorvg/thorvg/issues/1555
2023-09-04 16:48:38 +09:00
Hermet Park
5a73bcaa8f
common/array: code refactoring
...
easy access to a specific data with a operator.
2023-08-29 12:28:38 +09:00
Hermet Park
7d797ee548
Yet we don't break apis, this patch reverts the next:
...
cb36c25aff
8c0fc2b25a
c1e4e0808a
Those reverted changes sholud be in the bucket, the next issue item:
@Issue: https://github.com/thorvg/thorvg/issues/1372
2023-08-24 01:00:57 +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
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
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
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
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
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
Mira Grudzinska
480917651a
utils: custom strtof and strndup moved into utils
...
The custom implementations of 'strtof' and 'strndup'
present in the svg loader have been moved into a new
'utils' directory (strToFloat and strDuplicate, respectively).
2023-08-05 11:49:36 +09:00
Mira Grudzinska
07c05b52dc
svg_loader: removed unused code
...
The custom strtof function is defined
in tvgSvgUtil.
2023-08-05 11:49:36 +09:00
Mira Grudzinska
afee0441f6
svg_loader: removed unnecessary header
2023-08-01 14:53:36 +02:00
Mira Grudzinska
4f9f125454
svg_loader: update style in defs
...
In the defs node the style was not updated, hence
the inheritance wasn't applied causing wrong results.
2023-07-28 12:11:24 +09:00
Mira Grudzinska
b0e41b2b9f
svg_loader: support the '!important' directive
...
The directive is used to give a specific style property
higher priority, ensuring that it overrides other style
declarations for the same property.
@Issue: https://github.com/thorvg/thorvg/issues/1255
2023-07-27 11:51:45 +09:00
Hermet Park
60f81b7da7
loader lottie: added empty interface body
...
This marks the first step towards implementing the Lottie feature.
2023-07-27 00:31:27 +09:00