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;
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>
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.
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.
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.
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.
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
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;
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.
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.
* 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>
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.
* common Picture : Introduce Picture's size setter, getter APIs
If picture or file loaded by picture has an explicit Size(width, height),
it is transformed to fit the size.