Commit graph

1037 commits

Author SHA1 Message Date
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
f9d5c8b42d test: testPicture added .jpg and .png loading tests 2021-07-16 00:36:38 +09:00
Michal Maciola
58ad09a07a
test capi: added missing canvas, paint and shape tests
Added tests for tvg_canvas_reserve, tvg_canvas_update_paint, tvg_paint_duplicate, tvg_paint_set_composite_method, tvg_shape_cubic_to, tvg_shape_close
2021-07-16 00:34:54 +09:00
Michal Maciola
9bfacf2256
test capi: Stroke Radial Gradient
Added tvg_shape_get_gradient
2021-07-16 00:32:41 +09:00
Michal Maciola
c3aef76278 test: render jpg and png files 2021-07-16 00:29:39 +09:00
Michal Maciola
ba1a38ed39 test capi: Stroke Linear Gradient fix #2 2021-07-15 16:06:11 +09:00
Michal Maciola
a757e6b97d test capi: Stroke Linear Gradient fix #1
Added tvg_shape_get_gradient
2021-07-15 16:06:11 +09:00
Michal Maciola
3d672a4ea8 test capi: Stroke Linear Gradient 2021-07-15 16:06:11 +09:00
Michal Maciola
23db42e41c
github actions: added tvg and jpg loaders (#613)
* github actions: added tvg and jpg loaders

* github actions: added tvg and jpg loaders fix #1

Added install libturbojpeg
2021-07-15 09:24:13 +09:00
Michal Maciola
a8e13ed2b7 test: svg rendering
Added SVG file loading and rendering for increasing TC Line coverage
Line coverage for src/loaders/svg: 85.5%
2021-07-14 23:24:40 +09:00
Michal Maciola
9b276cc5fa test capi: scene added negative tests 2021-07-14 23:22:09 +09: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
99c37d01cc
Update README.md 2021-07-11 11:37:28 +09:00
Hermet Park
f1db784d87
Update LICENSE 2021-07-11 11:34:59 +09:00
Hermet Park
1238ea242d
Update AUTHORS 2021-07-11 11:33:43 +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
c9a083abce
Update CONTRIBUTING.md 2021-07-10 00:34:57 +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