Commit graph

25 commits

Author SHA1 Message Date
Hermet Park
a12accbc93 updated copyright 2025-01-03 14:32:31 +09:00
Hermet Park
6761c5c2a0 API: Replace the Canvas::clear() API with Canvas::remove() & draw()
Added a `clear` parameter to Canvas::draw(), allowing users to decide
whether to clear the target buffer before drawing.

To remove the paints from a canvas, please use Canvas::remove()

C++ API Removals:
- Result Canvas::clear(bool paints, bool buffer)

C++ API Modifications:
- Result Canvas::draw()
 -> Result Canvas::draw(bool clear)

C API Removals:
- Tvg_Result tvg_canvas_clear(bool paints, bool buffer)

C API Modifications:
- Tvg_Result tvg_canvas_draw(Tvg_Canvas* canvas)
 -> Tvg_Result tvg_canvas_draw(Tvg_Canvas* canvas, bool clear)

issue: https://github.com/thorvg/thorvg/issues/1372
2024-12-10 11:59:46 +09:00
Hermet Park
0ebbc614be api: 1.0 specification revision
- Enhanced Scene management to provide users with more control.
- Scenes now support adding specific scenes at defined positions and removing them as needed.
- Ensure safe access to Canvas, Scene paints() by adding const specifiers.
- Removed virtual specifier for the canvas primitive apis.
- Introduced a nested scene in the canvas to remove logic duplication.

C++ API Modification:
- Result Scene::push(Paint* paint)
 -> Result Scene::push(Paint* target, Paint* at = nullptr)
- Result Scene::clear(bool free = true)
 -> Result Scene::remove(Paint* paint = nullptr)
- Result Canvas::push(Paint* paint)
 -> Result Canvas::push(Paint* target, Paint* at = nullptr)
- list<Paint*>& Scene::paints()
 -> const list<Paint*>& Scene::paints() const
- list<Paint*>& Canvas::paints()
 -> const list<Paint*>& Canvas::paints() const

C++ API Addition:
- Result Canvas::remove(Paint* paint = nullptr);

C API Modifications:
- Tvg_Result tvg_scene_clear(Tvg_Paint* scene, bool free)
 -> Tvg_Result tvg_scene_remove(Tvg_Paint* scene, Tvg_Paint* paint)

C API Addition:
- Tvg_Result tvg_scene_push_at(Tvg_Paint* scene, Tvg_Paint* target, Tvg_Paint* at)
- Tvg_Result tvg_canvas_push_at(Tvg_Canvas* canvas, Tvg_Paint* target, Tvg_Paint* at)
- Tvg_Result tvg_canvas_remove(Tvg_Canvas* canvas, Tvg_Paint* paint)

issue: https://github.com/thorvg/thorvg/issues/2957
issue: https://github.com/thorvg/thorvg/issues/1372
2024-12-04 11:44:58 +09:00
Hermet Park
df8fc1949c test: ++paint reference counting 2024-11-20 01:53:25 +09:00
Hermet Park
ed01ef717e api: revise the spec
Remove the requirement for unique_ptr in the function prototypes.
This change will simplify the API usage, making it more streamlined
and user-friendly. However, memory management will now be the
responsibility of the user.

C++ API Modification:
- Result Paint::mask(std::unique_ptr<Paint> target, MaskMethod method) -> Result Paint::mask(Paint* target, MaskMethod method)
- Result Paint::clip(std::unique_ptr<Paint> clipper) -> Result Paint::clip(Paint* clipper)
- virtual Result Canvas::push(std::unique_ptr<Paint> paint) -> virtual Result Canvas::push(Paint* paint)
- std::unique_ptr<LinearGradient> LinearGradient::gen() -> LinearGradient* LinearGradient::gen()
- std::unique_ptr<RadialGradient> RadialGradient::gen() -> RadialGradient* RadialGradient::gen()
- Result Shape::strokeFill(std::unique_ptr<Fill> f) -> Result Shape::strokeFill(Fill* f)
- Result Shape::fill(std::unique_ptr<Fill> f) -> Result Shape::fill(Fill* f)
- std::unique_ptr<Shape> Shape::gen() -> Shape* Shape::gen()
- std::unique_ptr<Picture> Picture::gen() -> Result Picture::push(Paint* paint)
- std::unique_ptr<Scene> Scene::gen() -> Scene* Scene::gen()
- Result Text::fill(std::unique_ptr<Fill> f) -> Result Text::fill(Fill* f)
- std::unique_ptr<Text> Text::gen() -> Text* Text::gen()
- std::unique_ptr<SwCanvas> SwCanvas::gen() -> SwCanvas* SwCanvas::gen()
- std::unique_ptr<GlCanvas> GlCanvas::gen() -> GlCanvas* GlCanvas::gen()
- std::unique_ptr<Animation> Animation::gen() -> Animation* Animation::gen()
- Result Saver::background(std::unique_ptr<Paint> paint) -> Result Saver::background(Paint* paint)
- Result Saver::save(std::unique_ptr<Paint> paint, const char* filename, uint32_t quality = 100) -> Result Saver::save(Paint* paint, const char* filename, uint32_t quality = 100)
- std::unique_ptr<Saver> Saver::gen() -> Saver* Saver::gen()
- std::unique_ptr<Accessor> Accessor::gen() -> Accessor* Accessor::gen()

C++ API removal:
- template<typename T = tvg::Paint> std::unique_ptr<T> cast(Paint* paint)
- template<typename T = tvg::Paint> std::unique_ptr<T> cast(Paint* paint)

issue: https://github.com/thorvg/thorvg/issues
2024-11-09 12:29:15 +09:00
Hermet Park
0a16152d75 api: renamed the composite with mask.
Since we've separated ClipPath and Masking,
Masking now has a distinct and independent purpose.

API Modification:
 - enum class CompositeMethod -> enum class MaskMethod
 - Result Paint::composite(std::unique_ptr<Paint> target, CompositeMethod method) -> Result Paint::mask(std::unique_ptr<Paint> target, MaskMethod method)
 - CompositeMethod Paint::mask(const Paint** target) const -> MaskMethod Paint::mask(const Paint** target) const

issue: https://github.com/thorvg/thorvg/issues/1372
2024-10-16 14:41:26 +09:00
Hermet Park
76fb3f3cd9 api: clean up
promoted offical c++ apis (v0.15)
 - enum class BlendMethod
 - enum class CanvasEngine::Wg
 - virtual Result Canvas::viewport(int32_t x, int32_t y, int32_t w, int32_t h);
 - class Text
 - Result Text::fill(uint8_t r, uint8_t g, uint8_t b)
 - Result Text::fill(std::unique_ptr<Fill> f)
 - static Result Text::unload(const std::string& path)
 - static Result Text::load(const std::string& path)
 - static Result Text::load(const char* name, const char* data, uint32_t size, const std::string& mimeType = "ttf", bool copy = false)
 - static std::unique_ptr<Text> Text::gen()
 - class WgCanvas
 - static std::unique_ptr<WgCanvas> WgCanvas::gen()
 - static const char* Initializer::version(uint32_t* major, uint32_t* minor, uint32_t* micro)
 - class LottieAnimation

promoted official c apis (v0.15)
 - Tvg_Blend_Method
 - Tvg_Result tvg_engine_version(uint32_t* major, uint32_t* minor, uint32_t* micro, const char** version)
 - Tvg_Result tvg_canvas_set_viewport(Tvg_Canvas* canvas, int32_t x, int32_t y, int32_t w, int32_t h)
 - Tvg_Result tvg_paint_set_blend_method(Tvg_Paint* paint, Tvg_Blend_Method method)
 - Tvg_Paint* tvg_text_new(void)
 - Tvg_Result tvg_text_set_fill_color(Tvg_Paint* paint, uint8_t r, uint8_t g, uint8_t b)
 - Tvg_Result tvg_text_set_gradient(Tvg_Paint* paint, Tvg_Gradient* gradient)
 - Tvg_Result tvg_font_load(const char* path)
 - Tvg_Result tvg_font_load_data(const char* name, const char* data, uint32_t size, const char *mimetype, bool copy)
 - Tvg_Result tvg_font_unload(const char* path)
 - Tvg_Animation* tvg_lottie_animation_new(void)

removed experimental apis
 - BlendMethod paint::blend() const
 - bool Shape::strokeTrim(float* begin, float* end) const
 - Tvg_Result tvg_paint_get_blend_method(const Tvg_Paint* paint, Tvg_Blend_Method* method)
 - Tvg_Result tvg_shape_get_stroke_trim(Tvg_Paint* paint, float* begin, float* end, bool* simultaneous)
 - tvg_text_set_linear_gradient(Paint* paint, Tvg_Gradient* gradient)
 - tvg_text_set_radial_gradient(Paint* paint, Tvg_Gradient* gradient)

issue: https://github.com/thorvg/thorvg/issues/1372
2024-09-23 21:53:50 +09:00
Hermet Park
d70aa68dcc test: replaced ClipPath with clip() 2024-09-19 14:46:05 +09:00
Hermet Park
a746e1fcd6 renderer: blending refactoring++
- reordered the blending types to align with lottie spec.
- removed source over.
2024-09-09 21:18:13 +09:00
Hermet Park
43c87b4eb5 renderer/paint: revise the Paint::bounds() behavior
The current Paint::bounds(transform=true) returns the coordinates
of the paint in its local coordinates after transformation.

However, it did not convert the origin to the world coordinate.

This is problematic when the user wants to determine
the paint's position and size with the origin being the canvas.
Specifically, this matters that when the paint is belonged
to a certain scene.

Now, the bounds() method returns the coordinates
of the paint's bounding box with the corrected world space.
User can figure out the actual boundary within the painted result.

Remark that, this may break the functional behavior compatibility.
2024-08-07 12:02:22 +09:00
Hermet Park
eb86ac539c renderer: Rectified the paint transforms.
This corrects the return value to Result::InsufficientCondition
when a custom transform is applied.

Additionally, unnecessary x and y member fields have been removed.
2024-07-07 21:43:30 +09:00
Jinny You
2c6c8d3b21
updated copyright date (#1866) 2023-12-28 10:43:25 +09:00
Mira Grudzinska
c5a02b90df tests: bounds test ++
The 'transformed' arg of the 'bounds' api
wasn't tested. Added.
2023-08-01 14:53:12 +02:00
Hermet Park
3512beab9f test: ++blending 2023-06-20 11:30:18 +09:00
Martin Capitanio
4def2a679c Fix clang compiler warnings in unit tests.
[clang] Warn on unqualified calls to std::move and std::forward
See: https://reviews.llvm.org/D119670

[141/166] Compiling C++ object test/tvgUnitTests.p/testAccessor.cpp.o
../thorvg-git/test/testAccessor.cpp:58:29: warning: unqualified call to
'std::move' [-Wunqualified-std-cast-call]
    picture = accessor->set(move(picture), nullptr);
                            ^
                            std::
...
2023-06-07 16:56:30 +09:00
Hermet Park
72f89fcf53 test: add Inverse Luma Mask test cases 2023-05-20 20:11:58 +09:00
Hermet Park
9d9f38c875 common: code refactoring
Replace standard casting with tvg::cast()
2023-05-15 12:07:55 +09:00
Hermet Park
89dc7616cf test paint: ++CompositeMethod coverage 2023-05-09 23:19:15 +09:00
Hermet Park
5d930e51e4 test/examples: -- deprecated apis call warnings.
Result load(const char* data, uint32_t size, bool copy = false)
-> Result load(const char* data, uint32_t size, const std::string& mimeType, bool copy = false)

Result bounds(float* x, float* y, float* w, float* h)
-> Result bounds(float* x, float* y, float* w, float* h, bool transformed)
2023-04-22 18:32:22 +09:00
Hermet Park
f0ae3e9cee test: fix broken plugin support.
The thorvg test should not attempt to perform features
that were not enabled, as this will cause them to fail.

@Issues: https://github.com/thorvg/thorvg/issues/1251
2023-04-06 19:47:10 +09:00
Hermet Park
9b3c34c3b1 updated copyright. 2023-01-14 13:48:11 +09:00
Rémi Verschelde
46c3fc1f94 Format code files with dos2unix, ensure newline at EOF 2022-07-10 23:21:05 +09:00
Hermet Park
f0141e63de updated copyright date. 2022-01-12 14:08:48 +09:00
Hermet Park
fd74e0fae8 test: fix memory leak.
these duplicates are not unique_ptr, should be taken care.

@Issue: https://github.com/Samsung/thorvg/issues/995
2021-11-05 21:48:24 +09:00
Hermet Park
b3b9d8edf6 test paint: add missing Paint utc 2021-07-27 10:21:09 +09:00