Commit graph

105 commits

Author SHA1 Message Date
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
Michal Maciola
e6ebb5379b common: RenderRegion x, y protect against negative value in unsigned int
This change protects against negative value in unsigned int of
RenderRegion.x/y. This fixes a problem of invisible paint if ClipPath
bounds was negative.

@issue: #704
2021-08-11 21:46:59 +09:00
Michal Maciola
cff8815404
loaders: Pass mimetype to picture::load
* loaders: Pass mimetype to picture::load

Added mimetype attribute to enfaster loading using a proper loader.

@Changed api: Picture::load(const char* data, uint32_t size, const std::string& mimeType, bool copy = false)
@issue: #571
2021-08-05 11:02:26 +09:00
Hermet Park
f7f241cff5 common picture: remove viewbox() api.
picture provides size() interface to return the image size,
viewbox() is conceptually not correct with the Picture.

Remove it under the beta api.
2021-07-28 13:07:43 +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
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
Michal Maciola
b89abde7cb
svg_loader: image tag: force size equal to the viewbox (#603)
* svg_loader: image tag: force size equal to the viewbox

For some svg files it is needed to force size equal the viewbox
for proper scaling

* svg_loader: image tag: force size equal to the viewbox fix #1
2021-07-15 17:48:35 -07:00
Michal Maciola
28342c5c1f svg_loader: <image> tag introduced fix #8
Disable embedded svg files to protect against recursive svg image loading
2021-07-09 12:04:29 +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