Commit graph

352 commits

Author SHA1 Message Date
Mira Grudzinska
82c7a96628 doc: ++ MemPool docs 2021-07-26 15:07:35 +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
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
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
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
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
8aa941c4ab common picture: ++exception case.
Fixed load() to return InvalidArgument if the file path is invalid.
2021-07-02 14:01:52 +09:00
Hermet Park
2fd830c940 common shape: allow to reset stroke dash.
user may need to reset stroke dash to off,
now stroke api allows it.
2021-07-02 10:35:46 +09:00
Mira Grudzinska
6eea979dae common: introducing the composite API (getter)
The new API gets the composite method and the pointer to the composite
target of the given paint object.
2021-06-25 22:16:06 +09:00
Mira Grudzinska
96d6b47a64 common: PaintType enum changed to identifier in Paint class
The PaintType enum was used to set the paint type in the internal Paint
implementation. This solution is switched to an identifier with id() getter,
so that the information about the type can be reached from outside the Paint.
2021-06-25 22:13:20 +09:00
Hermet Park
ea668eae1d fix a build break in MSVC
add missing string header, string is used for a Picture::load() parameter
2021-06-22 14:35:46 +09:00
Hermet Park
0df8c00519 loaders: revise code from cce4b443b3
use copy variable instead of additional buffer pointer.
2021-06-22 10:42:34 +09:00
Michal Maciola
cce4b443b3 loaders: added copy param for Picture::load
@API Changed:
Result Picture::load(const char* data, uint32_t size, bool copy /*=false*/) noexcept
TVG_EXPORT Tvg_Result tvg_picture_load_data(Tvg_Paint* paint, const char *data, uint32_t size, bool copy);
2021-06-21 19:52:38 +09:00
mmaciola
16e39ee81b
TVG Loader/Saver: tvg loader introduced
This patch introduces tvg loader module for loading .tvg binary files.
This allows to load and reuse pregenerated scene.

tvg file format:
.tvg is a binary file format designed for saving/restoring the scene content.
It allows to save scenes and reuse them in other apps or to restore state of
the application.

@Example:
   auto picture = tvg::Picture::gen();
   picture->load(EXAMPLE_DIR"/tvg_file.tvg");
   canvas->push(move(picture));

@API Additions:
   Result paint(std::unique_ptr<Paint> paint) noexcept;

@Issue: Issue ticket is #375.
2021-06-11 12:49:37 +09:00
Hermet Park
13009657cd common canvas: supplement corner cases.
filled up corner cases to return the result properly.

Canvas newly has a drawing condition to prevent usage-violation.
2021-06-09 20:11:57 +09:00
Hermet Park
efa0035fe6 common initializer: correct the result value.
When memory is not allocated successully, it must return the FailedAllocation as the return value.
Previous initializer wrongly returns the value that case, this corrects it.
2021-06-03 20:48:02 +09:00
Hermet Park
c2b2aa92c3 infra: install capi header file only its binding option is enabled.
decouple the capi header from the default headers by replacing it in capi folder.
now it's also installed optionally.
2021-06-03 20:43:39 +09:00
Mira Grudzinska
ed7d8b73b9 common: added API to get the transformation matrix of the object 2021-06-02 19:03:20 +09:00
Hermet Park
2c37191584 api: --inproper const syntax.
compoiste() requires internal data change, its api syntax should not contain "const"

though this changes the api spec, but won't affect build break
since it allows wider usage.

@API Modification

from:
Result Paint::composite(std::unique_ptr<Paint> target, CompositeMethod method) const noexcept

to:
Result Paint::composite(std::unique_ptr<Paint> target, CompositeMethod method) noexcept
2021-06-02 16:42:08 +09:00
Hermet Park
54fa59e7c3 docs: -- beta tag.
Scene::clear() is ready to public.
2021-05-28 16:24:48 +09:00
Hermet Park
0394fa5ef5 common: fix a potential memory leak after clear()
Paints must clear canvas engine data if they were dismissed from the canvas,

1. Canvas::clear(free = false) must retain all the paints from the paints hierarchy
so that user keeps the all dangled paints lifecycle.
In this scenario, it could leak the engine data of paints, this patch fixes it.

2. Previously, t just keeps the immediate paints lives of canvas, but not them of children of scene nor picture.
This patch changes a policy which was not considered seriously,
Now it keeps the all paints lives through the tree-hieararchy.

3. Also changed the Scene::clear() behavior identical to Canvas::clear() for consistency.

@API Modification:

From: Result Scene::clear() noexcept;
To: Result Scene::clear(bool free = true) noexcept;
2021-05-28 16:19:01 +09:00
Hermet Park
af01f5b899 api doc: replace beta api desc to beta tag 2021-05-14 19:49:28 +09:00
Mira Grudzinska
dc637d0beb doc: linguistic changes in C++ API docs 2021-05-13 23:44:26 +09:00
Hermet Park
6dd414ee3b sw_engine: fix invalid data sharing at multi-threading.
We have encountered that multi-threading usage that user creates,
multiple canvases owned by multiple user threads.

Current sw_engine memory pool has been considered only for multi-threads,
spawned by tvg task scheduler.

In this case it's safe but when user threads introduced, it can occur race-condition.

Thus, Here is a renewal policy that non-threading tvg(initialized threads with zero),
takes care of multiple user threads bu changing its policy,
each of canvases should have individual memory pool to guarantee mutual-exclusion.

@API additions

enum MempoolPolicy
{
    Default = 0, ///< Default behavior that ThorVG is designed to.
    Shareable,   ///< Memory Pool is shared among the SwCanvases.
    Individual   ///< Allocate designated memory pool that is only used by current instance.
};

Result SwCanvas::mempool(MempoolPolicy policy) noexcept;

All in all, if user calls multiple threads, set memory pool policy to Individual.
2021-05-12 10:59:50 +09:00
Mira Grudzinska
924ea15cfa capi: added check against null pointer before dereferencing
TVG_RESULT_INVALID_ARGUMENT returned in case a nullptr passed as an argument
(does not apply to color getters).
The change is addressed in the docs file.
2021-05-11 12:09:23 +02:00
Mira Grudzinska
335880c58c docs: polishing up the C API docs 2021-05-06 14:12:37 +02:00
Hermet Park
28008e2f91
doc: polish up api documentation. 2021-04-30 18:53:20 +09:00
JunsuChoi
3908397d95 doc common: Add enum and struct docs in capi 2021-04-29 15:06:54 +09:00
JunsuChoi
706df374cf doc common: Groupping c APIs
C APIs
 - Initializer
 - Canvas
  - SwCanvas
 - Paint
 - Shape
 - Gradient
 - Picture
 - Scene
2021-04-29 15:06:54 +09:00
JunsuChoi
d7b3f0103e doc common: Add grouping of C++ api and C api
group ThorVG C++ APIs
group ThorVGCapi C APIs
2021-04-29 12:11:06 +09:00
Mira Grudzinska
ec1232b9b4 doc common: change of the return value in the composite API 2021-04-28 15:06:00 +02:00
Mira Grudzinska
3d5006740c doc common: adding the documentation for the C++ APIs
Added the missing descriptions for Sw/Gl/Canvas and Initializer.
@retval command applied.
2021-04-28 19:46:58 +09:00
JunsuChoi
6241fd054d doc common: Fix typo and missing parameter 2021-04-27 11:54:22 +02:00
Mira Grudzinska
7e35ec339a doc common: adding the documentation for the C++ APIs
The descriptions have been changed and new ones added.
There are still few apis for which descriptions are missing.
2021-04-25 17:16:13 -07:00
JunsuChoi
2cfc2bd241 doc common: Draft documentation for C++ header APIs
Write documentation for some of the APIs that have already been cleared up.
2021-04-21 17:57:24 +09:00
Michal Szczecinski
3ae9832684 capi: Added Inverted Alpha Mask composition enumeration.
Added missing composite method. Backend supports this compostion type.
2021-04-20 17:59:22 +09:00
Hermet Park
cb425fa4bb capi: fix incorrect composite api.
Api prototype is completely wrong, now it's corrected.
2021-03-04 11:33:24 +09:00
Mira Grudzinska
d86032df36
sw_engine: adding a gradient as a stroke feature
* sw_engine: adding a gradient as a stroke feature

Similarly as a shape may have a gradient fill so can the stroke.

* Capi: adding APIs for a gradient stroke

Co-authored-by: Hermet Park <hermetpark@gmail.com>
2021-02-19 17:16:10 +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
Patryk Kaczmarek
9b4769076f Capi: Composite Method binding 2021-01-26 20:36:40 +09:00
Michal Szczecinski
975fdc8a39 capi: Added doxygen comments and doxygen config file. 2021-01-25 23:25:11 +09:00
mmaciola
d0799d8fa1
Capi: Shape bounds binding
Co-authored-by: Michal Maciola <m.maciola@samsung.com>
2020-12-30 12:40:03 +09:00
Hermet Park
4767f83b99
common composite: code refactoring
Splited out ClipPath routine from other pixel compositions'
since yet it's unlikely compatible...

Also revise internal engine interfaces to be simpler.

This is a step forward to enhance masking feature.
2020-12-25 19:47:01 +09:00
Hermet Park
1e02d62d01 inc header: remove unnecessary declaration.
This log tag is not used. We can introduce it when it's necessary.
2020-12-18 19:25:24 +09:00
Hermet Park
82e3553b56 common sw_engine: fix build break.
some wrong merge conflicts left. resolve them.
2020-12-18 17:44:59 +09:00
Patryk Kaczmarek
4dbdcbd057
common composition: support Masking method
New feature - CompositeMethod::MaskAlpha

Newly Support AlphaMask. but it's unstable.

@Issues: 31
2020-12-18 17:40:54 +09:00
Hermet Park
1e78d1f845
picture: replace size parameter to float.
Considering smooth-resizing on sub-pixeling.
2020-12-08 12:27:13 +09:00