Commit graph

99 commits

Author SHA1 Message Date
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
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
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
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
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
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
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
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
94eeb92dbe infra: seprate test image resources from the examples.
change for removing dependency.
2021-07-19 14:43:26 +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
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
Michal Maciola
957ad5d017 example: PictureJpg.cpp
Created an example for testing jpg loading
2021-07-08 23:17:05 +09:00
Hermet Park
89d35123d8 examples: add commentary for exceptions. 2021-06-23 13:10:02 +09:00
Hermet Park
58fefeb05f examples tvg: clean up for tvg consistency.
no logical changes.
2021-06-11 12:58:15 +09:00
mmaciola
2c1f165f19
TVG Loader/Saver module: tvg loader example 2021-06-11 12:51:35 +09:00
Hermet Park
b7431eab3e examples: updated samples.
one of children paint can not be updated immediately with a canvas.

the root paint must be passed, otherwise requesting whole canvas is the best idea.
2021-06-10 20:00:55 +09:00
Hermet Park
ea8d26a681 examples: revise examples
remove the show-cases that accessing the raw memory from the unique_ptr

we don't like to use those cases without any inevitable excuse.
2021-06-10 16:08:00 +09:00
Hermet Park
2401495c47 examples: updated svg samples 2021-06-10 11:59:45 +09:00
Hermet Park
85587bbe79 examples stacking: ++ scene stacking. 2021-06-09 21:07:13 +09:00
Hermet Park
6fce96a124 examples: fix wrong data size conversion.
pointer size becomes 32 to 64 bits up to machines.
it has to be 32 bits.
2021-05-01 12:56:49 +09:00
Hermet Park
2bd07c050c examples: fix wrong data size conversion.
pointer size becomes 32 to 64 bits up to machines.
it has to be 32 bits.
2021-05-01 12:49:23 +09:00
Hermet Park
3a538340aa infra: disable capi in default.
capi is not mandatory option in v0.1.

we can manually toggle it on when it's necessary.
2021-04-30 19:15:05 +09:00
Mira Grudzinska
0f9d3ff6e9 examples: ignoring pictures other than svgs in Stress.cpp
The picture->size() function does not work for raw/png pictures.
As a consequence enabling both, the svg and png file loaders,
resulted in the unintended behavior of the example.
2021-04-14 17:17:10 +09:00
Hermet Park
6cc7dfdc56 examples: revise picture sample code. 2021-04-01 20:05:07 +09:00
Mateusz Palkowski
ac3e848cfe minor fixes 2021-04-01 19:38:30 +09:00
Mateusz Palkowski
1046ed2c40 Added png loading example 2021-04-01 19:38:30 +09:00
Patryk Kaczmarek
cd6fb4f483 gradients: paint linerar gradients properly with mask composition method
@Issues: 243

Change-Id: Ie26a0b903af94a46683348e3fb7d8b554576997c
2021-03-31 20:38:16 +09:00
Hermet Park
f1fe36d8f6 common sw_engine: optimize single rectangle ClipPath.
If ClipPath is a singular rectangle,
we don't need to apply this to all children nodes to adjust rle span regions.

Rather than its regular sequence,
we can adjust render region as merging viewport that is introduced internally,

All in all,
If a Paint has a single ClipPath that is Rectangle,
it sets viewport with Rectangle area that viewport is applied to
raster engine to cut off the rendering boundary.

In the normal case it brings trivial effects.
but when use SVGs which has a viewbox, it could increase the performance
up to 10% (profiled with 200 svgs rendering at the same time)

Note that, this won't be applied if the Paint has affine or rotation transform.

@Issues: 294
2021-03-26 17:10:35 +09:00
Hermet Park
19fc4f4b37 examples: allow a desianted main thread capacity.
Maximum threads is not always peak the highest performance,
tvg examples guide user the proper threads count.
2021-03-24 14:19:01 +09:00
Hermet Park
1a7d41ce71 updated copyright 2021-03-23 14:31:58 +09:00
Hermet Park
e4a28869d1
examples: revise StrokeGradient
renamed GradientStroke & repositioned visuals.
2021-03-22 13:52:43 +09:00
Hermet Park
53d23e9862
common picture: fix crash at picture duplication.
A duplicated picture needs to access internal picture loader data
to get its properties while rasterizing.

But it missed the loader since it's not copied from origin.

Thus, we fix this by sharing the internal loader among the duplications and origin.

@Examples: Duplicate
2021-03-19 19:41:18 +09:00
Hermet Park
0faea8a9ab examples: clean up mask resources.
These are not proper for our svg examples.
2021-03-15 19:19:54 +09:00
Mira Grudzinska
ecf47fcec8 example: Duplicate.cpp modified
Duplication of the Picture with a raw image is added
2021-03-11 10:42:28 +09:00
Patryk Kaczmarek
6e59116137 example: AnimateMask images change
Change-Id: Iacd407c3e186f1f91c2bcbd9099f0b83a9dba264
2021-03-09 14:39:56 +09:00
Hermet Park
e64ff980b0 examples images: correct file change mode.
For consistency, thorvg keeps file chmod => 664.
2021-02-25 19:14:23 +09:00
Patryk Kaczmarek
03d48159e3 examples: new AnimateMask example and svg images with masks
Change-Id: I609597a5ecb710e9af9939a3028eeef691b66188
2021-02-25 12:24:19 +09:00
Michal Szczecinski
d6d65c3bd6
Issue 180 example (#212)
* examples: Added resize_cb to Capi example.

resize_cb in capi example is used to verify crash on reize described
in @180 issue.

* examples capi: Fixed file type from dos to unix.

Use the same code style as it is used in other examples.
2021-02-22 13:30:05 +09:00
Mira Grudzinska
20324dc48e example StrokeGradient
Example showing a gradient usage for a stroke.
2021-02-19 17:14:12 +09:00
Mira Grudzinska
e154bfb264 example ClipPath: update
Added example with non-overlaping clip and shape.
2021-02-09 09:10:34 +09:00
Patryk Kaczmarek
905fd46ccf sw_engine composition: invert alpha masking
composition invert alpha masking

@Examples: added InvMasking

@Issues: 31

Change-Id: I2ee9d428d5749240ddf2e6adbb7677dccbe1926f
2021-02-02 11:47:30 +09:00