Hermet Park
6cbc1de570
api: enhance Shape::stroke() method usage.
...
Designate a default value for alpha which is mostly optional.
2023-06-07 12:10:31 +09:00
Hermet Park
1ae92daa9d
api: enhance Shape::fill() method usage.
...
Designate a default value for alpha which is mostly optional.
2023-06-07 12:10:31 +09:00
Hermet Park
5ceeb32ef0
api: remove a beta api.
...
- Result Picture::viewbox(float* x, float* y, float* w, float* h) const; //c++
- vg_Result tvg_picture_get_viewbox(const Tvg_Paint* paint, float* x, float* y, float* w, float* h); //c
@Issue: https://github.com/thorvg/thorvg/issues/1372
2023-05-20 13:22:52 +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
bf2b348343
svg_loader: removed unused code
...
While css styling applied one of conditions was
always false. It is now removed and the function
that was called is refactored
2023-04-25 14:30:40 +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
ef93a45d56
svg_loader: removing setting the locale
...
The locale was set while reading the path attr,
which could have caused race conditions between
threads and potentially led to crashes.
Now removed as unnecessary.
@Issue: https://github.com/thorvg/thorvg/issues/1389
2023-04-25 09:17:00 +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
b0991b6ce7
svg_loader: fixing 'infinity' handling in svgUtilStrtof
...
The word 'infinity' was not read to the end due to
the pointer shifting.
2023-04-24 10:47:17 +09:00
Mira Grudzinska
46147dcec7
svg_loader: fixing clipper transformation
...
In a case where both the clipper and the clippee
are transformed, the final clipper transformation
matrix should be calculated as the multiplication
of both matrices.
@Issue: https://github.com/thorvg/thorvg/issues/1255
2023-04-19 11:43:16 +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
e61857f27d
svg_loader: _applySvgViewFlag refactored
2023-04-17 21:43:36 +09:00
Mira Grudzinska
158e36f7c9
svg_loader: fix vx and vy
...
If no viewbox is given, vx and vy were set to values
corresponding to the svg's bounding box. This is now
applied only if no viewbox and no width/height information
is given. Otherwise, vx and vy are set to the default
values (0, 0).
@Issue: https://github.com/thorvg/thorvg/issues/1368
2023-04-17 21:43:36 +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
Mira Grudzinska
66ef84e7d7
svg_loader: code refactoring
...
Changed order of functions - needed in the grad
inheritance commit.
2023-04-15 17:43:42 +09:00
Mira Grudzinska
d60a7bec7e
svg_loader: fixing svgs without viewbox attr
...
For svgs without any viewbox and width/height
whole image is drawn. Before it was forced
to set x=y=0.
2023-04-03 12:39:43 +02:00
Mira Grudzinska
c7137a8105
svg_loader: forcing file loading completion
...
Svgs without any viewbox and width/height information
have to be loaded before any other action is taken.
This is necessary to get the valid sive/viewbox info.
2023-03-31 09:48:01 +02:00
Mira Grudzinska
d96b8f4385
svg_loader: invalid strokes' width set to zero
...
In case the "stroke" attrib is set to "none",
the width of the stroke is set to zero. Thanks
to that it isn't taken into account while
establishing the bounds of the shape.
2023-03-24 11:52:14 +09:00
Mira Grudzinska
be361221df
svg_loader: handling zero width/height viewbox
...
For svgs with the width and/or height value set to zero
rendering was disabled - the load api return Result:Unknown
and draw - Result::InsufficientCondition.
Now an empty scene is added, so that both, load and draw,
return Result::Success.
2023-03-21 11:11:45 +09:00
Mira Grudzinska
9e8980a1f7
svg_loader: handling svgs without viewBox/viewPort
...
Additionally:
- cases of inforrect viewBox values are handled
- cases of zero width/height of a viewBox and/or viewPort
@Issue: https://github.com/Samsung/thorvg/issues/1239
2023-03-21 11:11:45 +09:00
Hermet Park
cd68a783dd
svg loader: correct clipper usage.
...
that has been changed by 0de3872be3
2023-01-26 21:37:03 +09:00
Mira Grudzinska
b58c20b881
svg_loader: overwrite the clip's opacity/alpha
...
According to the svg standard the clips opacity
doesn't affect the final rendering. In order to
avoid any confusion the opacity values are
overwritten by the max possible value.
2023-01-19 23:07:50 +01:00
Hermet Park
9b3c34c3b1
updated copyright.
2023-01-14 13:48:11 +09:00
Mira Grudzinska
ae07b480d0
svg_loader: fixing crash for to big buffer
...
Crash observed on macOS for the image-embeded-*.svg files.
Since the alloca function was used the stack allocation failure
could not be handled.
2023-01-08 11:28:42 +09:00
Mira Grudzinska
df9a28bf0a
svg_loader: fixing name
...
_parserColor -> _parseColor
2023-01-07 10:52:56 +09:00
JunsuChoi
1769e1c4af
common Util: Move to before decimal part calculation
2022-12-14 10:42:27 +09:00
JunsuChoi
439c918553
common Util: Skip if there is a space after the dot
...
Some SVG parsers allow parsing of "0."
If there is a space after the dot, skip to the next step.
2022-12-14 10:42:27 +09:00
JunsuChoi
abb9df7c6b
svg_loader: Change SVG viewbox variable type from int to float
...
The viewbox and size(width, height) defined in SVG can be of type float.
This prevents matrix calculation errors caused by this.
2022-12-12 23:48:52 +09:00
Hermet Park
93b88370ad
svg loader: remove unused logic.
...
Please keep it simple and easy.
Don't leave a chance compiler warn it.
2022-09-02 12:02:39 +09:00
Mira Grudzinska
3939b61770
svg_loader: preserveAspectRatio attrib handled according to the svg standard ( #1249 )
...
* svg_loader: preserveAspectRatio attrib handled according to the svg standard
* svg_loader: symbol fixed
The correct width/height values used in the _useBuildHelper function.
Bug was propageted while the preserveAspectRatio attrib was handled,
now fixed.
* svg_loader: refactoring code regarding the preserveAspectRatio attrib
To avoid copy/paste a new function is introduced to handle the proper
scaling.
* svg_loader: initialize the svg loader members
The 'align' and 'meetOrSlice' svg loader members were not initialized.
* svg_loader: resize function forces any transformation
The resize function is called after the svg image is read and scaled
taking into account the proper preserveAspectRatio value. While resizing
the preserveAspectRatio isn't checked any more and the image can be
freely transformed.
2022-09-02 11:59:49 +09:00
Mira Grudzinska
c93c2d3100
svg_loader: deeper search for postponed nodes
...
Till now the proper node was searched only among children,
now all the nodes are checked.
2022-09-02 11:15:08 +09:00
Mira Grudzinska
313a4d1562
svg_loader: prevent stack-overflow for nested nodes
2022-09-02 11:13:45 +09:00
JunsuChoi
b7b8c2424c
svg_loader: No skip luma mask when composition node is image
...
Improved to skip Luma Mask when conditions are the same
as AlphaMask for optimization in e409bb29
.
If the composition node is an image, it is not skipped because
it is not known for sure whether to skip it.
2022-08-31 21:33:22 +02:00
Mira Grudzinska
be4f382d99
svg_loader: prevent mem leaks
...
A necessary check added before strdup function is called
2022-08-31 11:27:37 +09:00
JunsuChoi
b24e7c7402
svg_loader: Remove unnecessary code
2022-08-30 23:31:25 +02:00
JunsuChoi
eb936d1a81
svg_loader: If there is already set color url, it will be deleted.
...
When setting the url for color, if there is an already set url,
it will be overwritten after deletion. This prevents memory leaks.
asan result)
Direct leak of 2 byte(s) in 1 object(s) allocated from:
#0 0x7ff1d547bc68 in __interceptor_malloc (/usr/lib/x86_64-linux-gnu/libasan.so.5+0x10bc68)
#1 0x7ff1d4e435b4 in _idFromUrl ../src/loaders/svg/tvgSvgLoader.cpp:327
#2 0x7ff1d4e44a8e in _toColor ../src/loaders/svg/tvgSvgLoader.cpp:558
#3 0x7ff1d4e42ee9 in _parseStyleAttr ../src/loaders/svg/tvgSvgLoader.cpp:1033
#4 0x7ff1d4e7f092 in simpleXmlParseAttributes(char const*, unsigned int, bool (*)(void*, char const*, char const*), void const*) ../src/loaders/svg/tvgXmlParser.cpp:361
#5 0x7ff1d4e597d3 in _createPathNode ../src/loaders/svg/tvgSvgLoader.cpp:1363
#6 0x7ff1d4e61359 in _svgLoaderParserXmlOpen ../src/loaders/svg/tvgSvgLoader.cpp:2723
#7 0x7ff1d4e61c49 in _svgLoaderParser ../src/loaders/svg/tvgSvgLoader.cpp:2801
#8 0x7ff1d4e7f3f6 in simpleXmlParse(char const*, unsigned int, bool, bool (*)(void*, SimpleXMLType, char const*, unsigned int), void const*) ../src/loaders/svg/tvgXmlParser.cpp:429
#9 0x7ff1d4e639a1 in SvgLoader::run(unsigned int) ../src/loaders/svg/tvgSvgLoader.cpp:3121
#10 0x7ff1d4dc8b75 in tvg::Task::operator()(unsigned int) ../src/lib/tvgTaskScheduler.h:68
#11 0x7ff1d4dc8b75 in tvg::TaskSchedulerImpl::run(unsigned int) ../src/lib/tvgTaskScheduler.cpp:138
#12 0x7ff1d4dc98f7 in tvg::TaskSchedulerImpl::TaskSchedulerImpl(unsigned int)::{lambda()#1}::operator()() const ../src/lib/tvgTaskScheduler.cpp:113
#13 0x7ff1d4dc98f7 in void std::__invoke_impl<void, tvg::TaskSchedulerImpl::TaskSchedulerImpl(unsigned int)::{lambda()#1}>(std::__invoke_other, tvg::TaskSchedulerImpl::TaskSchedulerImpl(unsigned int)::{lambda()#1}&&) /usr/include/c++/9/bits/invoke.h:60
#14 0x7ff1d4dc98f7 in std::__invoke_result<tvg::TaskSchedulerImpl::TaskSchedulerImpl(unsigned int)::{lambda()#1}>::type std::__invoke<tvg::TaskSchedulerImpl::TaskSchedulerImpl(unsigned int)::{lambda()#1}>(std::__invoke_result&&, (tvg::TaskSchedulerImpl::TaskSchedulerImpl(unsigned int)::{lambda()#1}&&)...) /usr/include/c++/9/bits/invoke.h:95
#15 0x7ff1d4dc98f7 in void std:🧵 :_Invoker<std::tuple<tvg::TaskSchedulerImpl::TaskSchedulerImpl(unsigned int)::{lambda()#1}> >::_M_invoke<0ul>(std::_Index_tuple<0ul>) /usr/include/c++/9/thread:244
#16 0x7ff1d4dc98f7 in std:🧵 :_Invoker<std::tuple<tvg::TaskSchedulerImpl::TaskSchedulerImpl(unsigned int)::{lambda()#1}> >::operator()() /usr/include/c++/9/thread:251
#17 0x7ff1d4dc98f7 in std:🧵 :_State_impl<std:🧵 :_Invoker<std::tuple<tvg::TaskSchedulerImpl::TaskSchedulerImpl(unsigned int)::{lambda()#1}> > >::_M_run() /usr/include/c++/9/thread:195
#18 0x7ff1d3a344bf (/usr/lib/x86_64-linux-gnu/libstdc++.so.6+0xd44bf)
example)
<svg height="400" width="600" xmlns:xlink="http://www.w3.org/1999/xlink " xmlns="http://www.w3.org/2000/svg ">
<defs>
<radialGradient r="12" fy="10" fx="10" cy="10" cx="10" id="i" xlink:href="#d"/>
<clipPath id="g" clipPathUnits="userSpaceOnUse">
<path d="M0 10 10z" style="marker:none" fill="#fff" stroke-width="2"/>
</clipPath>
</defs>
<path d="M0 10 Z" fill="url(#g)" style="fill:url(#i);fill-opacity:1"/>
</svg>
2022-08-30 23:31:25 +02:00
Mira Grudzinska
092a53b0aa
svg_loader: fill and stroke paiint url were copied twice
...
The url were copied in the _copyAttr and in the _styleCopy
functions.
2022-08-29 12:00:35 +09:00
Mira Grudzinska
e36368c40c
svg_loader: only the first css style node is interpreted
...
Since the css id selector is not supported in TVG, only the first
style node is taken into account.
2022-08-29 11:59:32 +09:00
Vincent Torri
b6ca58f655
Fix compilation error on Windows
2022-08-24 22:31:41 +09:00
Omar Polo
53074d250f
fix OpenBSD compile issue
...
Linux seems the only system AFAICS to have alloca.h. All the BSDs have
the declaration in stdlib.h
2022-07-13 10:28:46 +09:00
Rémi Verschelde
becb70f09d
Cleanup FreeBSD preprocessor checks (if vs ifdef)
...
Should be equivalent but checking if the value is defined (`#ifdef`) is cleaner
than checking if it is set to something different from 0 (`#if`).
2022-05-24 10:32:53 +09:00
mundusnine
75c1314ab0
Fix on FreeBSD
...
Fix compile errors on FreeBSD.
- alloca is defined in stdlib.h on [freeBSD](https://www.freebsd.org/cgi/man.cgi?alloca )
Issue in [godot](https://cirrus-ci.com/task/5485473287110656?logs=build#L657 )
2022-05-13 17:58:04 +09:00