Commit graph

1027 commits

Author SHA1 Message Date
Michal Maciola
a4a323929f loader: removed loader finding for LoaderMgr::loader(data, w, h, copy)
LoaderMgr::loader(data, w, h, copy) is dedicated for raw images only.
No need to try other loaders.
2021-08-04 15:25:17 +09:00
Hermet Park
dc7bb0deed tvg_saver: do not pass through if the view size is invalid. 2021-07-30 12:40:02 +09:00
Hermet Park
b3aed50a2e common loader: lookup in the numberic order. 2021-07-30 12:36:19 +09:00
JunsuChoi
b72ff371ee svg_loader SvgLoader: Add 'href' attribute for parser
"xlink:href" will be deprecated.
https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/xlink:href
2021-07-30 12:26:27 +09:00
Hermet Park
5e52134e2a dexample Picture: improve the test coverage.
In this patch, it replaced the test images with Lenna.
and fix the wrong jpeg file size figuring.
2021-07-30 12:09:59 +09:00
Hermet Park
e59ba67b7c tvg_format: optimize data format
This reduces tvg binary format size by converting PathCommand to more compact size.

This optimization increase +12% compress rate with our example:

195,668 => 174,071 (sum of all converted tvgs from svgs)

@Issues: https://github.com/Samsung/thorvg/issues/639
2021-07-30 10:35:30 +09:00
Hermet Park
a91bd37ea9
tvg_format: save/restore default view size in the data.
current bounding box of the paint is the default view size...

Do we have any better information of that?

This also fixes the wrong result after changing the size of the tvg picture.
2021-07-30 10:34:48 +09:00
JunsuChoi
37453a2dfd
sw_engine Raster: Apply bilinear interpolation to images
* Apply bilinear interpolation to images

Apply bilinear interpolation when drawing images with transformation
If the mapped coordinate value is a floating point value,
bilinear interpolation is performed using adjacent pixel values.
Interpolation is not performed in cases when the color values to beinterpolated
are the same or scale down case.
2021-07-30 10:31:59 +09:00
Hermet Park
ccc3c7d381 tvg_saver: code refactoring.
keep the macro naming convention.
2021-07-29 20:12:00 +09:00
Hermet Park
2db5d24c9f tvg_loader: code refactoring.
keep the macro naming convention
2021-07-29 17:26:36 +09:00
Hermet Park
4bdf346dbb tvg format: code refactoring
use SIZE() macro for consistency.
2021-07-29 16:45:14 +09:00
Hermet Park
87c6ce1f7c tvg_format: save/restore default view size in the data.
current bounding box of the paint is the default view size...

Do we have any better information of that?
2021-07-29 15:51:00 +09:00
Michal Maciola
eb810a92f2
svg_loader: allow multiple defs tags
If svg contained multiple defs tags only the first one was handled correctly.
Every next 'defs' tag was skipped and its inner elements parsed as it was
outside the defs.
2021-07-29 11:47:33 +09:00
Hermet Park
02081d8cdc common picture: correct non-working size() behavior.
Pixel-based image picture doesn't work at size() method.
Obvisouly, we missed to implement it properly.

This patch corrects it.

@Issue: https://github.com/Samsung/thorvg/issues/656
2021-07-29 11:44:18 +09:00
Hermet Park
750d170978 sw_engine raster: remove inlining.
Reduce the binary size,

Leave it to the best choice by the complier.
2021-07-28 19:56:37 +09:00
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