Commit graph

1725 commits

Author SHA1 Message Date
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
Hermet Park
5fa8aac2aa examples: fix a compilation error on windows.
../src/examples/Performance.cpp:32:8: error: 'uint' does not name a type; did you mean 'u_int'?
   32 | static uint cnt = 0;
      |        ^~~~
      |        u_int

@Issues: https://github.com/Samsung/thorvg/issues/1247
2022-08-23 22:44:24 +09:00
Vincent Torri
e918a8cb5b fix compilation of svg2png on Windows 2022-08-23 22:41:28 +09:00
Hermet Park
ddb9bbdf0e common picture: code refactoring.
keep api parameter naming consistency.

ptsCnt, cmdCnt, triangleCnt ...
2022-08-20 15:21:31 +09:00
Hermet Park
240bf6259a common picture: code refactoring.
++ neat & clean
2022-08-20 14:44:20 +09:00
Hermet Park
c0a246ee71 apis: removed BETA_API tag for identifiers and Accessor.
These apis are promoted to the official apis, released in v0.9
2022-08-20 14:28:48 +09:00
Hermet Park
3184317688
Update CONTRIBUTING.md 2022-08-20 13:25:27 +09:00
projectitis
510ffa571a Fix compiler warnings on windows 2022-08-20 12:30:35 +09:00
projectitis
3dd65dfed0 common picture: support image mesh feature
Tvg Picture newly provides mesh() api to support texture mapping.
These apis allows to have a coarse triangle list which have polygon coordinates
and texture uvs those are used for traditional polygon texture mapping.

Note that these apis are beta version.

@API Additions:

Result mesh(const Polygon* triangles, const uint32_t triangleCount) noexcept
uint32_t mesh(const Polygon** triangles) const noexcept

@Examples:

//Mapping with two polygons
Polygon polygon[2];

//First polygon
polygon[0].vertex[0].pt = {0, 0};
polygon[0].vertex[1].pt = {100, 0};
polygon[0].vertex[2].pt = {0, 100};
polygon[0].vertex[0].uv = {0, 0};
polygon[0].vertex[1].uv = {1, 0};
polygon[0].vertex[2].uv = {0, 1};

//Second polygon
polygon[1].vertex[0].pt = {100, 0};
polygon[1].vertex[1].pt = {100, 100};
polygon[1].vertex[2].pt = {0, 100};
polygon[1].vertex[0].uv = {1, 0};
polygon[1].vertex[1].uv = {1, 1};
polygon[1].vertex[2].uv = {0, 1};

//Apply polygons to the picture
picture->mesh(polygon, 2);

@Issues: https://github.com/Samsung/thorvg/issues/1218
2022-08-20 11:58:55 +09:00
Vincent Torri
6687defc0b Windows: set TVG_EXPORT to dllexport also for mingw
In addition, remove TVG_EXPORT from enum class. They are types
not symbols
2022-08-20 11:45:01 +09:00
JunsuChoi
638d69d635 sw_engine: Fix uninitialized variable
warning message
[35/42] Compiling C++ object src/libthorvg-0.dll.p/lib_sw_engine_tvgSwRaster.cpp.obj
In file included from ../src/lib/sw_engine/tvgSwRasterTexmap.h:96,
                 from ../src/lib/sw_engine/tvgSwRaster.cpp:83:
../src/lib/sw_engine/tvgSwRasterTexmapInternal.h: In function 'void _rasterPolygonImageSegment(SwSurface*, const SwImage*, const SwBBox*, int, int, uint32_t (*)(uint32_t), AASpans*)':
../src/lib/sw_engine/tvgSwRasterTexmapInternal.h:76:9: warning: 'maxx' may be used uninitialized [-Wmaybe-uninitialized]
   76 |         if (x2 > maxx) x2 = maxx;
      |         ^~
../src/lib/sw_engine/tvgSwRasterTexmapInternal.h:33:19: note: 'maxx' was declared here
   33 |     int32_t minx, maxx;
      |                   ^~~~
../src/lib/sw_engine/tvgSwRasterTexmapInternal.h:75:9: warning: 'minx' may be used uninitialized [-Wmaybe-uninitialized]
   75 |         if (x1 < minx) x1 = minx;
      |         ^~
../src/lib/sw_engine/tvgSwRasterTexmapInternal.h:33:13: note: 'minx' was declared here
   33 |     int32_t minx, maxx;
      |             ^~~~
2022-08-19 14:22:04 +09:00
Vincent Torri
de87cdc717 Windows: use _fullpath() instead of fullpath().
Fix compilation error
2022-08-17 19:44:05 +09:00
Hermet Park
714470e618 loaders raw: fix a compiler warnings on Windows.
fix the invalid conversion from float to uint32_t.

@Issue: https://github.com/Samsung/thorvg/issues/1229
2022-08-04 17:02:56 +09:00
Omar Polo
53074d250f fix OpenBSD compile issue
Linux seems the only system AFAICS to have alloca.h.  All the BSDs have
the declaration in stdlib.h
2022-07-13 10:28:46 +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
cb4bba83d9 updated AUTHORS 2022-06-05 15:26:39 +09:00
Rémi Verschelde
becb70f09d Cleanup FreeBSD preprocessor checks (if vs ifdef)
Should be equivalent but checking if the value is defined (`#ifdef`) is cleaner
than checking if it is set to something different from 0 (`#if`).
2022-05-24 10:32:53 +09:00
Martin Liska
0c987470af Fix building with GCC 13.
Fixes the following error:
../src/lib/tvgLzw.h:27:5: error: ‘uint8_t’ does not name a type
2022-05-23 22:39:24 +09:00
Hermet Park
0e8cd1e525 fix FreeBSD compile issue.
alloca is defined in stdlib.h on [freeBSD](https://www.freebsd.org/cgi/man.cgi?alloca)

additional fix to 75c1314ab0
2022-05-17 22:05:10 +09:00
Peter Vullings
47075bb3e6
Improve support for clang-cl on windows
* Better support for clang-cl on windows
* Fix runtime error caused by removing unwind tables
2022-05-14 00:17:30 +09:00
mundusnine
75c1314ab0 Fix on FreeBSD
Fix compile errors on FreeBSD.
- alloca is defined in stdlib.h on [freeBSD](https://www.freebsd.org/cgi/man.cgi?alloca)
Issue in [godot](https://cirrus-ci.com/task/5485473287110656?logs=build#L657)
2022-05-13 17:58:04 +09:00
JunsuChoi
8ef075eb27 svg2png: Add more error message types
Add a message according to the returned Result type.
2022-05-06 17:13:43 +09:00
JunsuChoi
0d010bdb6a svg_loader: Fix invaild '<' nested check
When Type is DOCTYPE, Child Entities start with '<'.
This condition is valid when general Elements (svg, g, path etc) are used.
Add a Doctype check to if condition.
(There can be various cases related to '<' nested case.
But for now, I only add Doctype considering the side effect.)
2022-05-05 11:36:16 +09:00
Hermet Park
1336e611c4 doc: updated
small icon wasn't visible. don't know why...
2022-04-07 23:56:02 +09:00
Hermet Park
70cc0bb302 doc: updated logo
also move the logo folder in the res.
2022-04-07 23:29:56 +09:00
Hermet Park
ff685e9a35
Update README.md 2022-04-07 23:04:44 +09:00
projectitis
6addd574dc Fix readme 2022-04-07 22:56:33 +09:00
projectitis
89bb9783d8 Updated branding 2022-04-07 22:56:33 +09:00
mgrudzinska
0da0f5fa46 svg_loader: clearing the parser stop flags 2022-04-05 20:07:33 +09:00
mgrudzinska
eb7b281898 svg_loader: fixing color parsing
Color given in percentages, ex."rgb(10%,20%,30%)", was incorrectly parsed.
2022-04-05 19:36:15 +09:00
mgrudzinska
470b885e65 svg_loader: fixing segf when passing a nullptr to strcmp
This occurred when a gradient has no 'id' attribute.
2022-04-03 22:42:26 +02:00
mgrudzinska
0925aa84a5 sw_engine: fixing oveflow
An overflow occurred for big shapes with a dashed stroke,
since a contour end points were stored as the uint16 type
(instead of the uint32 type).
2022-03-23 16:14:51 +09:00
mgrudzinska
1e8b8cbb53 svg_loader: symbol node without any viewbox/width/height info handled properly 2022-03-21 18:38:10 +09:00
Rémi Verschelde
bc5c29dd69 build: Add another <cstring> include for MinGW compatibility 2022-03-16 23:51:12 +09:00
Hermet Park
5122792ee5
Update README.md 2022-03-10 11:46:19 +09:00