Commit graph

1012 commits

Author SHA1 Message Date
Michal Szczecinski
1acc25b5ac sw_engine common: Added neon version of rasterRGBA32 API.
Changes:
- Added 'neon' vector option in build system
- Introduced neon version of rasterRGBA32 API, which improves
speed of the funciton on ARM cpu's around ~35%
2021-07-28 19:17:23 +09:00
Hermet Park
386888bd11 sw_engine: flush memory pool after drawing.
if many canvas instances own private memory pool,
the memory usage can be increased linearly.

To prevent memory usage, flush out memory pool from the clear()
if the canvas uses private memory pool.
2021-07-28 17:22:35 +09:00
Hermet Park
d213a67180 common loader: code refactoring
Bitmap based pictures doesn't need the viewbox,
LoaderModule should delegate the viewbox to the derived classes which
having vector-based image loaders such as svg, tvg.

In that case, paint resizing can be performed by the loaders by own
policy.
2021-07-28 14:16:18 +09:00
Hermet Park
3cb0caf2c4 common loader: code refactoring.
replace from Scene to Paint at the internal interface.

Picture doesn't need to know the returned Node type.
base class, Paint is enough to in the data passing.
2021-07-28 13:45:34 +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
7e5311fb86 sw_engine: -- unused header 2021-07-27 23:36:54 +09:00
Hermet Park
749a0fbb54 example performance: improve to print average... 2021-07-27 23:32:49 +09:00
Hermet Park
db85313328 example: add a sample for checking rendering performance. 2021-07-27 13:30:06 +09:00
Hermet Park
f66af5c8f5 tools svg2tvg: introduce a new tool for exporting tvg.
This is an utility to convert a file from svg to tvg
To use this, enable the feature by toggling in the meson option.

$meson build -Dtools="svg2tvg" ...

See also the usage:

Usage:
   svg2tvg [SVG file]

Examples:
    $ svg2tvg input.svg
2021-07-27 10:56:31 +09:00
Hermet Park
b3b9d8edf6 test paint: add missing Paint utc 2021-07-27 10:21:09 +09:00
Hermet Park
589a1d871b picture: paint() method shall not be public. 2021-07-26 20:45:02 +09:00
Hermet Park
57e086db64 sw_engine renderer: ++exception handling.
initialize a member with the default value.
2021-07-26 16:51:25 +09:00
Hermet Park
30ebf35c13 tvg_saver: fix the invalid data size.
sizeof(colors) indicates its pointer size, we actually intended to the structure size.
2021-07-26 16:18:37 +09:00
Hermet Park
5e3011f86e tvg_saver: +exception handling
close the file handle before returning the function.
2021-07-26 16:17:06 +09:00
Mira Grudzinska
18f4b96786 tvg_saver: removing saving the default values
The default values (stroke cap/join, fill rule/spread or color with alpha = 0)
were unnecessarily saved in the tvg format file.
2021-07-26 15:32:38 +09:00
Mira Grudzinska
82c7a96628 doc: ++ MemPool docs 2021-07-26 15:07:35 +09:00
Michal Maciola
330e258495
sw_engine: removed unused rleAlphaMask 2021-07-23 21:27:39 +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
Hermet Park
5024e7f952 svg_loader: code refactoring.
clean up about logging before replacing it with TVGLOG()
2021-07-23 15:24:59 +09:00
Hermet Park
02b0f6cfc9 doc: improved Saver documentation. 2021-07-23 14:19:17 +09:00
Hermet Park
05737f979f apis: promote beta apis to the official ones.
3 api candidates has been verified since it's tagged in beta,
we confirm that they are useful for tvg usages.

Here list shows the candidates apis:

@API Addition:

Matrix Paint::transform() noexcept;
CompositeMethod Paint::composite(const Paint** target) const noexcept;
Result SwCanvas::mempool(MempoolPolicy policy) noexcept;
2021-07-23 14:09:37 +09:00
Michal Maciola
934a95777c
common: style fixes (#644) 2021-07-22 13:35:26 +02:00
Hermet Park
e56476b7bd common: code refactoring.
renamed loader classes same to Saver classes

tvgLoaderMgr -> tvgLoader (tvgSaver)
tvgLoader -> tvgLoadModule (tvgSaveModule)
2021-07-22 17:30:02 +09:00
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
cc0abf18cb infra: add tvg saver in build test 2021-07-22 12:04:34 +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
f9d5c8b42d test: testPicture added .jpg and .png loading tests 2021-07-16 00:36:38 +09:00