Commit graph

2067 commits

Author SHA1 Message Date
Hermet Park
d4dc625481 examples MaskMethods: add a new example
This is introduced for Masking Methods.
2023-06-03 15:50:48 +09:00
Hermet Park
fddc409728 common sw_engine: adds missing composite methods.
Now tvg user could combine Mask Alpha & Mask Method like this:

paint->composite(target, tvg::CompositeMethod::AddMask);

binary size diff: 201307 -> 223399 (+22kb)

@APIs:
- CompositeMethod::AddMask
- CompositeMethod::SubtractMask
- CompositeMethod::IntersectMask
- CompositeMethod::DifferenceMask

@Issue: https://github.com/thorvg/thorvg/issues/404
2023-06-03 15:50:48 +09:00
Hermet Park
b45c8efd75 doc: ++Colorspace description
@Issue: https://github.com/thorvg/thorvg/issues/1372
2023-06-01 10:59:06 +09:00
Hermet Park
9032c00347 sw_engine texmap: code optimization.
Unify textmap methods that are overly duplicated with each other.

Still trying to simplifying raster code so that thorvg could introduce
the a bunch of masking method code nicely.

This reduces the size like: 214773 -> 212843 (-2kb)
2023-05-31 18:07:57 +09:00
Hermet Park
01974f652c sw_engine: code refactoring.
Unify raster methods that are overly duplicated with each others.
2023-05-30 20:07:34 +09:00
Hermet Park
86d287038b sw_engine: minor code clean up
keep code consistency, no logical changes.
2023-05-30 20:07:34 +09:00
Hermet Park
eb8539e0b4 sw_engine fill: optimize linear/radial fill fetching.
Save the separated for-loop by
unifying the blending/composition in one fetching stage.
2023-05-29 09:45:21 +09:00
Hermet Park
4d842d03f6 sw_engine: code refactoring.
unify raster methods that are overly duplicated with each other.
2023-05-29 09:45:21 +09:00
Hermet Park
28257ec807 common masking: optimize InvAlphaMask
try fast track if InvAlphaMask has 0 opacity + rectangle shape.
2023-05-29 09:45:21 +09:00
Hermet Park
62963268cb sw_engine: code cleanup
Remove unused template multiply.
Currently, 8-bit multiplication is the only valid operation.
2023-05-29 09:45:21 +09:00
Hermet Park
ee9b947c0c sw_engine: optimize alpha blending operation.
Compact blending instructions by distinquish the
shape & images. since we gurantee the shape color is
premultiplied alpha.

As a result, this enhanced performance by 0.002s in examples/Performance
on my local machine.

This also contains code cleanup chores.
2023-05-29 09:45:21 +09:00
Hermet Park
36919dc70f examples Texmap: extending the feature scenario. 2023-05-29 09:45:21 +09:00
Hermet Park
f4c9c4189e examples: changed the screen size. 2023-05-29 09:45:21 +09:00
Martin Capitanio
8b810bed87 tvgJpgd.cpp: Warnings - set but unused variables.
[41/145] Compiling C++ object src/libthorvg.a.p/loaders_jpg_tvgJpgd.cpp.o
../src/loaders/jpg/tvgJpgd.cpp:1339:17: warning: variable 'bytes' set but not used [-Wunused-but-set-variable]
    uint32_t c, bytes = 0;
                ^
../src/loaders/jpg/tvgJpgd.cpp:1773:29: warning: variable 'row_block' set but not used [-Wunused-but-set-variable]
    int mcu_row, mcu_block, row_block = 0;
                            ^
../src/loaders/jpg/tvgJpgd.cpp:1876:9: warning: variable 'row_block' set but not used [-Wunused-but-set-variable]
    int row_block = 0;
        ^
3 warnings generated.
2023-05-24 10:12:57 +09:00
Martin Capitanio
42a04bbc77 CI: Fix ubuntu-latest apt-get install ... 404 Not Found. 2023-05-23 14:49:58 +09:00
Vincenzo Pupillo
368ff01618 Fix invalid conversion error in Avx raster. 2023-05-22 10:34:25 +09:00
Martin Capitanio
2a56c43c84 infra: Avoid meson warning.
WARNING:: You should add the boolean check kwarg to the run_command call.
         It currently defaults to false,
         but it will default to true in future releases of meson.
         See also: https://github.com/mesonbuild/meson/issues/9300
2023-05-22 00:06:08 +09:00
Hermet Park
4838c25fa4 sw_engine raster: compact blender alpha table size. 2023-05-20 20:11:58 +09:00
Hermet Park
5643ecabd8 sw_engine: code refactoring
Introduced a blender alpha() to maintain clean and organized code.
2023-05-20 20:11:58 +09:00
Hermet Park
72f89fcf53 test: add Inverse Luma Mask test cases 2023-05-20 20:11:58 +09:00
Hermet Park
0aae65a171 sw_engine code refactoring.
Introduced a compositor table to maintain clean and organized code.
2023-05-20 20:11:58 +09:00
Hermet Park
7e1a647a36 examples: added InvLumaMasking sample. 2023-05-20 20:11:58 +09:00
Hermet Park
21c7debf14 composite: Support Inverse Luma Masking
The CompositeMethod now includes the newly supported InvLumaMask option:

The source pixels are converted to grayscale (luma values),
and the complement of the target's pixels is alpha blended.
As a result, only the part of the source where the grayscale
is not covered by the target is visible.

@APIs: CompositeMethod::InvLumaMask

@Example: examples/InvLumaMasking.cpp

@Issue: https://github.com/thorvg/thorvg/issues/404
2023-05-20 20:11:58 +09:00
Martin Capitanio
6f715b46a7 Fix clang compiler warnings.
[clang] Warn on unqualified calls to std::move and std::forward
See: https://reviews.llvm.org/D119670
2023-05-20 20:10:56 +09:00
Mira Grudzinska
ca0f30c4c0 tests: capi test for tvg_shape_set_paint_order 2023-05-20 13:23:47 +09:00
Mira Grudzinska
2309a48369 capi: tvg_shape_set_paint_order introduced
Capi sets the rendering order of the stroke and the fill.
2023-05-20 13:23:47 +09:00
Hermet Park
5ceeb32ef0 api: remove a beta api.
- Result Picture::viewbox(float* x, float* y, float* w, float* h) const;  //c++
- vg_Result tvg_picture_get_viewbox(const Tvg_Paint* paint, float* x, float* y, float* w, float* h);  //c

@Issue: https://github.com/thorvg/thorvg/issues/1372
2023-05-20 13:22:52 +09:00
Hermet Park
f633717e9f test shape: add stroke order test 2023-05-20 13:22:52 +09:00
Hermet Park
4c60415c0c apis: promote beta apis to offical ones.
- unique_ptr<Picture> Accessor::set(std::unique_ptr<Picture> picture, std::function<bool(const Paint* paint)> func);
- static Accessor::std::unique_ptr<Accessor> gen();
- Result Shape::order(bool strokeFirst);

@Issue: https://github.com/thorvg/thorvg/issues/1372
2023-05-20 13:22:52 +09:00
Hermet Park
fe14e4f499 api: rename beta apis.
- SwCanvas::Colorspace::ABGR8888_STRAIGHT -> SwCanvas::Colorspace::ABGR8888S
- SwCanvas::Colorspace::ARGB8888_STRAIGHT -> SwCanvas::Colorspace::ARGB8888S

@Issue: https://github.com/thorvg/thorvg/issues/1372
2023-05-20 13:22:52 +09:00
Martin Capitanio
baf21761f7 infa: Install svg2png and svg2tvg.
Meson can install stripped versions to
the standards-compliant (or --prefix) location.
2023-05-19 18:15:06 +09:00
Hermet Park
0e960e2d2b sw_engine: remove an unused function. 2023-05-19 10:56:59 +09:00
Hermet Park
f2fdc380b4 fix compiler warnings on MacOS
warning: unqualified call to 'std::move' [-Wunqualified-std-cast-call]
2023-05-19 10:56:59 +09:00
Hermet Park
89db13037d common sw_engine: gather scattered stroking composition.
There are two branches for completing stroke composition between the canvas and sw_engine.

It is necessary to centralize the task on the canvas engine side so that
we can maintain the logic without confusion.
2023-05-19 10:35:24 +09:00
Hermet Park
3626ded041 examples svg: adjust window size.
Still some display size is not enough large.
2023-05-19 10:35:24 +09:00
Hermet Park
d55ba07646 examples masking: updated for stroking composition. 2023-05-19 10:35:24 +09:00
Hermet Park
6994925b9d common shape: fixing stroking composition issue.
When combining Shape, Stroke, and AlphaMasking, there is a missing
composition step which results in an incorrect output as expected by the user.

This problem is resolved by introducing shape fill and stroking composition.

@Issue: https://github.com/thorvg/thorvg/issues/209
2023-05-19 10:35:24 +09:00
Hermet Park
4938c3253c doc: updated godot image. 2023-05-18 00:54:40 +09:00
Hermet Park
42e0f8c3a3 infra: enable strip flag only when it's requeted.
$meson . build -Dstrip=false  //off
$meson . build -Dstrip=true   //on
2023-05-17 22:17:10 +09:00
Hermet Park
1672badb7c package: add thorvg preprocessor for static linking 2023-05-17 22:17:10 +09:00
Hermet Park
d8687314a6 common picture: fix a composition bug.
Previously, a picture with a half-translucent mask would not function correctly.
This fix addresses the bug by applying the expected composition step.

Note: Even after applying this patch, a half-translucent mask with shape fill alpha will still not work properly.
We should consider removing the fill alpha property, as it duplicates the Paint opacity.

@Issue: https://github.com/thorvg/thorvg/issues/1423
2023-05-17 11:11:55 +09:00
Hermet Park
c7d77b3517 common scene: fix a potential composition bug.
In the current implementation, only a scene with a single shape type
is able to skip the composition step. However, a child picture might
have multiple children shapes as well, which leads to the bug.
2023-05-17 11:11:55 +09:00
Vincent Torri
be2de28312 portability: fix usage of TVG_API
Rule of thumb on Windows:
  * for a DLL:
    * if the library is built, set TVG_API to __declspec(dllexport)
    * if the library is used, set TVG_API to __declspec(dllimport)
  * for a static library, set TVG_API to nothing

To set TVG_API for a static library, TVG_STATIC is defined when the stataic library is built.
Otherwise, TVG_API is correctly set for a DLL.
Also sun and intel compilers are handled

@issue: https://github.com/thorvg/thorvg/issues/1446
2023-05-16 18:55:33 +09:00
Hermet Park
41c41b538d examples: updated SVG samples.
increase the canvas to afford more resources.
2023-05-16 11:46:28 +09:00
Mira Grudzinska
2cfa5505c3 svg_loader: fixing finding defs node
In the case when a 'use' node was used
in a 'defs' block  and the element it
referenced was also defined within the same
'defs' block, the reference node could not
be cloned. This was because the 'defs' node
could not be located.

@Issue: https://github.com/thorvg/thorvg/issues/1451
2023-05-16 10:43:45 +09:00
Mira Grudzinska
40ef9031ba svg_loader: copy the use node properties
A bug was observed when a 'use' node was
referenced in another 'use' node.

@Issue: https://github.com/thorvg/thorvg/issues/1451
2023-05-16 10:42:35 +09:00
Hermet Park
9d9f38c875 common: code refactoring
Replace standard casting with tvg::cast()
2023-05-15 12:07:55 +09:00
Hermet Park
4d722623a6 api: introduce cast() template method.
The cast() method is a utility function used to
cast a 'Paint/Fill' to type 'T'.

This would help users to write code optimal.

@API Additions:
template<typename T> std::unique_ptr<T> cast(Paint* paint)
template<typename T> std::unique_ptr<T> cast(Fill* fill)
2023-05-15 12:07:55 +09:00
Hermet Park
0fb8ed38d7 api: remove extern "C"
Remove extern "C specifier. ThorVG has the C binding,
C++ apis doesn't need to be compatibile with a C compiler.
This limits the C++ style template interface.
2023-05-15 12:07:55 +09:00
Hermet Park
aa000f7c56 api: remove deprecated apis
- Result Paint::bounds(float* x, float* y, float* w, float* h) const noexcept;
- Result Picture::load(const char* data, uint32_t size, bool copy = false) noexcept;

@Issue: https://github.com/thorvg/thorvg/issues/1372
2023-05-13 18:30:11 +09:00