Hermet Park
5024e7f952
svg_loader: code refactoring.
...
clean up about logging before replacing it with TVGLOG()
2021-07-23 15:24:59 +09:00
Hermet Park
e56476b7bd
common: code refactoring.
...
renamed loader classes same to Saver classes
tvgLoaderMgr -> tvgLoader (tvgSaver)
tvgLoader -> tvgLoadModule (tvgSaveModule)
2021-07-22 17:30:02 +09:00
Michal Maciola
c2ec997db5
svg_loader: allow both clipPath and mask together ( #622 )
...
* svg_loader: allow both clipPath and mask together
* svg_loader: allow both clipPath and mask together fix #1
Changed seperate functions _applyClipPathComposition and _applyMaskComposition into single function _applyComposition
2021-07-21 12:12:09 +09:00
JunsuChoi
333cac8d9d
svg_loader SvgLoader: Initialize to flag value of SvgParser
...
This patch fixes valgrind detection
$valgrind --leak-check=yes ./Svg
==21410== Conditional jump or move depends on uninitialised value(s)
==21410== at 0x505DB66: _attrParseStops(void*, char const*, char const*) (tvgSvgLoader.cpp:2099)
==21410== by 0x5064F6D: simpleXmlParseAttributes(char const*, unsigned int, bool ()(void, char const*, char const*), void const*) (tvgXmlParser.cpp:319)
==21410== by 0x5061774: _svgLoaderParserXmlOpen(SvgLoaderData*, char const*, unsigned int, bool) (tvgSvgLoader.cpp:2387)
==21410== by 0x5061857: _svgLoaderParser(void*, SimpleXMLType, char const*, unsigned int) (tvgSvgLoader.cpp:2408)
==21410== by 0x5065052: simpleXmlParse(char const*, unsigned int, bool, bool ()(void, SimpleXMLType, char const*, unsigned int), void const*) (tvgXmlParser.cpp:425)
==21410== by 0x5061993: SvgLoader::run(unsigned int) (tvgSvgLoader.cpp:2757)
==21410== by 0x5052F5E: operator() (tvgTaskScheduler.h:68)
==21410== by 0x5052F5E: tvg::TaskSchedulerImpl::run(unsigned int) (tvgTaskScheduler.cpp:138)
==21410== by 0x62C36DE: ??? (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.25)
==21410== by 0x6DA36DA: start_thread (pthread_create.c:463)
==21410== by 0x68C871E: clone (clone.S:95)
2021-07-12 12:35:42 +09:00
JunsuChoi
f9d82c2c28
svg_loader SvgLoader: Fix memory leak of duplicate declared id
...
Duplicate declaration of id attribute is invaild.
We do not have a separate policy for invalid svg files.
Therefore, it is a priority to prevent crashes or memory leaks.
If an id is declared as duplicate, the last declared id is used.
2021-07-12 11:21:05 +09:00
Michal Maciola
1f67c1d689
svg_loader: <image> tag introduced fix #6
...
Moved file:// removing into _imageBuildHelper
2021-07-09 12:04:29 +09:00
Michal Maciola
3e4512a9a6
svg_loader: <image> tag introduced fix #5
...
Added copyAttr for image
2021-07-09 12:04:29 +09:00
Michal Maciola
9c1af3dde5
svg_loader: <image> tag introduced fix #1
...
Fixed href string deleting
2021-07-09 12:04:29 +09:00
Michal Maciola
80fa97d366
svg_loader: <image> tag introduced
...
This patch introduces embeded <image> tag for svg files.
Images can be now loaded from local path or using data URI Scheme (RFC2397).
Base64 and utf8/uri are welcome.
@issue: #518
2021-07-09 12:04:29 +09:00
Hermet Park
af140a1fe5
svg_loader: fix gradient memory leak.
...
@Issue: https://github.com/Samsung/thorvg/issues/548
2021-07-09 11:58:44 +09:00
Hermet Park
3997aedcd5
svg_loader: optimize memory usage.
...
-- unnecessary memory fragmentation.
2021-07-09 11:58:44 +09:00
Michal Maciola
bb19bcf64f
svg_loader: postpone cloneNode()
...
Some svg export software puts <defs> element at the end of the file.
If so, the <defs> element won't be found, when parsing <use>.
In such scenario, this patch postpone node cloning until the whole file
is parsed.
@issue: #568
2021-07-07 15:34:15 +09:00
JunsuChoi
ea3d79f5f3
svg_loader: Support percentage unit of dash-array
...
Refers to the diagonal length of the viewport.
https://www.w3.org/TR/SVG2/coords.html#Units
2021-07-07 09:48:46 +09:00
Mira Grudzinska
1507438ecc
svg_loader: set the priority for the style attribute for stop properties
...
Stop properies stop-color and stop-opacity set using a style attribute should
have higher priority than properties set in a different way.
2021-07-06 10:13:58 +02:00
Mira Grudzinska
fff5bfee83
svg_loader: set the higher priority of style attributes
...
issue #515
2021-07-06 10:13:58 +02:00
Michal Maciola
7a8d7ceac6
svg_loader: fix dead loop on none digit char in stroke-dasharray fix #3
...
Added zero and negative value protection
2021-07-06 10:39:34 +09:00
Michal Maciola
bf8c633d38
svg_loader: fix dead loop on none digit char in stroke-dasharray fix #2
...
Moved _skipComma at the begining of the loop
2021-07-06 10:39:34 +09:00
Michal Maciola
2f8c00580d
svg_loader: fix dead loop on none digit char in stroke-dasharray
2021-07-06 10:39:34 +09:00
Michal Maciola
99263d54d1
svg_loader: multiple composition memory leak
...
Multiple composition are still not supported, but this patch fixes a
memory leak if it is tried to be applied.
2021-07-03 14:14:01 +09:00
Michal Maciola
6a09a8f015
svg_loader: memory leak after improper stop tag fix #1
...
Updated printf message
2021-07-03 13:50:03 +09:00
Michal Maciola
b005f97bcd
svg_loader: memory leak after improper stop tag
...
<stop> tag should be always a child of a <linearGradient> or
<radialGradient> element, but there were files with <stop> tag inside <rect>.
This patch fixes a memory leak if no gradient is defined before <stop> tag.
2021-07-03 13:50:03 +09:00
Mira Grudzinska
f411b5a64c
svg_loader: recalculating the default values of grads
...
The default values of gradient properties were handled differently
than the values given by a user/in an svg file.
2021-07-01 12:15:55 +09:00
Michal Maciola
3086f28b55
svg_loader: allow multiple <defs> tags without data and memory leak ( #528 )
...
* svg_loader: allow multiple defs without data and memory leak
If the svg file contained multiple <defs> tags, each subsequent tag
overwritten the previous tag. This resulted in incorrect rendering of the
file and memory leaks.
@Issues: 491
* svg_loader: allow multiple defs without data and memory leak- fix #1
Changed the idea to abandon node creating instead of deleting it after
creation. Removed simpleXmlParseAttributes for _createDefsNode.
2021-06-30 17:21:30 +09:00
Hermet Park
fcbc77bcdf
svg_loader: code refactoring
...
unify to tvg fill rule.
2021-06-30 15:18:14 +09:00
Hermet Park
3e7888b538
svg_loader: code refactoring
...
use color structure to keep neat & compact code.
2021-06-30 14:54:12 +09:00
Mira Grudzinska
feb71ff36c
svg_loader: currentColor - inheritance from a parent
...
The 'currentColor' attribute value was not inherited. Fixed.
2021-06-29 09:27:52 +09:00
Michal Maciola
520d6e7bbd
svg_loader: negative attrs length fix
...
After finding no attributes but white spaces, attrs length could be negative
that resulted in segmentation fault in simpleXmlParseAttributes function.
@Issue: #487
2021-06-28 16:46:26 +09:00
Hermet Park
78bb8d1f2e
svg_loader: fix trivial build warnings.
...
../src/loaders/svg/tvgSvgLoader.cpp: In function ‘void _copyAttr(SvgNode*, const SvgNode*)’:
../src/loaders/svg/tvgSvgLoader.cpp:1598:60: warning: ‘void* memcpy(void*, const void*, size_t)’ writing to an object of type ‘struct SvgStyleProperty’ with no trivial copy-assignment; use copy-assignment or copy-initialization instead [-Wclass-memaccess]
memcpy(to->style, from->style, sizeof(SvgStyleProperty));
@Issue: 498
2021-06-28 13:47:15 +09:00
Mira Grudzinska
57a22b8462
svg_loader: finish the search after founding the proper color
...
In the _toColor func, after founding the proper color, the search
should be finiched.
2021-06-28 11:32:44 +09:00
Hermet Park
a6f9ec3080
svg_loader: fix memory violation issues.
...
copy attribute must copy the url data,
otherwise, url memory can be atempted freeing twice.
also, fix the memory leak in multiple composition case.
2021-06-25 10:28:27 +09:00
Hermet Park
87b94b7a7f
common: fix compatibility issue for MSVC
...
Math Constants are not defined in Standard C/C++
for this, we can use _USE_MATH_DEFINES before math headers.
2021-06-23 13:38:46 +09:00
Mira Grudzinska
5679d666a6
svg_loader: correct parsing ColorStop offset values
...
Values different from numbers and percentages should be ignored
and the default values should be applied (zeros).
2021-06-23 10:35:58 +09:00
JunsuChoi
f20ef0dc15
svg_loader SvgLoader: Copy the missing composite url
...
When copying an attribute, url information of stype's composite is overwritten with memcpy.
This causes double free by deleting the wrong string in freeNodeStyle.
2021-06-22 10:26:05 +02:00
JunsuChoi
a2d348242b
svg_loader SvgLoader: Prevent invalid access
...
If there is no path information, it is not copied.
2021-06-22 09:55:13 +02:00
Hermet Park
0df8c00519
loaders: revise code from cce4b443b3
...
use copy variable instead of additional buffer pointer.
2021-06-22 10:42:34 +09:00
Michal Maciola
cce4b443b3
loaders: added copy param for Picture::load
...
@API Changed:
Result Picture::load(const char* data, uint32_t size, bool copy /*=false*/) noexcept
TVG_EXPORT Tvg_Result tvg_picture_load_data(Tvg_Paint* paint, const char *data, uint32_t size, bool copy);
2021-06-21 19:52:38 +09:00
Mira Grudzinska
8bb10fb261
svg_loader: radial gradient transformation support
...
For now the gradient radius is scales like x-axis - it has to be changed
after issue #37 will be resolved.
2021-06-21 10:23:42 +09:00
Mira Grudzinska
7ffeb2e606
svg_loader: fixing color parsing
...
For colors given in a style attribute in the format "rgb(rrr, ggg, bbb)"
a parsing was incorect. Now fixed.
2021-06-17 11:12:33 +09:00
Mira Grudzinska
e0a1aa9355
svg_loader: adding check if stroke-dasharray attribute != none
...
The stroke-dasharray value equal to "none" was causing a segfault
during a conversion to float. Fixed now.
2021-06-17 10:16:05 +09:00
Mira Grudzinska
a3e784b6b5
svg_loader: gradient update takes into account a stroke and a fill
...
For shapes with a grad fill and a grad stroke only the fill was drawn.
After this fix both can have a valid gradient.
2021-06-15 14:25:17 +09:00
Hermet Park
15b56a66de
tvg_loader: code refactoring.
...
revise it under the tvg coding convention.
2021-06-11 20:51:50 +09:00
Mira Grudzinska
9b1356e7cb
svg_loader: support stroke gradient
...
The loader was ready to handle the gradient stroke, but there was no API to support
it when the loader was introduced. We've had this API for a while already, so
its call has been added.
2021-06-10 11:36:20 +09:00
Mira Grudzinska
ae5673658e
svg_loader: initializing uninitialized variables
...
The 'loader->svgParse->global' variable was uninitialized when no viewBox attribute
was set. If gradient was applied, the division by zero occured and no gradient was drawn.
2021-06-07 12:30:56 +09:00
JunsuChoi
f8f90f3f34
log SvgLoader: Enhance log message
...
- Change tag name "Doc" to "Svg"
- Fix "Mask" tag name.
- Add element to skip output
- title
- Add attribute to skip output
- id, data-name, version, overflow=visible, xmlns*, xml:space
2021-05-13 23:46:17 +09:00
JunsuChoi
475fc22f6d
loader SvgLoader: Fix memory leak
...
Add memory release for style->comp.url, which is the leaking memory.
[Valgrind Test Result]
==21595== 32 bytes in 1 blocks are definitely lost in loss record 29 of 152
==21595== at 0x4C3217F: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==21595== by 0x5C248C6: _idFromUrl(char const*) (tvgSvgLoader.cpp:272)
==21595== by 0x5C24DE1: _handleClipPathAttr(SvgLoaderData*, SvgNode*, char const*) (tvgSvgLoader.cpp:860)
==21595== by 0x5C260CC: _attrParseGNode(void*, char const*, char const*) (tvgSvgLoader.cpp:953)
==21595== by 0x5C2ABA9: simpleXmlParseAttributes(char const*, unsigned int, bool (*)(void*, char const*, char const*), void const*) (tvgXmlParser.cpp:272)
==21595== by 0x5C26F6E: _createGNode(SvgLoaderData*, SvgNode*, char const*, unsigned int) (tvgSvgLoader.cpp:1063)
==21595== by 0x5C27A04: _svgLoaderParserXmlOpen(SvgLoaderData*, char const*, unsigned int, bool) (tvgSvgLoader.cpp:2168)
==21595== by 0x5C27CE9: _svgLoaderParser(void*, SimpleXMLType, char const*, unsigned int) (tvgSvgLoader.cpp:2226)
==21595== by 0x5C2AC8C: simpleXmlParse(char const*, unsigned int, bool, bool (*)(void*, SimpleXMLType, char const*, unsigned int), void const*) (tvgXmlParser.cpp:378)
==21595== by 0x5C27E09: SvgLoader::run(unsigned int) (tvgSvgLoader.cpp:2571)
==21595== by 0x5C1A7C1: operator() (tvgTaskScheduler.h:68)
==21595== by 0x5C1A7C1: tvg::TaskSchedulerImpl::run(unsigned int) (tvgTaskScheduler.cpp:138)
==21595== by 0x5EED6DE: ??? (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.25)
2021-05-03 16:29:30 +09:00
Hermet Park
1d923a8632
loader svg: fix build break due to typo
2021-05-01 12:37:45 +09:00
Hermet Park
e1ebcf6153
loaders svg: code refactoring
...
split functions as its purpose.
2021-04-21 11:12:22 +09:00
JunsuChoi
51e4757a3b
loader SvgLoader: Fix wrong debug log
...
1.
Modify that attribute information used for use type
looks like it was used for g type.
2.
Fix clippath node looking like setting "none"
(clippath's display = false is intentional)
2021-04-21 11:11:37 +09:00
JunsuChoi
8b54b6768a
loader SvgLoader: add locale-independent strtof function
...
strtof's behavior is changed by system locale.
https://linux.die.net/man/3/strtof
Because of this, strtof(10.0000) returns 0.0 in some locales.
When a given value string is locale-independent, strtof has to be
replaced to custom function.
2021-04-20 19:44:04 +09:00
Hermet Park
b541a0654c
loaders svg: ++safety
...
prevent buffer overflow just in case.
2021-04-20 17:49:48 +09:00