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
JunsuChoi
50da80573d
png_loader(static): Move the colortype check code to open()
2023-02-10 22:23:24 +09:00
JunsuChoi
02613feac3
png_loader(static): Fix the colorspace of an image with an alpha channel
...
Set colorspace to ABGR when colortype of lodepng is LCT_RGBA.
Since an image without an alpha channel becomes an ARGB colorspace with LCT_RGB,
it is the same as the default colorspace.
2023-02-10 22:23:24 +09:00
JunsuChoi
507b11829c
loader: Support ABGR colorspace
...
Since the color space is set at the time of specifying the target buffer of the canvas,
there is no way to know the color space when the picture is loaded.
So, check the color space applied to SwCanvas at the time of reload()
and change the color space.
There is an issue of BGR color space support for each loader.
The external_jpg loader resets the TJPF color space and calls read() to get a new buffer.
In the case of external_png, we need to change the color value directly
because it have to start over from begin_read_*.
This solution can affect performance as much as it access again image buffer
that have already been `read()` done. However, this only happens once.
2023-02-08 17:54:33 -08: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
1980d9d0e3
all: Trailing spaces removed
2023-01-07 10:53:51 +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
d958fc7971
saver/loader tvg: support picture mesh properties.
...
this mesh properites newly introduced in v0.8
(see: 3dd65dfed0
)
tvg saver/loader should implement mesh support to
properly capture/replay the scene snapshot.
@Issue: https://github.com/Samsung/thorvg/issues/1242
2022-12-08 22:29:29 +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
projectitis
510ffa571a
Fix compiler warnings on windows
2022-08-20 12:30:35 +09:00
Hermet Park
714470e618
loaders raw: fix a compiler warnings on Windows.
...
fix the invalid conversion from float to uint32_t.
@Issue: https://github.com/Samsung/thorvg/issues/1229
2022-08-04 17:02:56 +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
46c3fc1f94
Format code files with dos2unix, ensure newline at EOF
2022-07-10 23:21:05 +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
Hermet Park
0e8cd1e525
fix FreeBSD compile issue.
...
alloca is defined in stdlib.h on [freeBSD](https://www.freebsd.org/cgi/man.cgi?alloca )
additional fix to 75c1314ab0
2022-05-17 22:05:10 +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
JunsuChoi
0d010bdb6a
svg_loader: Fix invaild '<' nested check
...
When Type is DOCTYPE, Child Entities start with '<'.
This condition is valid when general Elements (svg, g, path etc) are used.
Add a Doctype check to if condition.
(There can be various cases related to '<' nested case.
But for now, I only add Doctype considering the side effect.)
2022-05-05 11:36:16 +09:00
mgrudzinska
0da0f5fa46
svg_loader: clearing the parser stop flags
2022-04-05 20:07:33 +09:00
mgrudzinska
eb7b281898
svg_loader: fixing color parsing
...
Color given in percentages, ex."rgb(10%,20%,30%)", was incorrectly parsed.
2022-04-05 19:36:15 +09:00
mgrudzinska
470b885e65
svg_loader: fixing segf when passing a nullptr to strcmp
...
This occurred when a gradient has no 'id' attribute.
2022-04-03 22:42:26 +02:00
mgrudzinska
1e8b8cbb53
svg_loader: symbol node without any viewbox/width/height info handled properly
2022-03-21 18:38:10 +09:00
Rémi Verschelde
bc5c29dd69
build: Add another <cstring>
include for MinGW compatibility
2022-03-16 23:51:12 +09:00
Mira Grudzinska
2ee25ea11d
svg_loader: width and height attribs of the use element applied
2022-03-07 11:32:02 +09:00
mgrudzinska
ed3608b39b
svg_loader: use node fixed
...
By mistake the use node was improperly transformed and/or displayed
for a reference node other than a symbol node.
2022-03-02 17:18:13 -08:00
mgrudzinska
b16d60d509
svg_loader: symbol preserveAspectRatio attribute fixed
...
The symbol node was properly scaled only for 'preserveAspectRatio=none'.
Now it works also for the default value of this attribute (xMidYMid).
2022-03-02 17:18:01 -08:00
mgrudzinska
d1e7d60fc9
svg_loader: preserveAspectRatio fix
...
The default value should be xMidYMid, now it is.
2022-03-02 17:17:54 -08:00
Hermet Park
bdda2586e9
svg_loader: handle the exception properly.
...
viewBox doesn't expect the missing attributes,
it won't have any default values.
So we can decide the fault when the values are missed.
2022-02-23 15:02:17 +09:00
Mira Grudzinska
c214532ad2
svg_loader: fixing symbol transformation
...
For a Symbol node, the transformation based on the 'viewBox', 'width'
and 'height' attributes has to be applied before the transformation
based on the 'transformation' attribute.
2022-02-21 11:21:22 +09:00
Mira Grudzinska
72ab9268e3
svg_loader: symbol++
...
- The initial value of the overflow attribute was missing
- overflow="visible" was missing scaling
2022-02-21 11:21:22 +09:00
Mira Grudzinska
70ed0653f1
svg_loader: symbol tag implemented
...
The 'symbol' tag introduced. It can be used to define graphical
template objects which can be instantiated by a 'use' tag.
2022-02-21 11:21:22 +09:00
Hermet Park
ccce0d7641
jpeg_loader: resolve the asan bug report.
...
fix the invalid negative shift operations.
@Issue: https://github.com/Samsung/thorvg/issues/1172
2022-02-16 12:45:37 +09:00
Mira Grudzinska
23ea4ed9f1
svg_loader: fixing memory leak
...
The css style node was improperly freed.
2022-02-14 14:35:09 +09:00