Commit graph

1126 commits

Author SHA1 Message Date
Hermet Park
e381edacb7 tvg_loader: code refactoring.
no logical changes in the succesful cases,

change the code for better readibility.
and add log messages in the error scenario.
2021-09-07 18:18:09 +09:00
Hermet Park
f1d9f691cc tvg_saver: fix the incorrect stroke transformation
Saver tries to pre-transfom to skip the matrix data,
but it missed the case - transformed stroking,

we skip it also only when xy scaling factors are same excluding the dash properties,
because scaled of the stroking is depent on the engines,
we have no idea of the proper input data in advance.

@Issues: https://github.com/Samsung/thorvg/issues/773
2021-09-07 10:56:43 +02:00
Mira Grudzinska
b421660676 svg_loader: parsing flags in the elliptical arc curve
Since the arc flags can have values 0 or 1, we reported as
an error cases, when a float value was given.
Since the EBNF grammar can be used, we misread some paths.
Removing the condition that prevents giving a float as a flag solves
this problem and is in agreement with the w3 specs.
2021-09-07 13:15:50 +09:00
Hermet Park
d21089ddfd
tvg_saver: save the missing scene reserve count. (#771)
This reserved count was just missed,
Aside from it, tvg_loader logic is not well organized (hard to expect)
We can refine it by recovering the data tree structure in the reverse order.

@Issues: https://github.com/Samsung/thorvg/issues/768
2021-09-06 08:38:18 +02:00
Hermet Park
eddd253c55
tvg_loader: code refactoring & optimization loading. (#772)
Skip the reassigning values by the flags,
We assume those property values are reserved,
leave to apis that handle the invalids if the exceptions.
2021-09-06 08:35:11 +02:00
Mira Grudzinska
5cad097485 sw_engine: handling clips from outside the render region
Clips from outside the rendering region were ignored resulting
in rendering shapes, which should be completely clipped.
In case of the clip fast track, the bounding box width/height
overflow occured and shape, that should be clipped, could be
visible (not always).
2021-09-06 13:16:45 +09:00
Hermet Park
d6193dddd0 Revert "sw_engine avx: the not aligned memory separated in the rasterRGBA32 func"
This reverts commit dafc229a75.
2021-09-03 11:08:40 +09:00
Mira Grudzinska
dafc229a75 sw_engine avx: the not aligned memory separated in the rasterRGBA32 func
The aligned and not aligned memory parts handled separately.
This gives around 10% of the performance increase (tested on i7-8700 CPU)
2021-09-03 11:06:59 +09:00
Michal Maciola
3ded3e359d utc: testing loading and saving .tvg
Added tests of loading and saving .tvg.
Created testSavers.cpp. Created files tag.tvg and test.tvg. Minor change
in tag.svg.
2021-09-03 11:02:25 +09:00
Mira Grudzinska
5c504cbfe6
test SwEngine: increasing lines coverage (#767)
All functions from tvgSwStroke.cpp called.
2021-09-02 15:04:44 +02:00
Mira Grudzinska
dddb38d900 test SwEngine: _rasterTranslucentRect added into the tests 2021-09-01 17:26:07 +09:00
Mira Grudzinska
2fb07d9ac8 test SwEngine: raster image functions included into the unit tests
All image rastering funcions called in the 'Image Draw' test case.
2021-09-01 17:25:42 +09:00
Mira Grudzinska
3a54c5e219 sw_engine: calling avxRasterTranslucentRect instead of its c version
For avx vector support the avxRasterTranslucentRect should be called
instead of cRasterTranslucentRect (mischanged in 01e1fec367).
2021-08-31 15:17:28 +02:00
Mira Grudzinska
d7cb87971b
docs: minor linguistic changes (#759) 2021-08-31 15:15:03 +02:00
Michal Maciola
bf2e9631bf
svg2png: changed help message (#762) 2021-08-31 11:19:18 +02:00
Mira Grudzinska
a1480bedb1
svg2png: fixing the args interpretation (#760)
The background color was misinterpreted and its value was treated
as an svg file name (warning was returned).
The color format can not be passed in a `#ffffff` format, since
the '#' sign is used in bash to comment a line and nothiing after
it is loaded.
2021-08-31 11:14:16 +02:00
Hermet Park
c6becf4ec6 tvg_loader: guarantee the buffer ends with the null character
the issue is detected by asan.
2021-08-30 21:36:09 +09:00
Mira Grudzinska
c0e21bfcee sw_engine neon: refactoring
One if statement less.
2021-08-30 20:47:21 +09:00
Mira Grudzinska
36ac948ec9 sw_engine neon: fix the iterations number of 'neon calls'
In the case, when the dst memory was not aligned,
we went out of the dst range in the 'neon loop'.
2021-08-30 20:46:36 +09:00
Michal Maciola
4b8229f1c3
README: updated svg2png section (#758) 2021-08-30 12:40:29 +02:00
Hermet Park
e9871361a2
Update README.md 2021-08-30 19:05:12 +09:00
Hermet Park
01e1fec367
sw_engine: code refactoring.
simplify neon code and fix the wrong range access.
2021-08-30 16:54:43 +09:00
Hermet Park
37e8011325 tvg_loader: fixed a wrong delete call.
delete is not expected here, malloc-free must be paired.
2021-08-30 15:36:31 +09:00
Mira Grudzinska
dee32053c6 tvg saver: enabling gradient transformation
A gradient transformation was omitted when saving
into the tvg format. Fixed
2021-08-30 12:47:39 +09:00
JunsuChoi
700abffd38 doc: Enhance appendPath docs
Added description according to api behavior change
2021-08-30 11:07:47 +09:00
Hermet Park
2fcc06b553 tvg_format: fix broken clippath region.
there some multiple wrong calculation about size during tvg optimiation.
this patch fixes them.

1. picture needs to return the current desired size because
it will save the transformed the geometry. the final size should be
recorvered as the base size from the loader.

2. clippath missed to multiply parents transform, it's fixed.

@Issue: https://github.com/Samsung/thorvg/issues/752
2021-08-28 23:13:07 +09:00
Michal Maciola
ed31fc215f wasm: fix loading for binary files
This patch changes load function in thorvgwasm.cpp for using size()
instead of strlen(). It fixes loading of binary files like .tvg.
2021-08-28 16:02:51 +09:00
Hermet Park
f2252787ee sw_engine shape: prevent crash when wrong pair of commands & points.
add an exception handling,
if the given points count is not matched with expected points count from commands.

@Issue: https://github.com/Samsung/thorvg/issues/735
2021-08-28 15:59:29 +09:00
Mira Grudzinska
54b328b1a9 sw_engine avx: addad ALPHA_BLEND and avxRasterTranslucentRect functions
Both functions implemented using 128-bit registers.
avxRasterTranslucentRect is around 5 times faster than cRasterTranslucentRect (i7-8700 CPU - Coffe Lake)
2021-08-28 15:55:50 +09:00
Michal Maciola
7be4bf4c4f wasm: intoduce saveTvg via File System API
This patch adds saveTvg() function into thorvgwasm.cpp.
Functions saves tvg using File System API.
To enable fs, changed build flag: -s FORCE_FILESYSTEM=1.
Increase in result thorvg-wasm.js size: about 68kB to about 125kB.
2021-08-28 15:35:48 +09:00
Michal Maciola
fe474856b9 tvg_loader: make sure the pointer does not exceed the size 2021-08-27 11:45:37 +09:00
Hermet Park
d599f744c8 tvg format: fix broken encoding/decoding.
a regression bug was introduced by 52a7a257b2
in size calculation of data in case of uncompressed version.

@Issue: https://github.com/Samsung/thorvg/issues/739
2021-08-25 21:48:30 +09:00
Hermet Park
3d80f0a9e9 common picture: quick fix the broken bounds() interface.
picture must return the boundary info - 0, 0, w, h
We assume that it has a designated picture size.

Aside from this issue,
bounds() api must be reviewed, its behavior is quite in a trouble...
unless the result is not transformed, its information is useless...

@Issue: https://github.com/Samsung/thorvg/issues/741
2021-08-25 19:32:26 +09:00
Michal Maciola
ae3141d65c svg: fix opacity percentage value parsing
Percentage values wasn't handled by _toOpacity() function. Other incorrect values
was handled wrongly. Now fixed.
2021-08-25 14:57:30 +09:00
Hermet Park
f5f1e9f3a4
Update CONTRIBUTING.md 2021-08-24 20:35:06 +09:00
Michal Szczecinski
94a3e92fdd sw common: Added neon translucent rect API implementation.
Changes:
Added neonRasterTranslucentRect implementation. Rendering was tested on
32 lottie fiels. Without neon ~ 18.1 FPS was measured. With neon ~ 20.1
FPS was measured.
2021-08-24 18:44:08 +09:00
Hermet Park
52a7a257b2 tvg_format: newly introduced for tvg data compression.
By choosing compress option, tvg tries to compress the data to reduce the binary size.
Since the compression has the double-edges sword, we provides an option to users
to select it by their demand. Basically, compression is better than non-compression.

After profiling, we decided to use the encoder/decoder of Guilherme R. Lampert's.

Here is the profiling result:

test.tvg: 296037 -> 243411 (-17%)
tiger.tvg: 54568 -> 50622 (-7%)
image-embedded.tvg: 2282 -> 1231 (-46%)

@Issue: https://github.com/Samsung/thorvg/issues/639

About compression method:

Lempel–Ziv–Welch (LZW) encoder/decoder by Guilherme R. Lampert

This is the compression scheme used by the GIF image format and the Unix 'compress' tool.
Main differences from this implementation is that End Of Input (EOI) and Clear Codes (CC)
are not stored in the output and the max code length in bits is 12, vs 16 in compress.

EOI is simply detected by the end of the data stream, while CC happens if the
dictionary gets filled. Data is written/read from bit streams, which handle
byte-alignment for us in a transparent way.

The decoder relies on the hardcoded data layout produced by the encoder, since
no additional reconstruction data is added to the output, so they must match.
The nice thing about LZW is that we can reconstruct the dictionary directly from
the stream of codes generated by the encoder, so this avoids storing additional
headers in the bit stream.

The output code length is variable. It starts with the minimum number of bits
required to store the base byte-sized dictionary and automatically increases
as the dictionary gets larger (it starts at 9-bits and grows to 10-bits when
code 512 is added, then 11-bits when 1024 is added, and so on). If the dictionary
is filled (4096 items for a 12-bits dictionary), the whole thing is cleared and
the process starts over. This is the main reason why the encoder and the decoder
must match perfectly, since the lengths of the codes will not be specified with
the data itself.
2021-08-24 14:24:17 +09:00
Hermet Park
80f02c64d1
Update README.md 2021-08-24 14:22:28 +09:00
Hermet Park
077132e9d9 res: updated images 2021-08-24 14:20:56 +09:00
Hermet Park
ff32d7ce2e res: updated images.
documentation images are not updated,
remove the file first and add again.
2021-08-24 14:19:20 +09:00
Hermet Park
e845256057 res: updated images. 2021-08-24 14:14:03 +09:00
Hermet Park
8d02b459ad
Update README.md 2021-08-24 14:13:02 +09:00
Michal Maciola
8ed6a1a12d utc: increase coverage of picture and fill 2021-08-20 12:36:09 +09:00
Michal Maciola
f66ea21e9c utc: increase coverage SwEngine 2021-08-20 12:35:25 +09:00
Hermet Park
2ceee70fcf wasm: turn off the vectorization.
We can visit this feature later when it's stable.
2021-08-20 12:33:18 +09:00
Michal Maciola
d82b088b7a utc: increase coverage up #1 2021-08-19 14:49:14 +09:00
Michal Maciola
3a05ae4c01 utc: increase coverage up 2021-08-19 14:49:14 +09:00
Hermet Park
6f95e9dbe7 infra: simplify vector meson option.
neon/avx can't be resided in together,
we replace it with a string variable.
2021-08-19 14:46:59 +09:00
Michal Maciola
78dd50acc0
svg2png: enhance the feature.
Svg2png fully redesigned.
Introduced whole directory parsing. Created flags interface.

Usage:
   svg2png [svgFileName] [-r resolution] [-b bgColor]

Flags:
    -r set output image resolution.
    -b set output image background color.

Examples:
    $ svg2png input.svg
    $ svg2png input.svg -r 200x200
    $ svg2png input.svg -r 200x200 -b ff00ff
    $ svg2png input1.svg input2.svg -r 200x200 -b ff00ff
2021-08-18 20:29:10 +09:00
Michal Maciola
399caaaff9 picture: fix reloading images
Calling picture->load after it was already once called resulted in
segmentation fault or memory leak (depending on whether the vector (svg, tvg)
or raster (jpg, png, raw) file was loaded).
This patch checks the image has already been loaded. If so, the load()
returns InsufficientCondition.

@issue: fixes #719
2021-08-18 19:17:14 +09:00