Mira Grudzinska
8d81ad360f
svg_loader: correct polygon's points loading
...
Only an even number of correctly read points defining
a polygon should be loaded and passed on for rendering.
Any remaining points should be ignored.
2024-04-22 11:12:15 +09:00
Mira Grudzinska
2cb89c71a1
Revert "loader/svg: Skip to invalid polygon"
...
This reverts commit 75e587a9a9
.
If incorrect data for the points in a polygon is provided,
the element should still be rendered, but only up to the point
where the error occurs—using an even number of the points that
have been successfully loaded.
2024-04-22 11:12:15 +09:00
JunsuChoi
1bbf9bbb7d
loader/svg: Return actual decoded size
...
Returns the actual length of the decoded array.
related issue: https://github.com/thorvg/thorvg/issues/2156
2024-04-16 13:32:03 +02:00
JunsuChoi
66c43352ef
loader/svg: Add null to the end of data
...
Because memcpy() is not guaranteed to copy null at the end of the data array,
it increase the size by 1 and add null
This prevents invalid access of string functions in parser.
2024-04-16 10:27:20 +09:00
Hermet Park
be7437e0a3
common: code refactoring
...
introduced mathDeg2Rad() and mathRad2Deg() for a common implementation.
2024-04-15 20:35:33 +09:00
JunsuChoi
387d82a80e
loader/svg: Ignore unrecognized commands following 'z'
...
If the command after `m` is not recognized, it must be recognized as `l` or `L`.
However, if it is not recognized after ending with `z`, all commands after it are ignored.
```
<svg width="100" version="1.0" xmlns="http://www.w3.org/2000/svg " height="100" xmlns:xlink="http://www.w3.org/1999/xlink ">
<path style="stroke:#F00" d="m 20,20 0,50 50 0 -50 -50 z 70,70 0,50 50 0 -50 -50 z "/>
</svg>
```
2024-04-11 10:55:34 +09:00
JunsuChoi
75e587a9a9
loader/svg: Skip to invalid polygon
...
If a Polygon's points array is odd, it is not a valid shape.
2024-04-11 10:55:20 +09:00
Hermet Park
1c4b254015
svg: code refactoring
...
-- compiler warnings on msvc
2024-04-08 17:25:05 +09:00
JunsuChoi
a4ced1963e
loader/svg: Fix invalid syntax check
...
If the key is not parsed and the '=' keyword is located next,
modify it to parse the following syntax.
related issue:
https://github.com/thorvg/thorvg/issues/2116
2024-04-04 15:58:07 +09:00
JunsuChoi
79c65aa5e7
loader/svg: Check invalid color
...
Checks whether the string that can be specified in Color is valid.
example)
```
style="stroke:asdasd"
```
related issue: https://github.com/thorvg/thorvg/issues/1255
2024-04-03 11:38:49 +09:00
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