Commit graph

1355 commits

Author SHA1 Message Date
Hermet Park
3ae9e33c65 examples: replace sprintf() with snprintf()
snprintf() is more preferred to use in preventing buffer overflow.
2021-07-22 16:32:12 +09:00
Hermet Park
fe00e54257 tvg_saver: introduce a new module tvg saver
tvg saver is a new module to export tvg files.

In this patch, it also contains the infrastructure of saver module
to expand other types of savers such as png, jpg, etc.

To save the tvg file from a paint, you can use the Saver feature, for example:

auto saver = tvg::Saver::gen();
saver->save(paint, "sample.tvg");
saver->sync();

Later, you can read the "sample.tvg" using Picture.

auto picture = tvg::Picture::gen();
picture->load("sample.tvg");
...

The behavior of the saver will work on sync/async based on the threading setting of the initializer.
Thus if you wish to have a benefit of it, you must call sync() after the save() in the proper delayed time.

Otherwise, you can call sync() immediately.

Note that, the asynchronous tasking is depent on the saver module implementation.
Also, you need to enable tvg saver/loader modules from meson option. (yet this feature is under the beta)

@API Addition:
Result Saver::save(std::unique_ptr<Paint> paint, const std::string& path) noexcept;
Result Saver::sync() noexcept;

@Examples: tvgSaver

@Co-author: Mira Grudzinska <m.grudzinska@samsung.com>
2021-07-21 19:30:15 +09:00
Hermet Park
87d00b4121 tvg format: code refactoring #10
keep neat & clean code,
revise to tvg style naming convention.
2021-07-21 13:59:57 +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
Hermet Park
02b3d7dd20 tvg format: code refactoring #9
revise format of the macro names, no logical changes.
++ comments for maintenence.
2021-07-21 11:26:21 +09:00
Hermet Park
e0667ca7f1 tvg format: code refactoring #8
Hide iterator APIs, simplify it as much as it's necessary.
2021-07-20 20:06:55 +09:00
Hermet Park
ace58d5afd tvg format: code refactoring #7
remove return type values.
2021-07-20 15:55:51 +09:00
Hermet Park
21f8828890 tvg format: code refactoring #6
++ neat & clean code
2021-07-20 15:39:29 +09:00
Hermet Park
5b2d10d97a tvg format: code refactoring #5
replace from ofstream to FILE

We know both have the same purpose, we always prefer the less binary size.

So... this brings the binary size reduction.

1918496 => 1913528
2021-07-20 14:33:11 +09:00
Hermet Park
bccb1d29e3 examples: split Tvg to TvgSaver, PictureTvg
We'd like to clearly split showcases TvgSaver & Picture.
2021-07-20 14:10:05 +09:00
Hermet Park
9f9d4b62a0 examples: sort file list alphabetical. 2021-07-20 13:42:10 +09:00
Mira Grudzinska
30dafb26e0 tvg_saver: Tvg.cpp example modyfied
Previously the 'test.tvg' file was loaded from the EXAMPLE_DIR.
Now the 'test.tvg' file is created using the tvg saver module
(if in the EXAMPLE_DIR is alread a 'test.tvg' file, it is overwriten)
and then it's loaded using the tvg loader module.
2021-07-20 13:38:37 +09:00
Hermet Park
792b9db3fd tvg format: code refactoring #4
Remove an unnecessary internal reference.
2021-07-20 13:33:44 +09:00
Hermet Park
2eb920beaf tvg format: code refactoring #3
use the Array function instead of own implementation.
2021-07-20 13:31:25 +09:00
Hermet Park
8059a23f7c tvg format: code refactoring #2
code clean up, removed reserved data sector
2021-07-20 12:53:16 +09:00
Hermet Park
60e3129ce2 common saver: change to instance based for future sync/async behavior.
reserve sync() method TODO
2021-07-19 20:32:31 +09:00
Hermet Park
b13dec31cd common: code refactoring
unify tvg class identifiers
2021-07-19 20:12:14 +09:00
Mira Grudzinska
0150391f03
tvg_saver: implementation of the Saver class
The Saver class enables to save any Paint object (Scene, Shape, Picture)
in a binary file. To read the file the tvg loader should be used.
To save a paint a new API was introduced - tvg::Saver::save.
2021-07-19 17:31:36 +09:00
Mira Grudzinska
f23cba89f3
common: introducing basic iterators functionality
The introduced Iterator class enables to access the children nodes
of a given Paint.
2021-07-19 17:28:14 +09:00
Hermet Park
9ea6962c5a sw_engine renderer: code refactoring
+ trivial changes while reading the code.
2021-07-19 17:22:27 +09:00
Hermet Park
0ca69c49ff jpg_loader: code refactoring
remove unnecessary member variables.
2021-07-19 16:02:35 +09:00
Mira Grudzinska
96f22e282d
sw_engine: preventing a double application of the opacity (#540)
For filled and stroked shapes with a gradient, the opacity
was applied during the composition and during the ctable update.
To prevent this, in case the composition occured, ctable
is updated with the opacity = 255.
2021-07-19 16:02:10 +09:00
Michal Maciola
8826394b56
jpg_loader: decompress header on opening 2021-07-19 14:55:23 +09:00
Hermet Park
94eeb92dbe infra: seprate test image resources from the examples.
change for removing dependency.
2021-07-19 14:43:26 +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
1c30bb391f
example: logo_test.svg (#617)
Manually created svg with edited logo.svg that test most of the svg tags
and attributes
2021-07-14 13:57:32 +02:00
Michal Maciola
dc516df9d8
capi binding: added missing null paint check (#616) 2021-07-14 12:19:42 +02:00
Michal Maciola
30a3d442b9 svg_loader: image tag: fixed utf8 decode
Fixed svgUtilURLDecode function.
Deleted snippet was not needed and it broken decoding when space.
2021-07-14 10:08:15 +09:00
Michal Maciola
8e1d8b0cb2 svg_loader: race condition on arc processing
Unneeded static keyword in _pathAppendArcTo function led to race
conditioning
@issue: #604
2021-07-13 22:23:02 +09:00
JunsuChoi
233045f796 svg_loader SvgPath: Skip invalid path
If the d attribute of SVG path is not parsed through _nextCommand(),
it is regarded as an invalid data.
2021-07-12 16:43:44 +09:00
JunsuChoi
bbc0fbb130 svg_loader SvgUtil: Move nullcheck to before use
prevent invalid access
2021-07-12 13:37:42 +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
Hermet Park
26128807e1 commong shape: --sanitizer report
null pointer passed as argument 2, which is declared to never be null
2021-07-10 23:48:17 +09:00
Hermet Park
aa1a43e3a2 jpg_loader: code refactoring
keep it clean and neat code add some TODO comments for the future tasks.

This also fixes potential data memory leak.
2021-07-09 21:15:59 +09:00
Michal Maciola
cc71ff43e5 example svg: 'image-embeded.svg' added fix #2
Chenaged indent to tabs
2021-07-09 17:44:00 +09:00
Michal Maciola
9ea99e90e2 example svg: 'image-embeded.svg' added fix #1
Added png image with composition applied
2021-07-09 17:44:00 +09:00
Michal Maciola
f0815934d8 example svg: 'image-embeded.svg' added 2021-07-09 17:44:00 +09:00
Hermet Park
0d71a74de5 jpg_loader: change source file mode 664 2021-07-09 16:53:08 +09:00
JunsuChoi
91cf75ff04 jpg_loader JpgLoader: Prevent memory leak
If the copied data in JpgLoader's data open is invalid,
it is processed without being cleared.
Therefore, data memory free is handled in the destructor.
2021-07-09 16:50:45 +09:00
Michal Maciola
31f45fbd5f svg_loader: <image> tag introduced fix #9
Fixed Base64 and utf8 for new line and whitespace
Changed tvgSvgLoaderCommon.h to single line convention
2021-07-09 12:04:29 +09: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
48bc30e70a svg_loader: <image> tag introduced fix #7
fixed auto and new lines in tvgSvgUtil.cpp
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
Michal Maciola
3e4512a9a6 svg_loader: <image> tag introduced fix #5
Added copyAttr for image
2021-07-09 12:04:29 +09:00
Michal Maciola
e01f29270a svg_loader: <image> tag introduced fix #4
fixed mistyped vw to w and vh to h
2021-07-09 12:04:29 +09:00
Michal Maciola
d69805c668 svg_loader: <image> tag introduced fix #3
Added working composition
2021-07-09 12:04:29 +09:00
Michal Maciola
c35f7e1f64 svg_loader: <image> tag introduced fix #2
Removed #ifdef from tvgSvgSceneBuilder.cpp
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