Commit graph

257 commits

Author SHA1 Message Date
Mira Grudzinska
1b391180c7 svg_loader: copy display property
The display property was not copied along with other
node properties. This caused incorrect rendering
of an object with display=none if accessed through
a use tag.
2024-04-26 11:15:02 +09:00
Mira Grudzinska
abb10afc88 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-26 11:14:55 +09:00
JunsuChoi
730a88c42b 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-19 11:00:29 +09:00
Hermet Park
8502b41b99 common: code refactoring
introduced mathDeg2Rad() and mathRad2Deg() for a common implementation.
2024-04-19 11:00:29 +09:00
Hermet Park
d4258c93ad svg: code refactoring
-- compiler warnings on msvc
2024-04-08 17:26:59 +09:00
JunsuChoi
349fd266b9 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-06 12:48:30 +09:00
JunsuChoi
0c6395cbea loader/svg: Support hsl color format
Support parsing of hsl(hue, saturation, brightness) color type
and conversion to rgb color.
2024-04-06 12:48:30 +09:00
JunsuChoi
f0527a2304 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-04-06 12:08:23 +09:00
JunsuChoi
b408178ca6 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-04-06 12:08:23 +09:00
Vincent Torri
2f196b514f [common] code clean up
use fmodf() instead of fmod()
2024-04-06 12:08:23 +09:00
vtorri
3640724b99 [common] code clean up
use MATH_PI and MATH_PI2 instead of M_PI and M_PI_2
2024-04-06 12:08:23 +09:00
JunsuChoi
c6cf9cb2cf 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-04-06 12:08:21 +09:00
Hermet Park
b0540929e5 common/array: code refactoring
Make the array interface pair begin()/end() for consistency.
2024-04-06 12:08:21 +09:00
JunsuChoi
b400512fda 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-04-06 12:08:21 +09:00
Hermet Park
9972fa9831 svg_loader: code refactoring
removed duplicate matrix multiply function.
2024-04-05 17:37:39 +09:00
Mew Pur Pur
d23e0fd22c svg_loader: Add missing implementation of skewX and skewY in transform-list 2024-04-05 17:37:33 +09:00
Hermet Park
a078f14bb3 loader: code refactoring
Ensure scene data is freed when it's dangled in the loader.
2024-04-05 17:21:18 +09:00
Hermet Park
ab744fc164 svg: ensure that all allocated memory.
observed a memory leak at a corner case.
2024-01-02 20:34:12 +09:00
Jinny You
92288c8291 updated copyright date (#1866) 2024-01-02 20:34:12 +09:00
Hermet Park
49d26691e5 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.
2024-01-02 20:34:11 +09:00
Hermet Park
c0a1f82033 renderer/loader: optimization++
removed the internal unique_ptr usage to reduce the binary size(-553)
2024-01-02 20:34:10 +09:00
Hermet Park
f64ee28079 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
2024-01-02 20:34:10 +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
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
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
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
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
Mira Grudzinska
de41853bcf svg_loader: custom strndup moved into utils
The custom _strndup was used only in one file
as an internal function and wasn't accessible
in other parts of the code. Now function
is available as svgUtilStrndup.
2023-07-26 00:21:56 +09:00
Hermet Park
a1f0b06f41 common array: revise code.
maintain code with an optimial size.
2023-07-25 19:57:12 +09:00
Hermet Park
accb8c5699 svg loader: --compiler warnings
../src/loaders/svg/tvgSvgLoader.cpp: In function ‘void _copyAttr(SvgNode*, const SvgNode*)’:
../src/loaders/svg/tvgSvgLoader.cpp:2911:44: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
 2911 |             if (to->node.polygon.pts.count = from->node.polygon.pts.count) {
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/loaders/svg/tvgSvgLoader.cpp:2917:45: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
 2917 |             if (to->node.polyline.pts.count = from->node.polyline.pts.count) {
2023-07-04 01:17:25 +09:00
Hermet Park
d72d6aa51f loader svg: code cleanup
Use array instead of individual dynamic array implementation.
This also fixes wrong polygon & polyline data access during copy & paste...
2023-07-04 01:09:23 +09:00
Martin Capitanio
44a750ee5d API, CAPI, sw_engine: add suport for stroke-miterlimit. 2023-06-13 10:42:20 +09:00
Hermet Park
f2fdc380b4 fix compiler warnings on MacOS
warning: unqualified call to 'std::move' [-Wunqualified-std-cast-call]
2023-05-19 10:56:59 +09:00
Mira Grudzinska
2cfa5505c3 svg_loader: fixing finding defs node
In the case when a 'use' node was used
in a 'defs' block  and the element it
referenced was also defined within the same
'defs' block, the reference node could not
be cloned. This was because the 'defs' node
could not be located.

@Issue: https://github.com/thorvg/thorvg/issues/1451
2023-05-16 10:43:45 +09:00
Mira Grudzinska
40ef9031ba svg_loader: copy the use node properties
A bug was observed when a 'use' node was
referenced in another 'use' node.

@Issue: https://github.com/thorvg/thorvg/issues/1451
2023-05-16 10:42:35 +09:00
Mira Grudzinska
4599067bee svg_loader: fixing percent. calculations of width/height
The conversion to percentages was applied twice.
Additionally, when a viewbox value was provided before the width/height,
incorrect scaling occurred.

@Issue: https://github.com/thorvg/thorvg/issues/1414
2023-05-04 09:52:55 +09:00
Hermet Park
9a9c0e7907 svg_loader: code refactoring.
simplify the logic and remove unnecessary member data.
2023-05-03 22:08:16 +09:00
Hermet Park
f82c274444 svg_loader: fix memory violation.
LoadModule data is designed to be returned to the user's call.
and should not be writable in Task::run()

@Issue: https://github.com/thorvg/thorvg/issues/1409
2023-05-03 22:08:16 +09:00
Mira Grudzinska
92346c4119 svg_loader: handling svg width/height in percentages
The percentages should refer to the size of the viewbox.
This was not the case for not knowing the viewbox before
reading the width/height.

@Issue: https://github.com/thorvg/thorvg/issues/1409
2023-05-03 20:35:08 +09:00
Hermet Park
1e370712e0 loader svg: ++code readability
Use own bit operation helpers.
2023-04-26 11:15:48 +09:00
Mira Grudzinska
83ffe9f612 svg_loader: fixing grad overwritting
Gradient was mistakenly overwritten in
files in which the <def> section existed,
but grad was defined outside it.
2023-04-25 14:30:23 +09:00
Mira Grudzinska
74c9a5f795 svg_loader: changed update order
The gradient was updated before the style,
which resulted in only the URL tag being
inherited, but the gradient itself was not
applied to the node.
2023-04-25 09:01:19 +09:00
Mira Grudzinska
219e23855f svg_loader: paint-order attrib handled
@Issue: https://github.com/thorvg/thorvg/issues/1340
2023-04-18 22:21:55 +09:00
Mira Grudzinska
f089b77a45 svg_loader: fixing parsing empty elements
Self-closing tags (empty elements) were parsed until
the appearance of the '>' character, causing the '/'
char to be appended to the tag name. The final '/'
char should be omitted.
2023-04-17 09:57:52 +09:00
Mira Grudzinska
598c28a597 svg_loader: gradient inheritance implemented
Till now only the grad stops were inherited. Now all
grad attribs are.
Inheritance from different grad type is not supported.

@Issue: https://github.com/thorvg/thorvg/issues/1209
2023-04-15 17:43:42 +09:00