Commit graph

476 commits

Author SHA1 Message Date
Rémi Verschelde
0c6c37b616 build: Add missing <cstring> includes for MinGW compatibility 2022-01-19 16:40:30 +09:00
Rémi Verschelde
4e14e30447 tvg_loader: Convert tvgJpgd.h EOL to LF
This makes it consistent with the rest of the codebase.
2022-01-19 16:35:38 +09:00
Mira Grudzinska
99da490ef7 svg_loader: memleak prevention
If image href set more than once, the memory was not freed.
2022-01-18 18:22:01 +01:00
Mira Grudzinska
ed3b17b228 svg_loader: preventing memcpy from a nullptr
In a case when a polygon/polyline had no points, there is nothing
to be copied.
2022-01-17 12:05:34 +09:00
Mira Grudzinska
04d3bb0ec0 svg_loader: fixing cyclic cloning of nodes
The reference node doesn't have to be placed inside the defs block,
so when refering to it, it is necessary to search the entire node tree.
In case of invalid svg file this can lead to circular references.
Added prevention against such a sutuation.
2022-01-17 12:03:57 +09:00
Mira Grudzinska
43e5644e8b svg_loader: fixing memleak
Memory was not freed before reallocation (grad->ref can be overwritten
without freeing memory first) - fixed.
2022-01-15 17:26:20 +01:00
Mira Grudzinska
6fb0984b49 svg_loader: postponed nodes properly cloned
In case when no defs tag was used, no child node was found.
Also the node attributes should not override those set in the ancestor.
2022-01-12 09:54:57 +01:00
Hermet Park
f0141e63de updated copyright date. 2022-01-12 14:08:48 +09:00
Mira Grudzinska
2217b94361 svg_loader: changed the order of if conditions
The weekest condition should be checked as the last one.
Otherwise CDATA marker was never found.
2022-01-11 14:05:00 +09:00
Mira Grudzinska
baf45823cb svg_loader: the color attribute properly inherited
The color attribute hat to be inherited regardles whether it is used
in the child node or not - it may be used i.e. in the grandchild node.
2022-01-11 14:04:39 +09:00
Mira Grudzinska
4b0037fe6a svg_loader: removing repeated lines
The clip-path and the mask attributes are both parsed in _attrParseGNode
function, which is called in th _attrParseUseNode.
2022-01-11 14:03:33 +09:00
Mira Grudzinska
333ff25c7e svg_loader: fix grad update
The grad update should be handled after the postponed nodes are cloned.
2022-01-11 13:56:14 +09:00
Mira Grudzinska
1f6c236fa3 svg_loader: preventing memory leak
A memory leak occured when the 'id' attribute was given multiple times
for a given gradient element. Fixed.
2022-01-11 13:55:21 +09:00
Mira Grudzinska
e409bb2984 svg_loader: LumaMask used only for masks other than white
For the performance reasons, the LumaMask is used only when
it's necessary - when the mask color is other than white.
Otherwise the AlphaMask is enough.
2022-01-08 02:26:52 +01:00
Mira Grudzinska
d3053777a8 svg_loader: typo fixed
_svgLoaderParerXmlClose -> _svgLoaderParserXmlClose
2022-01-08 00:39:21 +01:00
Mira Grudzinska
2f7e7e9923 svg_loader: mask-type attribute introduced
In an svg file the mask-type attribute can be specified.
It takes one of the two values: Luminosity or Alpha.
After the LumaMask is introduced into TVG, this attribute can be
properly read by the svg loader.
2022-01-07 12:45:34 +09:00
Hermet Park
1f5b66c256 svg_loader: ++robustness
prevent a crash with an exceptional handling.

@Issue: https://github.com/Samsung/thorvg/issues/1131
2022-01-06 13:40:00 +09:00
Mira Grudzinska
a6781734dc svg_loader: composite node splitted on mask and clip nodes
The SvgCompositeNode is replaced by the SvgMaskNode and SvgClipNode.
This is needed for using Luma/AlphaMask in the svg loader and in the future,
when we introduce other mask's features.
2022-01-03 12:30:01 +09:00
Hermet Park
36da47af80 png_loaders: fix the wrong premultiplying operations.
It should not modify the alpha channel value while premultiplying
that turned out with the wrong visual result.

@Issue: https://github.com/Samsung/thorvg/issues/655
2021-12-13 23:46:15 -08:00
Hermet Park
4cdf648e14 sw_engine image: support non-premultiplied alpha images.
Previously, translucent png images are not displayed properly
due to alpha channels premultiplication.

This patch implements that missing part to support it properly
by introducing the Surface data between canvas engine & rasterizer

@Issue: https://github.com/Samsung/thorvg/issues/655
2021-12-02 17:10:12 +09:00
Mira Grudzinska
4485db4f15 svg_loader: a function to establish shapes boundries without a stroke introduced
To handle the objectBoundingBox units, the shape's boundaries have to be known.
According to the SVG standard, a stroke shouldn't be taken into account. Since
the bounds() api uses the shape's stroke information, a new function is introduced,
that compensates this and returns boundaries without any strokes.
2021-11-26 11:47:15 +01:00
Mira Grudzinska
bd7c19a592 svg_loader: struct used to pass 1 args instead of 4 of them
The Box struct is introduced to replace the four functions
args: vx, vy, vw, vh, so all of them can be passed at once.
2021-11-26 11:47:15 +01:00
JunsuChoi
baab43aff2 tvg_saver TvgBinInterpreter: prevent misaligned memory access
When parsing a binary stored as a char type,
interpreter can access the misaligned memory while accessing it with a pointer.
To prevent that, pass the array copied to memcpy as tvg Object.
2021-11-22 16:30:08 +09:00
jykeon
bfaf26d99e svg_loader: Add nullptr check.
Signed-off-by: jykeon <jykeon@samsung.com>
2021-11-19 17:37:45 +09:00
Hermet Park
0fcdba8a4b common math: code refactoring
introduced mathZero(), mathEqual() for floating variables.
2021-11-15 17:10:54 +09:00
Mira Grudzinska
ed640630c1 svg_loader: mem properly freed
delete -> free
2021-11-12 10:46:53 +09:00
Mira Grudzinska
f3450e1760 svg_loader: memory properly released
delete->free
2021-11-11 21:49:13 +09:00
Hermet Park
56e2498466 png_loader: correct colorspace
decoding color channels rgba -> bgra

@Issue: https://github.com/Samsung/thorvg/issues/1007
2021-11-11 21:48:22 +09:00
Hermet Park
6ba2bc8eb3 tvg_loader: fix asan report.
revert c31c77c0fb

memory mis-alignment is detected by asan tool.
2021-11-09 17:11:10 +09:00
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
b85eaddcf2 svg_loader: passing the svgPath information into the _applyComposition
An image can be a mask, so the information about it's path is necessary
during a composition application.
2021-11-05 13:10:52 +09:00
Mira Grudzinska
0501863195 svg_loader: mask node loaded as a scene
Since the mask is a container element (in opposite to the clipPath),
it has to be loaded as a scene.
2021-11-05 13:10:52 +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
Hermet Park
0f2d7e3eef jpg_loader: fix compiler warnings.
"warning: shifting a negative signed value is undefined [-Wshift-negative-value"
2021-11-02 19:49:57 +09:00
Hermet Park
c31c77c0fb tvg_loader interpreter: tiny optmization
skip memory copy as possible.
2021-11-02 19:47:08 +09:00
Mira Grudzinska
6b132d77e8 tvg_saver/tvg_loader: gradient fill in the tvg format
Introducing the gradient transform() apis and changing the grad
algorithms made it possible to apply the shape's transformation
before saving the tvg file, in case the shape (or its stroke)
has a fill.
2021-11-02 19:37:02 +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
3c7d037841 jpg_loader: code refactoring
removed unused variables.
2021-11-02 19:02:07 +09:00
Hermet Park
c8e7bc9d43 png_loader: code refactoring
removed unused variables.
2021-11-02 18:57:55 +09:00
JunsuChoi
590381f68b infra meson: Add -Dstatic option
Add an option for use in environments where
the use of static libraries must be enforced.
2021-11-02 13:14:16 +09:00
Mira Grudzinska
16a153c804 svg_loader: fix bounds for gradient
In the case when bounds should not include a stroke width, width
and height values were reduced by half of a stroke width, instead
of the full width.
2021-11-01 20:36:48 +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
Mira Grudzinska
b12421b4d1 tvg_loader: TVGLOG added in case an unknown fill or stroke tag used 2021-11-01 12:12:02 +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
Mira Grudzinska
4db3087c45 svg_loader: gradient transformation properly applied
The final gradient transformation depends on the coordinate system.
It can not be applied during an svg loading. The transformation matrix
has to be passed via api for further gradient processing.
2021-10-29 10:58:43 +09:00
Mira Grudzinska
ba25cb80eb svg_loader: shape's bounds without a stroke
A shape's bounds used for a gradient transformation shouldn't take
a stroke into account.
2021-10-28 12:18:17 +02:00
Hermet Park
a4494919ac jpg_loader: support multi-thread and header reading in prior to decoding.
revise the code to support async loading of the static jpeg_loader,
also support header reading in prior to decoding.
2021-10-27 16:39:43 +09:00