Commit graph

246 commits

Author SHA1 Message Date
JunsuChoi
53e2ecd81c loader/svg: Fix empty id to null
empty id is invalid. Therefore, set it to null and make it is not used.

issue: https://github.com/thorvg/thorvg/issues/1977
2024-02-15 10:29:13 +09:00
Hermet Park
67d8d9f36c svg_loader: code refactoring
removed duplicate matrix multiply function.
2024-01-22 19:03:59 +09:00
Mew Pur Pur
de00104566
svg_loader: Add missing implementation of skewX and skewY in transform-list 2024-01-22 18:52:37 +09:00
Hermet Park
0eafcfd1b0 loader: code refactoring
Ensure scene data is freed when it's dangled in the loader.
2024-01-11 10:12:04 +09:00
Hermet Park
fbcfb3f865 svg: ensure that all allocated memory.
observed a memory leak at a corner case.
2023-12-31 10:45:26 +09:00
Jinny You
2c6c8d3b21
updated copyright date (#1866) 2023-12-28 10:43:25 +09:00
Hermet Park
bd37e8ba37 common: Revise internal loader interfaces.
We are introducing the FontLoader, which slightly differs
from the ImageLoader in terms of features. To adequately
support both, we have separated the loader functionalities
into FontLoader and ImageLoader. This allows us to optimally
adapt the LoadModule for each case.
2023-12-25 12:40:12 +09:00
Hermet Park
a9d39eaf56 renderer/loader: optimization++
removed the internal unique_ptr usage to reduce the binary size(-553)
2023-12-08 23:35:19 +09:00
Hermet Park
ff6ea4b6c4 Loaders: Introduced a loader cache.
The loader cache is applied to conserve memory.

If the input data is already present in loaders,
the loader cache will promptly return the active loader.

This results in a lot of memory savings for the duplicated resources.

binary diff: -400 bytes
2023-11-23 18:21:28 +09:00
Hermet Park
f2c29063d2 api: updated the recent changed api again.
Reordered by the data packing size.
Also removed a wrong capi default parameter value.

Result Picture::load(const char* data, uint32_t size, const std::string& mimeType, bool copy = false, const std::string& rpath = "")
-> Result load(const char* data, uint32_t size, const std::string& mimeType, const std::string& rpath = "", bool copy = false)

Tvg_Result tvg_picture_load_data(Tvg_Paint* paint, const char *data, uint32_t size, const char *mimetype, bool copy, const char* resourcePath)
-> Tvg_Result tvg_picture_load_data(Tvg_Paint* paint, const char *data, uint32_t size, const char *mimetype, const char* resourcePath, bool copy);
2023-11-23 11:59:38 +09:00
Jinny You
132be91de4 lottie/loader: support external image from memeory lottie
I've added new parameter, const string& resourcePath, to load external image on lottie.

Result load(const char* data, uint32_t size, const string& mimeType, bool copy, const string& resourcePath)

Note: tvgLoadModule will have new overrided method `open`, not to effect to other changes except animation.

Issue: #1793
2023-11-22 18:04:35 +09:00
Mira Grudzinska
fd014df1a9 loader/svg: support the focal property in the radial gradient.
@Issue: https://github.com/thorvg/thorvg/issues/1555
2023-09-04 16:48:38 +09:00
Hermet Park
5a73bcaa8f common/array: code refactoring
easy access to a specific data with a operator.
2023-08-29 12:28:38 +09:00
Mira Grudzinska
478e45f9f3 common: stroke dash offset support added
The feature is supported also in the svg loader.

@Issue: https://github.com/thorvg/thorvg/issues/1591
2023-08-23 12:40:27 +09:00
Hermet Park
f399491557 loader/svg: ++optimization
flush out the used internal memory immediately.
2023-08-22 13:29:49 +09:00
Hermet Park
5d32cf1e3b loader/svg: ++optimization
share the image data to bypass the need for multiple bitmap memory copies.
2023-08-22 13:29:49 +09:00
Mira Grudzinska
480917651a utils: custom strtof and strndup moved into utils
The custom implementations of 'strtof' and 'strndup'
present in the svg loader have been moved into a new
'utils' directory (strToFloat and strDuplicate, respectively).
2023-08-05 11:49:36 +09:00
Mira Grudzinska
afee0441f6 svg_loader: removed unnecessary header 2023-08-01 14:53:36 +02:00
Mira Grudzinska
4f9f125454 svg_loader: update style in defs
In the defs node the style was not updated, hence
the inheritance wasn't applied causing wrong results.
2023-07-28 12:11:24 +09:00
Mira Grudzinska
b0e41b2b9f svg_loader: support the '!important' directive
The directive is used to give a specific style property
higher priority, ensuring that it overrides other style
declarations for the same property.

@Issue: https://github.com/thorvg/thorvg/issues/1255
2023-07-27 11:51:45 +09:00
Hermet Park
60f81b7da7 loader lottie: added empty interface body
This marks the first step towards implementing the Lottie feature.
2023-07-27 00:31:27 +09:00
Mira Grudzinska
de41853bcf svg_loader: custom strndup moved into utils
The custom _strndup was used only in one file
as an internal function and wasn't accessible
in other parts of the code. Now function
is available as svgUtilStrndup.
2023-07-26 00:21:56 +09:00
Hermet Park
a1f0b06f41 common array: revise code.
maintain code with an optimial size.
2023-07-25 19:57:12 +09:00
Hermet Park
accb8c5699 svg loader: --compiler warnings
../src/loaders/svg/tvgSvgLoader.cpp: In function ‘void _copyAttr(SvgNode*, const SvgNode*)’:
../src/loaders/svg/tvgSvgLoader.cpp:2911:44: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
 2911 |             if (to->node.polygon.pts.count = from->node.polygon.pts.count) {
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/loaders/svg/tvgSvgLoader.cpp:2917:45: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
 2917 |             if (to->node.polyline.pts.count = from->node.polyline.pts.count) {
2023-07-04 01:17:25 +09:00
Hermet Park
d72d6aa51f loader svg: code cleanup
Use array instead of individual dynamic array implementation.
This also fixes wrong polygon & polyline data access during copy & paste...
2023-07-04 01:09:23 +09:00
Martin Capitanio
44a750ee5d API, CAPI, sw_engine: add suport for stroke-miterlimit. 2023-06-13 10:42:20 +09:00
Hermet Park
f2fdc380b4 fix compiler warnings on MacOS
warning: unqualified call to 'std::move' [-Wunqualified-std-cast-call]
2023-05-19 10:56:59 +09:00
Mira Grudzinska
2cfa5505c3 svg_loader: fixing finding defs node
In the case when a 'use' node was used
in a 'defs' block  and the element it
referenced was also defined within the same
'defs' block, the reference node could not
be cloned. This was because the 'defs' node
could not be located.

@Issue: https://github.com/thorvg/thorvg/issues/1451
2023-05-16 10:43:45 +09:00
Mira Grudzinska
40ef9031ba svg_loader: copy the use node properties
A bug was observed when a 'use' node was
referenced in another 'use' node.

@Issue: https://github.com/thorvg/thorvg/issues/1451
2023-05-16 10:42:35 +09:00
Mira Grudzinska
4599067bee svg_loader: fixing percent. calculations of width/height
The conversion to percentages was applied twice.
Additionally, when a viewbox value was provided before the width/height,
incorrect scaling occurred.

@Issue: https://github.com/thorvg/thorvg/issues/1414
2023-05-04 09:52:55 +09:00
Hermet Park
9a9c0e7907 svg_loader: code refactoring.
simplify the logic and remove unnecessary member data.
2023-05-03 22:08:16 +09:00
Hermet Park
f82c274444 svg_loader: fix memory violation.
LoadModule data is designed to be returned to the user's call.
and should not be writable in Task::run()

@Issue: https://github.com/thorvg/thorvg/issues/1409
2023-05-03 22:08:16 +09:00
Mira Grudzinska
92346c4119 svg_loader: handling svg width/height in percentages
The percentages should refer to the size of the viewbox.
This was not the case for not knowing the viewbox before
reading the width/height.

@Issue: https://github.com/thorvg/thorvg/issues/1409
2023-05-03 20:35:08 +09:00
Hermet Park
1e370712e0 loader svg: ++code readability
Use own bit operation helpers.
2023-04-26 11:15:48 +09:00
Mira Grudzinska
83ffe9f612 svg_loader: fixing grad overwritting
Gradient was mistakenly overwritten in
files in which the <def> section existed,
but grad was defined outside it.
2023-04-25 14:30:23 +09:00
Mira Grudzinska
74c9a5f795 svg_loader: changed update order
The gradient was updated before the style,
which resulted in only the URL tag being
inherited, but the gradient itself was not
applied to the node.
2023-04-25 09:01:19 +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
f089b77a45 svg_loader: fixing parsing empty elements
Self-closing tags (empty elements) were parsed until
the appearance of the '>' character, causing the '/'
char to be appended to the tag name. The final '/'
char should be omitted.
2023-04-17 09:57:52 +09:00
Mira Grudzinska
598c28a597 svg_loader: gradient inheritance implemented
Till now only the grad stops were inherited. Now all
grad attribs are.
Inheritance from different grad type is not supported.

@Issue: https://github.com/thorvg/thorvg/issues/1209
2023-04-15 17:43:42 +09:00
Mira Grudzinska
66ef84e7d7 svg_loader: code refactoring
Changed order of functions - needed in the grad
inheritance commit.
2023-04-15 17:43:42 +09:00
Mira Grudzinska
c7137a8105 svg_loader: forcing file loading completion
Svgs without any viewbox and width/height information
have to be loaded before any other action is taken.
This is necessary to get the valid sive/viewbox info.
2023-03-31 09:48:01 +02:00
Mira Grudzinska
be361221df svg_loader: handling zero width/height viewbox
For svgs with the width and/or height value set to zero
rendering was disabled - the load api return Result:Unknown
and draw - Result::InsufficientCondition.
Now an empty scene is added, so that both, load and draw,
return Result::Success.
2023-03-21 11:11:45 +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
9b3c34c3b1 updated copyright. 2023-01-14 13:48:11 +09:00
Mira Grudzinska
df9a28bf0a svg_loader: fixing name
_parserColor -> _parseColor
2023-01-07 10:52:56 +09:00
JunsuChoi
abb9df7c6b svg_loader: Change SVG viewbox variable type from int to float
The viewbox and size(width, height) defined in SVG can be of type float.
This prevents matrix calculation errors caused by this.
2022-12-12 23:48:52 +09:00
Hermet Park
93b88370ad svg loader: remove unused logic.
Please keep it simple and easy.

Don't leave a chance compiler warn it.
2022-09-02 12:02:39 +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
c93c2d3100 svg_loader: deeper search for postponed nodes
Till now the proper node was searched only among children,
now all the nodes are checked.
2022-09-02 11:15:08 +09:00
Mira Grudzinska
be4f382d99 svg_loader: prevent mem leaks
A necessary check added before strdup function is called
2022-08-31 11:27:37 +09:00