Commit graph

113 commits

Author SHA1 Message Date
Hermet Park
1e370712e0 loader svg: ++code readability
Use own bit operation helpers.
2023-04-26 11:15:48 +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
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
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
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
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
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
Vincent Torri
b6ca58f655 Fix compilation error on Windows 2022-08-24 22:31:41 +09:00
mgrudzinska
1e8b8cbb53 svg_loader: symbol node without any viewbox/width/height info handled properly 2022-03-21 18:38:10 +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
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
Mira Grudzinska
6a589777b0 svg_loader: proper image transformation
One of the image's attributes can be a transformation matrix.
Now it's applied.
2022-02-08 19:49:39 +09:00
Mira Grudzinska
2fce4d46a0 svg_loader: the 'use' node properly transformed
The translation of the use node shouldn't overwrite its transformation.
2022-02-08 19:47:09 +09:00
Mira Grudzinska
d1fc538429 svg_loader: fixing the used mask-type
For the performance reasons, regardless of the set/default
mask-type value, if the mask is white, the alpha masking is
used. To qualify a mask as white, not only its fill has to be
checked, but its stroke as well. The second was missing.
2022-02-08 19:46:40 +09:00
Rémi Verschelde
0c6c37b616 build: Add missing <cstring> includes for MinGW compatibility 2022-01-19 16:40:30 +09:00
Hermet Park
f0141e63de updated copyright date. 2022-01-12 14:08:48 +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
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
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
Hermet Park
0fcdba8a4b common math: code refactoring
introduced mathZero(), mathEqual() for floating variables.
2021-11-15 17:10:54 +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
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
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
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
Mira Grudzinska
1abee9f8d5 svg_loader: fixing viewBox clipping
For vw=width and vh=height, vx or vy > 0 had no effect. Fixed
2021-10-15 12:33:26 +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
Mira Grudzinska
c2bbdccac1 svg_loader: removed unnecessary casting
The used scaling factor should be a float - casting it to an int caused
misevaluation of the radial gradient radius
2021-10-11 18:59:23 +09:00
Mira Grudzinska
a16e91b441 all: fix compiler warnings
pow->powf and sqrt->sqrtf
2021-10-07 14:49:00 +09:00
Hermet Park
74954db56d common paint: refine the bounds() api to return the values after applying transformation.
Current paint::bounds() returns the coordinates under the raw status,
the values are not quite useful if the paint object has the transformed children.

Thus, we extends the feature and give an additional parameter "transformed"
to return the coordinates values after transformation by user demands.

This is also necessary for tvg format, since we need the exact view size of the scene information.

The previous api is deprecated and we introduce a new api to replace it.

@APIs:
+ Result Paint::bounds(float* x, float* y, float* w, float* h, bool transformed) const noexcept;
- Result Paint::bounds(float* x, float* y, float* w, float* h) const noexcept;

@Issues: https://github.com/Samsung/thorvg/issues/746
2021-09-24 11:25:49 +09:00
Michal Maciola
702f452c6c svg: fix url property
If 'fill="url(#image)"' and defs with id 'image' was not found, the paint was
improperly filled with color.
2021-09-21 20:20:59 +02:00
Mira Grudzinska
4589196689
common: preventing msvc compiler warnings (#817) 2021-09-20 13:54:06 +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