Commit graph

1076 commits

Author SHA1 Message Date
Hermet Park
205e463160 sw_engine raster: code refactoring
keep it neat & clean code with descriptions.
2021-11-10 18:26:31 +09:00
Hermet Park
d73ecc5524 sw_engine raster: code refactoring
renamed internal variables, no logical changes.
2021-11-10 17:34:27 +09:00
Hermet Park
cffc87e7b1 sw_engine raster: code refactoring.
keep the code thorvg convention.
2021-11-10 17:03:07 +09:00
Mira Grudzinska
8c4b679fb7 sw_engine: unification of mask and inv mask functions
The function pointers used to pass the proper blending method - mask
or inverse mask.
2021-11-10 13:07:57 +09:00
Hermet Park
097e10fea4 sw_engine renderer: fix the invalid memory access in the corner case.
Tasks can be disposed while the renderer referencing it.
Now, we can delete the tasks with lazy approach by introducing some tags.

@Issue: https://github.com/Samsung/thorvg/issues/995
2021-11-09 20:38:12 +09:00
Mira Grudzinska
14c1562b36 tvg_saver: fix memory leaks
In the cae when Result::InsufficientCondition was retured by the save()
api, the user had to remember to delete the passed paint - fixed.
Also path was not released.
2021-11-09 20:15:06 +09:00
Hermet Park
6ba2bc8eb3 tvg_loader: fix asan report.
revert c31c77c0fb

memory mis-alignment is detected by asan tool.
2021-11-09 17:11:10 +09:00
Hermet Park
cbcb85cd7c sw_engine renderer: code refactoring
free the member resources in the destructor.
2021-11-09 16:09:44 +09:00
Hermet Park
74413a989f common paint: fix a memory leak.
delete dangling object properly in the corner case.

Unfortunately, this brings to correct the capi test cases.
we assume the paints is deleted whenever its result is successful or not.

@Issue: https://github.com/Samsung/thorvg/issues/995
2021-11-09 14:51:32 +09:00
Hermet Park
37e39866dd common: ++exception handling.
fix the memory leak in the corner case

detected by tvg test suites

@Issue: https://github.com/Samsung/thorvg/issues/995
2021-11-09 14:16:15 +09:00
JunsuChoi
6400493859 tvg_saver TvgSaver: Initialize local value
If paint has no path information or stroke information,
it is not referenced inside bounds.
This will access the uninitialized variable at line 759, 760.
2021-11-08 19:39:01 +09:00
Hermet Park
2aa551e222 common array: + exception handling.
properly handle if the realloc() is failed.

@Isssue: https://github.com/Samsung/thorvg/issues/995
2021-11-08 12:28:17 +09:00
Hermet Park
b956b0a7e0 sw_engine raster: fix build break.
trivial mistake by cdf7019b19
2021-11-05 20:59:54 +09:00
Michal Maciola
545d3ead67
WASM: unpremultiplyBuffer fixes (#999) 2021-11-05 10:32:41 +01:00
Hermet Park
45f521618c sw_engine image: ++missing logs. 2021-11-05 17:43:08 +09:00
Hermet Park
cdf7019b19 sw_raster image: add error logs to notify issues. 2021-11-05 17:42:19 +09:00
Mira Grudzinska
7bc7ab83d0 sw_engine: functions supporting a masking of the clipped images are missing
To preserve the naming convention function '_rasterTranslucentImageRle'
is reanmed to '_translucentImageRle'. The '_rasterTranslucentImageRle'
function is though created - it checks the composition method and calls
the corresponding function. Missing functions are marked, but not implemented
(separate commit).
2021-11-05 17:36:25 +09:00
Hermet Park
c790e18de6
svg_loader: reduce binary size
saved 800 bytes.
2021-11-05 17:17:20 +09:00
Hermet Park
88d34f0d9a svg_loader: reduce binary size
removed the std::string usages.

saved 17kb.
2021-11-05 17:12:53 +09:00
Mira Grudzinska
b85eaddcf2 svg_loader: passing the svgPath information into the _applyComposition
An image can be a mask, so the information about it's path is necessary
during a composition application.
2021-11-05 13:10:52 +09:00
Mira Grudzinska
0501863195 svg_loader: mask node loaded as a scene
Since the mask is a container element (in opposite to the clipPath),
it has to be loaded as a scene.
2021-11-05 13:10:52 +09:00
Mira Grudzinska
40f2baabae svg_loader: SvgCompositeNode type introduced
Clips and masks require to implement some additional variables,
so the new node type has been introduced. Implementation of the usage
of these additional variables will be the subject of a separate
commit.
2021-11-05 13:10:14 +09:00
Hermet Park
eadb7fc4af binary size optimization.
replaced new/delete with malloc/free

saved 936 bytes
2021-11-04 20:10:21 +09:00
Hermet Park
b289950a5f common shape: code refactoring.
cast to float type properly.
2021-11-04 17:35:30 +09:00
Michal Maciola
f222124c40 WASM: Use ARGB8888. Convert into ABGR and unmultiply after sync()
Wasm needs ABGR STRAIGHT buffer.
As there is a problem using ABGR for loaders, it is better to use ARGB8888.
This patch makes wasm using ARGB8888 and relocate pixels and unmultiply after sync().
2021-11-04 17:12:05 +09:00
Hermet Park
c3a29bd648 common math: code refactoring
introduce common math functions to improve the reusability.
2021-11-04 17:11:27 +09:00
Hermet Park
7c1b16ba11 common shape: ++tiny optimization
reduce the binary size by 80 bytes.
2021-11-03 20:24:36 +09:00
Hermet Park
b705822732 optimize binary size.
apply two more compiler options to reduce binary size.

Saved about 7kb.
2021-11-03 20:04:12 +09:00
Hermet Park
0f2d7e3eef jpg_loader: fix compiler warnings.
"warning: shifting a negative signed value is undefined [-Wshift-negative-value"
2021-11-02 19:49:57 +09:00
Hermet Park
c31c77c0fb tvg_loader interpreter: tiny optmization
skip memory copy as possible.
2021-11-02 19:47:08 +09:00
Mira Grudzinska
6b132d77e8 tvg_saver/tvg_loader: gradient fill in the tvg format
Introducing the gradient transform() apis and changing the grad
algorithms made it possible to apply the shape's transformation
before saving the tvg file, in case the shape (or its stroke)
has a fill.
2021-11-02 19:37:02 +09:00
Hermet Park
3b54e4797e sw_engine image: fix memory leak.
reset rle is supposed to be reused, image should keep its pointer.

@Issue: https://github.com/Samsung/thorvg/issues/982
2021-11-02 19:33:32 +09:00
Mira Grudzinska
7176a5ddd4 svg_loader: define the scaling factors for units changing
The values in absolute units are calculated based on the pixel unit.
Till now the default value of 90dpi was used. Since CSS3 (now CSS4 is
the most recent) 1 inch equals to 96 pixels. The necessary constants
are introduces in this commit.
2021-11-02 11:29:41 +01:00
Hermet Park
3c7d037841 jpg_loader: code refactoring
removed unused variables.
2021-11-02 19:02:07 +09:00
Hermet Park
c8e7bc9d43 png_loader: code refactoring
removed unused variables.
2021-11-02 18:57:55 +09:00
Hermet Park
e4ab100fb2 tools svg2tvg: ++exception handling.
skip to process if the input is invalid.
2021-11-02 14:38:09 +09:00
Hermet Park
3abf89a6ff examples: updated tvgs
re-compiled the tvgs with the latest tvg saver.
2021-11-02 14:32:29 +09:00
JunsuChoi
590381f68b infra meson: Add -Dstatic option
Add an option for use in environments where
the use of static libraries must be enforced.
2021-11-02 13:14:16 +09:00
Mira Grudzinska
abc3b40a37 sw_engine: var/funct renaming
Changed names:
shape->rect -> shape->fastTrack
_factTrack -> _axisAlignedRect
2021-11-02 11:41:14 +09:00
Mira Grudzinska
16a153c804 svg_loader: fix bounds for gradient
In the case when bounds should not include a stroke width, width
and height values were reduced by half of a stroke width, instead
of the full width.
2021-11-01 20:36:48 +01:00
Mira Grudzinska
26f99372b0 sw_engine: fastTrack with clips
After 362d2df the fastTrack cases were applied even for shapes with clips.
These changes fixed this - the check whether a shape is a rect should be done
only if it has no clips.
2021-11-01 22:21:17 +09:00
Hermet Park
3b2e1f4291 Revert "loaders: Consider colorspaces (#838)"
This reverts commit cd5116b053.

Ah this breaks the Stress example due to Picture::duplicate() is not available...

Need to consider and come back again.
2021-11-01 16:53:25 +09:00
Michal Maciola
cd5116b053
loaders: Consider colorspaces (#838)
* common: added colorSpace() function

This patch introduces colorSpace() function for SW and GL engine.

* infra: change LoadModule:read() into LoadModule:read(uint32_t colorspace)

This patch changes LoadModule:read() into LoadModule:read(uint32_t colorspace)

* picture: implement passing colorspace into loader

This patch implements passing colorspace into loaders.
Loader->read is now called on the first update.

* external_jpg_loader: support colorspaces

* external_png_loader: support colorspaces
2021-11-01 16:10:22 +09:00
Michal Maciola
479cea74cc common: Unmultiplicated colorspace
This patch introduces _STRAIGHT colorspaces (ABGR8888_STRAIGHT and
ARGB8888_STRAIGHT) whose colors are un-alpha-premultiplied. Unmultiplicated
colors are especially needed for wasm thorvg loader and svg2png / tvg2png.
Only C version now.

@issue: #791
2021-11-01 15:57:13 +09:00
Mira Grudzinska
86a8bbbb88 tvg_saver: preTransform condition
A stroke is irregularly scaled in case when:
1) m11 != m22
2) m11 == m22 == 0 and m12 != m21
The second case was missing in the code.
2021-11-01 15:52:20 +09:00
Mira Grudzinska
b12421b4d1 tvg_loader: TVGLOG added in case an unknown fill or stroke tag used 2021-11-01 12:12:02 +09:00
Hermet Park
875e200767 common: code refactoring
removed invalid nullptr checks.

New allocation doesn't gurantee that returns nullptr when it's failed.
It's useless on the modern compliers and our policy respects it.
2021-11-01 12:09:32 +09:00
Mira Grudzinska
a9990be54c sw_engine: incorrect matrix used
The invTransform should be used instead of transform - missed during
all the gradient changes.
2021-10-29 15:04:52 +02:00
Michal Maciola
00dfd55f18 SVG: Support geometry properties of use tag
This patch adds a support for geometry properties (x, y) of <use> tag
2021-10-29 14:10:44 +09:00
Mira Grudzinska
4db3087c45 svg_loader: gradient transformation properly applied
The final gradient transformation depends on the coordinate system.
It can not be applied during an svg loading. The transformation matrix
has to be passed via api for further gradient processing.
2021-10-29 10:58:43 +09:00