Commit graph

1659 commits

Author SHA1 Message Date
Mira Grudzinska
1980d9d0e3 all: Trailing spaces removed 2023-01-07 10:53:51 +09:00
Mira Grudzinska
df9a28bf0a svg_loader: fixing name
_parserColor -> _parseColor
2023-01-07 10:52:56 +09:00
Mira Grudzinska
5bc6f4881a examples: fixing the crash for disabled loaders
ImageScaleUp/ImageScaleDown fixed.
2023-01-07 10:48:40 +09:00
Hermet Park
4082a13527 examples: keep aspect ratio of svg images.
changed by 3939b61770
2023-01-07 02:28:48 +09:00
Mira Grudzinska
5c59c9aa71 scene: fixing nested masking
For any type of masking composition may be required.

@Issue: https://github.com/Samsung/thorvg/issues/1295
2023-01-07 01:54:09 +09:00
Hermet Park
57e3efc6ab
Update README.md 2023-01-07 01:24:37 +09:00
Hermet Park
262303c8b8
Update README.md 2023-01-07 01:13:25 +09:00
Mira Grudzinska
12056d516f paint: fastTrack should return false for the skew transformations 2022-12-28 13:06:49 +09:00
Hermet Park
eff6b3aa6a
Update CONTRIBUTING.md 2022-12-28 13:03:14 +09:00
JunsuChoi
1769e1c4af common Util: Move to before decimal part calculation 2022-12-14 10:42:27 +09:00
JunsuChoi
439c918553 common Util: Skip if there is a space after the dot
Some SVG parsers allow parsing of "0."
If there is a space after the dot, skip to the next step.
2022-12-14 10:42:27 +09:00
Mira Grudzinska
4bdb58a8ca examples: fixing building errors on macOS
Reference to the 'count' was ambiguous (var name / std::count).
2022-12-14 10:41:42 +09:00
Mira Grudzinska
3732b2c54a authors: updating email address 2022-12-13 17:15:26 -08:00
JunsuChoi
abb9df7c6b svg_loader: Change SVG viewbox variable type from int to float
The viewbox and size(width, height) defined in SVG can be of type float.
This prevents matrix calculation errors caused by this.
2022-12-12 23:48:52 +09:00
Hermet Park
91730249ae test picture: add picture mesh api unit test
@Issue: https://github.com/Samsung/thorvg/issues/1241
2022-12-09 12:09:59 +09:00
Hermet Park
7c269a9f20 common picture: +exception handling.
invalid arguments won't be allowed.
2022-12-09 12:09:59 +09:00
Hermet Park
d78744bae3 test accessor: added accessor test unit test.
@Issue: https://github.com/Samsung/thorvg/issues/1243
2022-12-08 22:39:09 +09:00
Hermet Park
d958fc7971 saver/loader tvg: support picture mesh properties.
this mesh properites newly introduced in v0.8
(see: 3dd65dfed0)

tvg saver/loader should implement mesh support to
properly capture/replay the scene snapshot.

@Issue: https://github.com/Samsung/thorvg/issues/1242
2022-12-08 22:29:29 +09:00
Hermet Park
dc583325b3 examples TvgSaver: code refactoring.
extracted functions for a better readiabilty.
2022-12-07 14:56:25 +09:00
Hermet Park
f03b260b19 examples tvg: added texmap use-case. 2022-12-07 14:22:04 +09:00
Hermet Park
b02ebb9f7f Update AUTHORS 2022-12-06 20:39:42 +09:00
Hermet Park
725af47573
Update README.md 2022-12-03 12:07:26 +09:00
Hermet Park
b5549a3a7d
Update README.md 2022-12-02 10:52:35 +09:00
rinechran
69b342e3e9 docs : Installing thorvg using vcpkg 2022-12-02 10:39:44 +09:00
Hermet Park
dc477e197b common Accessor: removed deprecated api.
the old version of Accessor::access() is redundant,
we replaced it with set().

It's still under the beta, we can remove it immediately.
Note that we've planned to promote them official APIs in v0.9.

Newly changed, tagging beta again...w
2022-11-26 19:02:11 +09:00
Hermet Park
4ceb91ccea
Add files via upload 2022-11-26 13:42:03 +09:00
Hermet Park
57fd448f0d
Update README.md
added godot practice.
2022-11-26 13:41:36 +09:00
JunsuChoi
3ba0b8adff common Accessor: Add access API using std::function 2022-11-25 15:25:49 +09:00
JunsuChoi
6e26aab1b6 common Accessor: Add access api that with data parameter
It supports data parameters that
can pass user data to the callback function.

std::unique_ptr<Picture> access(std::unique_ptr<Picture> picture, bool(*func)(const Paint* paint, void* data), void* data) noexcept;
2022-11-25 15:25:49 +09:00
Mira Grudzinska
a863f29512 [svg2png] size limitation while converting the file
In case the svg file size is too large, a heap overflow occurred
when conversting to png. To prevent this a size limitation
has been added - the resolution of the resulting png file cannot
be higher than 8k (7680 x 4320).
2022-11-22 22:37:00 +01:00
JunsuChoi
0aec18dc75 SwRaster: Remove comment 2022-10-04 10:56:06 +09:00
JunsuChoi
ea26e8dff5 SwRaster: Prevent memory issue
If vv goes out of buffer, it can cause potential memory problems.
Therefore, an `if condition` is added so that it does not exceed the height of the image.
This is temporary fix.

Test)
meson -Db_sanitize=address,undefined -Dexamples=true . build
$ ./build/src/examples/Texmap

==6298==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x7f37fd6c2180 at pc 0x7f380d884599 bp 0x7fffb02b2db0 sp 0x7fffb02b2da0
READ of size 4 at 0x7f37fd6c2180 thread T0
    #0 0x7f380d884598 in _rasterPolygonImageSegment ../src/lib/sw_engine/tvgSwRasterTexmapInternal.h:107
    #1 0x7f380d887694 in _rasterPolygonImage ../src/lib/sw_engine/tvgSwRasterTexmap.h:271
    #2 0x7f380d88a598 in _rasterTexmapPolygonMesh ../src/lib/sw_engine/tvgSwRasterTexmap.h:639
    #3 0x7f380d89828d in _transformedRGBAImageMesh ../src/lib/sw_engine/tvgSwRaster.cpp:701
    #4 0x7f380d89828d in rasterImageMesh(SwSurface*, SwImage*, tvg::Polygon const*, unsigned int, tvg::Matrix const*, SwBBox const&, unsigned int) ../src/lib/sw_engine/tvgSwRaster.cpp:1585
    #5 0x7f380d89bf16 in tvg::SwRenderer::renderImageMesh(void*) ../src/lib/sw_engine/tvgSwRenderer.cpp:369
    #6 0x7f380d830e7e in tvg::Paint::Impl::render(tvg::RenderMethod&) ../src/lib/tvgPaint.cpp:178
    #7 0x7f380d823bd2 in tvg::Canvas::Impl::draw() (/home/junsu/dev/os/thorvg/build/src/examples/../libthorvg.so.0+0x265bd2)
    #8 0x7f380d821e79 in tvg::Canvas::draw() ../src/lib/tvgCanvas.cpp:60
    #9 0x557d07b2d5b6 in drawSwView(void*, _Eo_Opaque*) ../src/examples/Texmap.cpp:103
    #10 0x7f380cb7d2aa in evas_process_dirty_pixels ../src/lib/evas/canvas/evas_object_image.c:1894
    #11 0x7f380cb7d2aa in _evas_image_pixels_get ../src/lib/evas/canvas/evas_object_image.c:2318
    #12 0x7f380cb7d85e in _evas_image_render ../src/lib/evas/canvas/evas_object_image.c:2468
    #13 0x7f380cb7ea0c in evas_object_image_render ../src/lib/evas/canvas/evas_object_image.c:2271
    #14 0x7f380cbe51db in evas_render_mapped ../src/lib/evas/canvas/evas_render.c:2290
    #15 0x7f380cbe6f15 in evas_render_updates_internal_loop ../src/lib/evas/canvas/evas_render.c:3158
    #16 0x7f380cbe9912 in evas_render_updates_internal ../src/lib/evas/canvas/evas_render.c:3631
    #17 0x7f380cbeb31c in _evas_canvas_render_async ../src/lib/evas/canvas/evas_render.c:4094
    #18 0x7f380cb6634a in evas_canvas_render_async ../src/lib/evas/canvas/evas_canvas_eo.c:168
    #19 0x7f380cb6fce5 in evas_render_async ../src/lib/evas/canvas/evas_canvas_eo.legacy.c:179
    #20 0x7f37f3a81555 in _ecore_evas_x_render ../src/modules/ecore_evas/engines/x/ecore_evas_x.c:761
    #21 0x7f3809677e42 in _ecore_evas_idle_enter ../src/lib/ecore_evas/ecore_evas.c:295
    #22 0x7f38098a89a4 in _ecore_call_task_cb ../src/lib/ecore/ecore_private.h:456
    #23 0x7f38098a89a4 in _ecore_factorized_idle_process ../src/lib/ecore/ecore_idler.c:35
    #24 0x7f3809b29081 in _event_callback_call ../src/lib/eo/eo_base_class.c:2114
    #25 0x7f3809b29081 in _efl_object_event_callback_call ../src/lib/eo/eo_base_class.c:2186
    #26 0x7f3809b22d22 in efl_event_callback_call ../src/lib/eo/eo_base_class.c:2189
    #27 0x7f38098aae44 in _ecore_main_loop_iterate_internal ../src/lib/ecore/ecore_main.c:2466
    #28 0x7f38098ab689 in _ecore_main_loop_begin ../src/lib/ecore/ecore_main.c:1231
    #29 0x7f38098b05e0 in _efl_loop_begin ../src/lib/ecore/efl_loop.c:57
    #30 0x7f38098af77c in efl_loop_begin src/lib/ecore/efl_loop.eo.c:28
    #31 0x7f38098ab755 in ecore_main_loop_begin ../src/lib/ecore/ecore_main.c:1316
    #32 0x7f380d14ba1f in elm_run ../src/lib/elementary/elm_main.c:1359
    #33 0x557d07b2d298 in main ../src/examples/Texmap.cpp:176
    #34 0x7f380b533c86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21c86)
    #35 0x557d07b2d3c9 in _start (/home/junsu/dev/os/thorvg/build/src/examples/Texmap+0xb3c9)
2022-10-04 10:56:06 +09:00
Hermet Park
353e8316c2 gl_engine: fixed mismatched malloc/free calls. 2022-10-02 19:00:15 +09:00
Vincenzo Pupillo
2fd9bb76b6 gl_engine: fixed the signature of the prepare() method in GlRenderer
The implementation of the virtual prepare() method is different from that of RenderMethod.
from that of RenderMethod, so the compilation fails. This modification solves the problem.
2022-10-02 18:46:47 +09:00
JunsuChoi
a4afc72f33 wasm: add -flto option
Clang 16 of emsdk does not support `-flto=0` option.
so I temporarily add -flto option.

clang-16: error: unsupported argument '0' to option '-flto='

em++: error: '/home/junsu/dev/os/emsdk/upstream/bin/clang++ -target wasm32-unknown-emscripten -fignore-exceptions -fvisibility=default -I/home/junsu/dev/os/emsdk/upstream/emscripten/cache/sysroot/include/SDL --sysroot=/home/junsu/dev/os/emsdk/upstream/emscripten/cache/sysroot -Xclang -iwithsysroot/include/compat -O2 -Werror -fno-unroll-loops -g3 -flto=0 -c /home/junsu/dev/os/emsdk/upstream/emscripten/system/lib/embind/bind.cpp -o /home/junsu/dev/os/emsdk/upstream/emscripten/cache/build/libembind-rtti/bind.o' failed (returned 1)
2022-09-15 16:13:34 +09:00
JunsuChoi
b7eb1f80f0 wasm: remove empty space 2022-09-15 16:10:40 +09:00
JunsuChoi
91a6cdb9dc wasm: Update size calculation logic
revised the logic to align svg images in the center of the view.
this is the subsequent changes to 3939b61770.
2022-09-15 16:10:40 +09:00
Hermet Park
67b48ab772 examples: Added Texmap
added texture mapping example.

@Issues: https://github.com/Samsung/thorvg/issues/1241
2022-09-14 11:36:21 +09:00
Hermet Park
e2057d10f1 examples: updated svg.
revised the logic to align svg images in the center of the grids.

this is the subsequent changes to 3939b61770.
2022-09-02 12:10:36 +09:00
Hermet Park
93b88370ad svg loader: remove unused logic.
Please keep it simple and easy.

Don't leave a chance compiler warn it.
2022-09-02 12:02:39 +09:00
Mira Grudzinska
3939b61770
svg_loader: preserveAspectRatio attrib handled according to the svg standard (#1249)
* svg_loader: preserveAspectRatio attrib handled according to the svg standard

* svg_loader: symbol fixed

The correct width/height values used in the _useBuildHelper function.
Bug was propageted while the preserveAspectRatio attrib was handled,
now fixed.

* svg_loader: refactoring code regarding the preserveAspectRatio attrib

To avoid copy/paste a new function is introduced to handle the proper
scaling.

* svg_loader: initialize the svg loader members

The 'align' and 'meetOrSlice' svg loader members were not initialized.

* svg_loader: resize function forces any transformation

The resize function is called after the svg image is read and scaled
taking into account the proper preserveAspectRatio value. While resizing
the preserveAspectRatio isn't checked any more and the image can be
freely transformed.
2022-09-02 11:59:49 +09:00
Mira Grudzinska
c93c2d3100 svg_loader: deeper search for postponed nodes
Till now the proper node was searched only among children,
now all the nodes are checked.
2022-09-02 11:15:08 +09:00
Mira Grudzinska
313a4d1562 svg_loader: prevent stack-overflow for nested nodes 2022-09-02 11:13:45 +09:00
JunsuChoi
b7b8c2424c svg_loader: No skip luma mask when composition node is image
Improved to skip Luma Mask when conditions are the same
as AlphaMask for optimization in e409bb29.
If the composition node is an image, it is not skipped because
it is not known for sure whether to skip it.
2022-08-31 21:33:22 +02:00
Mira Grudzinska
be4f382d99 svg_loader: prevent mem leaks
A necessary check added before strdup function is called
2022-08-31 11:27:37 +09:00
JunsuChoi
b24e7c7402 svg_loader: Remove unnecessary code 2022-08-30 23:31:25 +02:00
JunsuChoi
eb936d1a81 svg_loader: If there is already set color url, it will be deleted.
When setting the url for color, if there is an already set url,
it will be overwritten after deletion. This prevents memory leaks.

asan result)

Direct leak of 2 byte(s) in 1 object(s) allocated from:
    #0 0x7ff1d547bc68 in __interceptor_malloc (/usr/lib/x86_64-linux-gnu/libasan.so.5+0x10bc68)
    #1 0x7ff1d4e435b4 in _idFromUrl ../src/loaders/svg/tvgSvgLoader.cpp:327
    #2 0x7ff1d4e44a8e in _toColor ../src/loaders/svg/tvgSvgLoader.cpp:558
    #3 0x7ff1d4e42ee9 in _parseStyleAttr ../src/loaders/svg/tvgSvgLoader.cpp:1033
    #4 0x7ff1d4e7f092 in simpleXmlParseAttributes(char const*, unsigned int, bool (*)(void*, char const*, char const*), void const*) ../src/loaders/svg/tvgXmlParser.cpp:361
    #5 0x7ff1d4e597d3 in _createPathNode ../src/loaders/svg/tvgSvgLoader.cpp:1363
    #6 0x7ff1d4e61359 in _svgLoaderParserXmlOpen ../src/loaders/svg/tvgSvgLoader.cpp:2723
    #7 0x7ff1d4e61c49 in _svgLoaderParser ../src/loaders/svg/tvgSvgLoader.cpp:2801
    #8 0x7ff1d4e7f3f6 in simpleXmlParse(char const*, unsigned int, bool, bool (*)(void*, SimpleXMLType, char const*, unsigned int), void const*) ../src/loaders/svg/tvgXmlParser.cpp:429
    #9 0x7ff1d4e639a1 in SvgLoader::run(unsigned int) ../src/loaders/svg/tvgSvgLoader.cpp:3121
    #10 0x7ff1d4dc8b75 in tvg::Task::operator()(unsigned int) ../src/lib/tvgTaskScheduler.h:68
    #11 0x7ff1d4dc8b75 in tvg::TaskSchedulerImpl::run(unsigned int) ../src/lib/tvgTaskScheduler.cpp:138
    #12 0x7ff1d4dc98f7 in tvg::TaskSchedulerImpl::TaskSchedulerImpl(unsigned int)::{lambda()#1}::operator()() const ../src/lib/tvgTaskScheduler.cpp:113
    #13 0x7ff1d4dc98f7 in void std::__invoke_impl<void, tvg::TaskSchedulerImpl::TaskSchedulerImpl(unsigned int)::{lambda()#1}>(std::__invoke_other, tvg::TaskSchedulerImpl::TaskSchedulerImpl(unsigned int)::{lambda()#1}&&) /usr/include/c++/9/bits/invoke.h:60
    #14 0x7ff1d4dc98f7 in std::__invoke_result<tvg::TaskSchedulerImpl::TaskSchedulerImpl(unsigned int)::{lambda()#1}>::type std::__invoke<tvg::TaskSchedulerImpl::TaskSchedulerImpl(unsigned int)::{lambda()#1}>(std::__invoke_result&&, (tvg::TaskSchedulerImpl::TaskSchedulerImpl(unsigned int)::{lambda()#1}&&)...) /usr/include/c++/9/bits/invoke.h:95
    #15 0x7ff1d4dc98f7 in void std:🧵:_Invoker<std::tuple<tvg::TaskSchedulerImpl::TaskSchedulerImpl(unsigned int)::{lambda()#1}> >::_M_invoke<0ul>(std::_Index_tuple<0ul>) /usr/include/c++/9/thread:244
    #16 0x7ff1d4dc98f7 in std:🧵:_Invoker<std::tuple<tvg::TaskSchedulerImpl::TaskSchedulerImpl(unsigned int)::{lambda()#1}> >::operator()() /usr/include/c++/9/thread:251
    #17 0x7ff1d4dc98f7 in std:🧵:_State_impl<std:🧵:_Invoker<std::tuple<tvg::TaskSchedulerImpl::TaskSchedulerImpl(unsigned int)::{lambda()#1}> > >::_M_run() /usr/include/c++/9/thread:195
    #18 0x7ff1d3a344bf  (/usr/lib/x86_64-linux-gnu/libstdc++.so.6+0xd44bf)

example)
<svg height="400" width="600" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/2000/svg">
   <defs>
      <radialGradient r="12" fy="10" fx="10" cy="10" cx="10" id="i" xlink:href="#d"/>
      <clipPath id="g" clipPathUnits="userSpaceOnUse">
         <path d="M0 10 10z" style="marker:none" fill="#fff" stroke-width="2"/>
      </clipPath>
   </defs>
         <path d="M0 10 Z" fill="url(#g)" style="fill:url(#i);fill-opacity:1"/>
</svg>
2022-08-30 23:31:25 +02:00
Mira Grudzinska
092a53b0aa svg_loader: fill and stroke paiint url were copied twice
The url were copied in the _copyAttr and in the _styleCopy
functions.
2022-08-29 12:00:35 +09:00
Mira Grudzinska
e36368c40c svg_loader: only the first css style node is interpreted
Since the css id selector is not supported in TVG, only the first
style node is taken into account.
2022-08-29 11:59:32 +09:00
Vincent Torri
b6ca58f655 Fix compilation error on Windows 2022-08-24 22:31:41 +09:00