Commit graph

293 commits

Author SHA1 Message Date
Hermet Park
c790e18de6
svg_loader: reduce binary size
saved 800 bytes.
2021-11-05 17:17:20 +09:00
Hermet Park
88d34f0d9a svg_loader: reduce binary size
removed the std::string usages.

saved 17kb.
2021-11-05 17:12:53 +09:00
Mira Grudzinska
40f2baabae svg_loader: SvgCompositeNode type introduced
Clips and masks require to implement some additional variables,
so the new node type has been introduced. Implementation of the usage
of these additional variables will be the subject of a separate
commit.
2021-11-05 13:10:14 +09:00
Mira Grudzinska
7176a5ddd4 svg_loader: define the scaling factors for units changing
The values in absolute units are calculated based on the pixel unit.
Till now the default value of 90dpi was used. Since CSS3 (now CSS4 is
the most recent) 1 inch equals to 96 pixels. The necessary constants
are introduces in this commit.
2021-11-02 11:29:41 +01:00
Hermet Park
3b2e1f4291 Revert "loaders: Consider colorspaces (#838)"
This reverts commit cd5116b053.

Ah this breaks the Stress example due to Picture::duplicate() is not available...

Need to consider and come back again.
2021-11-01 16:53:25 +09:00
Michal Maciola
cd5116b053
loaders: Consider colorspaces (#838)
* common: added colorSpace() function

This patch introduces colorSpace() function for SW and GL engine.

* infra: change LoadModule:read() into LoadModule:read(uint32_t colorspace)

This patch changes LoadModule:read() into LoadModule:read(uint32_t colorspace)

* picture: implement passing colorspace into loader

This patch implements passing colorspace into loaders.
Loader->read is now called on the first update.

* external_jpg_loader: support colorspaces

* external_png_loader: support colorspaces
2021-11-01 16:10:22 +09:00
Hermet Park
875e200767 common: code refactoring
removed invalid nullptr checks.

New allocation doesn't gurantee that returns nullptr when it's failed.
It's useless on the modern compliers and our policy respects it.
2021-11-01 12:09:32 +09:00
Michal Maciola
00dfd55f18 SVG: Support geometry properties of use tag
This patch adds a support for geometry properties (x, y) of <use> tag
2021-10-29 14:10:44 +09:00
JunsuChoi
664e95859c svg_loader SvgLoader: Fix gradient default value
If isXXPercentage is true, then it is calculated accordingly.
2021-10-25 11:14:03 +02:00
Mira Grudzinska
5fc5fd7f2d svg_loader: requested changes applied 2021-10-25 11:15:58 +09:00
Mira Grudzinska
60029327f0 svg_loader: gradient handling and recalculation changed
The need to convert the gradient values occurs only when they are given
as nominal values in the current user coordinate system (userSpaceOnUse).
2021-10-25 11:15:58 +09:00
Mira Grudzinska
a93b5b98a9 svg loader: converting the image path to the absolute one
The href image tag should point to an absolute image path.
2021-10-23 02:26:55 +02:00
Hermet Park
9c8e785fdc updated license
Add missing original copyright texts in the source code.
2021-10-20 22:50:07 +09:00
Michal Maciola
d7a3aa580a svg_loader: fix potential mem corruption in _idFromUrl function
This patch fixes some potential memory corruptions in _idFromUrl function
when name (url) is longer than 50 chars or is incorrectly terminated.
2021-10-20 10:34:02 +09:00
Mira Grudzinska
0497ac894e svg_loader: removed unused variable
The gradient values passed to the scene builder are always given as percentages,
so there is no need to mark/check that.
2021-10-13 18:40:05 +09:00
projectitis
dad6c71b6c
all: fix warnings on MSVC
* Explicit casts to suppress warnings
* Fixed compiler warnings
2021-10-09 11:33:45 +09:00
Mira Grudzinska
a16e91b441 all: fix compiler warnings
pow->powf and sqrt->sqrtf
2021-10-07 14:49:00 +09:00
Mira Grudzinska
875e5bd058
svg_loader: proper handling width/height units (#851)
Units of the svg width and height tags were incorrectly assigned.
Percentage values will be handled separately.
2021-10-05 12:04:40 +02:00
Mira Grudzinska
79f7c744c5 svg_loader: fixing minor warnings 2021-09-28 12:07:52 +02:00
Mira Grudzinska
c9c3776207 svg_loader: proper svg resizing
Solves the problem of 'vx' and 'vy' < 0 and cases with 'width'
and 'height' values different than widht and height from the 'viewBox'
attribute.
2021-09-15 19:12:43 +09:00
Michal Maciola
ae3141d65c svg: fix opacity percentage value parsing
Percentage values wasn't handled by _toOpacity() function. Other incorrect values
was handled wrongly. Now fixed.
2021-08-25 14:57:30 +09:00
JunsuChoi
b72ff371ee svg_loader SvgLoader: Add 'href' attribute for parser
"xlink:href" will be deprecated.
https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/xlink:href
2021-07-30 12:26:27 +09:00
Michal Maciola
eb810a92f2
svg_loader: allow multiple defs tags
If svg contained multiple defs tags only the first one was handled correctly.
Every next 'defs' tag was skipped and its inner elements parsed as it was
outside the defs.
2021-07-29 11:47:33 +09:00
Hermet Park
d213a67180 common loader: code refactoring
Bitmap based pictures doesn't need the viewbox,
LoaderModule should delegate the viewbox to the derived classes which
having vector-based image loaders such as svg, tvg.

In that case, paint resizing can be performed by the loaders by own
policy.
2021-07-28 14:16:18 +09:00
Hermet Park
3cb0caf2c4 common loader: code refactoring.
replace from Scene to Paint at the internal interface.

Picture doesn't need to know the returned Node type.
base class, Paint is enough to in the data passing.
2021-07-28 13:45:34 +09:00
Hermet Park
e949883049 common log: use the log macro to replace the print method easier.
We can replace the system logger method by changing single line print source in common,
This also helps to remove the THORVG_LOG_ENABLED macro from each use-cases.

TVGLOG(): To print the hint & tip messages for users.
TVGERR(): To print the error message for debugging.

@Issues: https://github.com/Samsung/thorvg/issues/36
2021-07-23 21:17:01 +09:00
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