Commit graph

998 commits

Author SHA1 Message Date
Hermet Park
36270f588e common: replace the id() -> identifier() 2021-10-22 18:47:05 +09:00
Hermet Park
78d85d714a common: Introduce class type identifier apis.
This identifier is useful when user identify the instance type in runtime.

ThorVG basically don't prefer to dynamic_cast() nor typeid(),
it compiles with -fno-rtti option for the optimial size.

Here is an example for the simple usage.

if (paint->identifier() == Shape::identifier())
  auto shape = static_cast<Shape*>(paint);

@Issue: https://github.com/Samsung/thorvg/issues/693
2021-10-22 18:47:05 +09:00
JunsuChoi
d3ba000d80 png_loader meson: Remove dependency check using find_library()
meson's find_library() throws an error when the package cannot be found.
png static library is added, so it should be passed when package is not found.
Therefore, delete unnecessary find_library.
2021-10-22 16:32:57 +09:00
Ji2z
fcb0258b3c common: Fix typo
Fix typo backeneds to backends
2021-10-22 15:10:02 +09:00
Hermet Park
2e6715ba41 loader png: support static png loader
Copied only necessary decoding functions from the lodepng opensource.
See: https://lodev.org/lodepng/

additional changes:
- disabled crc for the optimal size.
- converted the format bgr -> rgb for our png example.

Still we don't have a concrete idea for the image formats,
We should fix the converting methods between bgra <-> rgba.

@Issue: https://github.com/Samsung/thorvg/issues/594
2021-10-21 22:39:50 +09:00
Hermet Park
b0c964cbb4 svg_loader: code refactoring.
cast to proper value type.
2021-10-21 15:15:07 +09:00
JunsuChoi
1b675adca4 svg_loader XMLParser: Clean up parameter type
size_t to unsigned int
2021-10-21 15:03:47 +09:00
JunsuChoi
e5196d610d svg_loader XMLParser: Refacotring simpleXmlParse method
1.
Remove macro function. The existing macro function
was doing meaningless nested `return false`.

2.
Extract the logic to find the type as a function.

3.
The SimpleXMLType::Error case is not actually used,
and in case of invalid XML, Do 'return false' immediately.
2021-10-21 15:03:47 +09:00
Hermet Park
9c8e785fdc updated license
Add missing original copyright texts in the source code.
2021-10-20 22:50:07 +09:00
Michal Maciola
d7a3aa580a svg_loader: fix potential mem corruption in _idFromUrl function
This patch fixes some potential memory corruptions in _idFromUrl function
when name (url) is longer than 50 chars or is incorrectly terminated.
2021-10-20 10:34:02 +09:00
Mira Grudzinska
e0aa007659 common: new api for a grad transformation
The new apii allows to transform the gradient fill.
2021-10-19 17:43:24 +09:00
Mira Grudzinska
e6f8aa1379 capi: example modified 2021-10-19 10:27:37 +09:00
Hermet Park
a3ecff9504 svg_loader util: fix the floating constant truncated to zero issue.
fyi, the minimum value of the float is 1.175494351 E-38

@Issue: https://github.com/Samsung/thorvg/issues/899
2021-10-15 15:20:01 +09:00
Mira Grudzinska
1abee9f8d5 svg_loader: fixing viewBox clipping
For vw=width and vh=height, vx or vy > 0 had no effect. Fixed
2021-10-15 12:33:26 +09:00
Michal Maciola
e186bb4a82 svg_loader util: fix missing quot
There was checking for 0 ('\0') that should be checking for '0'
2021-10-15 02:04:17 +09:00
Hermet Park
f4d284df2a infra: add "all" option for tools.
just for developer convenience.
2021-10-14 14:54:24 +09:00
Mira Grudzinska
95430fc645 capi: change defines to enum
Tvg_Engine enum introduced to replace TVG_ENGINE_SW/GL defs.
2021-10-14 12:39:54 +09:00
Michal Maciola
1f42f7da89 wasm: saveTvg add compress option 2021-10-13 21:24:53 +09:00
Hermet Park
d9f421ff4a svg_loader util: just fix a typo
exponet -> exponent
2021-10-13 20:12:51 +09:00
Hermet Park
5a6240bdf3 svg_loader util: code refactoring
fix for thorvg coding convention.

no logical changes.
2021-10-13 20:07:08 +09:00
Mira Grudzinska
e6debdbf15
capi: tvg_swcanvas_set_mempool capi added (#903)
* capi: tvg_swcanvas_set_mempool capi added

* tests: tvg_swcanvas_set_mempool added to the tests
2021-10-13 19:31:39 +09:00
Hermet Park
0f0a0ae4f0 bindings capi: code refactoring
fix for code consistency, no logical changes.
2021-10-13 19:02:55 +09:00
Mira Grudzinska
600055dacd capi: saver capis added 2021-10-13 18:58:18 +09:00
Mira Grudzinska
d40d2ea288 capi: introduced Tvg_Colorspace enum instead of defs
Used in the tvg_swcanvas_set_target() capi.
2021-10-13 18:55:17 +09:00
Mira Grudzinska
0bffe930ad tvg_saver: fix the argument of the sizeof call
We got the size of a pointer instead of the size of a whole table.
Fixed now
2021-10-13 18:46:21 +09:00
Mira Grudzinska
0497ac894e svg_loader: removed unused variable
The gradient values passed to the scene builder are always given as percentages,
so there is no need to mark/check that.
2021-10-13 18:40:05 +09:00
Mira Grudzinska
e0488f4a8d capi: tvg_gradient_duplicate() added 2021-10-13 18:34:02 +09:00
Mira Grudzinska
39af185de8 docs: ++ 2021-10-12 14:04:18 +02:00
Mira Grudzinska
c2bbdccac1 svg_loader: removed unnecessary casting
The used scaling factor should be a float - casting it to an int caused
misevaluation of the radial gradient radius
2021-10-11 18:59:23 +09:00
Hermet Park
4219d2b8ea tools svg2tvg: remove unused header 2021-10-11 15:43:28 +09:00
Mira Grudzinska
883e44ad40 svg2tvg: added missing array lib 2021-10-11 15:30:36 +09:00
projectitis
dad6c71b6c
all: fix warnings on MSVC
* Explicit casts to suppress warnings
* Fixed compiler warnings
2021-10-09 11:33:45 +09:00
Michal Maciola
e12729e0d3 wasm: fix compilation
After 'all: fixing clang warnings' (e7c3a91) there was a problem with wasm
compilation, as strncpy and strdup.
Disable define is __EMSCRIPTEN__.
2021-10-09 11:32:27 +09:00
Michal Maciola
cba7cf0e2b
example: added image-embeded-jpeg.svg (#890) 2021-10-08 17:38:18 +02:00
JunsuChoi
5e7981106b infra : add window build (with loaders) 2021-10-07 15:00:48 +09:00
Mira Grudzinska
a16e91b441 all: fix compiler warnings
pow->powf and sqrt->sqrtf
2021-10-07 14:49:00 +09:00
Hermet Park
9737dd4a89 test capi: update tvg_paint_get_bounds() utc.
The api has been changed by 060564cc93
update it according its change.
2021-10-06 22:17:18 +09:00
Hermet Park
ca9a9c3a42 capi: replaced bounds() api with the latest.
The next api of c++ version has been deprecated

Tvg_Result tvg_paint_get_bounds(const Tvg_Paint* paint, float* x, float* y, float* w, float* h);

instead, we introduce the next one under the beta.

Tvg_Result tvg_paint_get_bounds(const Tvg_Paint* paint, float* x, float* y, float* w, float* h, bool transformed);
2021-10-06 22:17:18 +09:00
Mira Grudzinska
dc55070ba7 docs: c and c++ apis docs improved 2021-10-06 22:11:17 +09:00
Hermet Park
a2ac28d0c5
infra: add all option to enable all loader formats.
just for developer convenience (including me)

ex) $meson . build -Dloaders="all" ...
2021-10-06 11:13:49 +09:00
Mira Grudzinska
e7c3a91aa1 all: fixing clang warnings
fopen->fopen_s, strdup -> _strdup, strncpy -> strncpy_s
__declspec(dllexport) -> __attribute__ ((visibility ("default")))
2021-10-06 11:13:12 +09:00
JunsuChoi
5124a9ad6b infra: Add window build test in CI
Add build test for normal build
2021-10-06 10:44:51 +09:00
Mira Grudzinska
78363c3aad Revert "sw_engine: border cases for gradients"
This reverts commit 284298445b.
2021-10-06 01:13:02 +02:00
Mira Grudzinska
284298445b sw_engine: border cases for gradients
According to the svg standard, in a case when 'x1==x2 and y1==y2'
for a linear gradient or when 'r==0' for a radial gradient, the area
should be painted as a single color - the last gradient stop color.
2021-10-05 15:24:07 +02:00
Mira Grudzinska
fc29d888f1 docs: ++ docs of the load apis 2021-10-05 14:16:41 +02:00
Hermet Park
ff20974632 loaders: prepare for static jpg/png loaders.
This patch has 2 purposes,

1. revise the loaders infrastructure to support both static/external linking loaders.
2. add a template for static jpg/png loaders after external jpg/png.

Our default loaders prefer static linking, external loaders are only available
when dependent libraries on the build system are found.

You might wonder why we have the external loaders together,
they might be faster than static loaders since the popular libraries are likely to be well maintained,
fine-grained optimized.

Thus in this patch, meson tries to apply the external loaders first
then see if the dependencies were found or not,
if it's failed, it turns to the default static loaders.

Next this patch, we need the contribution for actual static jpg/png loaders implementation.

@Issue: https://github.com/Samsung/thorvg/issues/594
2021-10-05 19:22:51 +09:00
Mira Grudzinska
875e5bd058
svg_loader: proper handling width/height units (#851)
Units of the svg width and height tags were incorrectly assigned.
Percentage values will be handled separately.
2021-10-05 12:04:40 +02:00
Mira Grudzinska
5b7f94a527 capi: picture size apis added 2021-10-05 16:03:10 +09:00
Mira Grudzinska
72727ea322 capi: removed repeated comments 2021-10-03 15:12:46 +02:00
Projectitis
00fe44fc71 Portable fallthrough attribute 2021-10-02 12:34:11 +09:00