Commit graph

714 commits

Author SHA1 Message Date
Hermet Park
82e3553b56 common sw_engine: fix build break.
some wrong merge conflicts left. resolve them.
2020-12-18 17:44:59 +09:00
Patryk Kaczmarek
4dbdcbd057
common composition: support Masking method
New feature - CompositeMethod::MaskAlpha

Newly Support AlphaMask. but it's unstable.

@Issues: 31
2020-12-18 17:40:54 +09:00
Hermet Park
cee1348a44 svg_loader XmlParser: code refactoring.
just renamed _nodeTypeToString() -> xmlParserNodeTypeToString()

+ print meson message if log is enabled.
2020-12-17 16:11:09 +09:00
JunsuChoi
23331cf8d4 svg_loader SvgLoader: Print inefficient elements
Opacity is 0
both Fill.Opacity and Stroke Opacity are 0
point is 0 in Path
declared display="none"
width or height of bounds becomes 0
2020-12-17 13:56:09 +09:00
Shinwoo Kim
135e6c872b fix typo 2020-12-16 09:58:40 +09:00
Shinwoo Kim
aedd3afd00 fix mistake 2020-12-16 09:57:57 +09:00
Shinwoo Kim
54e5cdee10 wasm: update picture size for file loading
The width and height was not changed, if there is newly loaded file.
As a result, the scale was not correct after loading a file.
2020-12-15 17:38:22 +09:00
Shinwoo Kim
e9772efbd1 wasm: work with log option
The wasm is using the ThorVG output starting whith "SVG:" to show
unsupported element and attribute of svg file.
This patch updates wasm_build.sh to make ThorVG prints log,
and removes build errors.

  - Following commit needs to include 'algorithm'
    1ed6113 common sw_engine: code refactoring & stabilizing.

  - Following commit needs to include 'string'
    5481633 svg_loader XmlParser: Print unsupported elements, ...
2020-12-15 17:38:22 +09:00
Hermet Park
abc9e89517 common log: notify opacity composition usage log.
replaced [XXX] log prefix with XXX:
2020-12-15 14:29:52 +09:00
JunsuChoi
54816339ed svg_loader XmlParser: Print unsupported elements, attribute with log option
* Using printf is temporary. We are planning a proper way to print the log.
When parsing a Svg file, Loader print unsupported elements and attributes.
2020-12-15 14:07:38 +09:00
JunsuChoi
55978d1bf4 examples Opacity: Add close method 2020-12-14 17:22:41 +09:00
Hermet Park
64d3897816
common sw_engine: apply partial composition.
Introduce RendererMethod::renderRegion() to return acutal drawing region info.

That is used by scene composition to composite actual partial drawing region

for better performance.

@Issues: 173
2020-12-14 12:29:37 +09:00
Hermet Park
e3eff97fac sw_engine renderer: optimize composition data usage.
Use cache mechanism for composition data so that we don't reallocate
composition memory several times in one frame rendering.

@Issues: 168
2020-12-10 19:55:57 +09:00
Hermet Park
1523446a20 examples Svg: replace a few example svgs. 2020-12-10 19:53:40 +09:00
Hermet Park
d9a0cf3d78 examples capi: fix a memory leak.
a shape is not cleaned properly.

@Issues: 178
2020-12-10 14:23:29 +09:00
Hermet Park
462bf277f2 sw_engine rle: fix an invalid memory access.
There is a mistake that over-access boundary.

This fix it.

@Issues: 178
2020-12-10 14:16:41 +09:00
Hermet Park
932cc65543 loaders: fix memory leak.
While looking for image loader, it occured memory leaks.
Fixed it properly.

@Issues: 178
2020-12-10 11:57:38 +09:00
Hermet Park
393be38f2a sw_engine stroke: fix memory leak.
Properly free data after use.

@Issues: 178
2020-12-10 11:48:08 +09:00
Hermet Park
dbbecef101 tools: remove invalid file link. 2020-12-10 10:47:08 +09:00
pkosko
1712e7d83f
tools: Automatic code format tool added
Tool allows auto formatting of code according to Google coding standard
for easier control and fixing formatting issues.
2020-12-10 10:38:22 +09:00
Hermet Park
1ed611386d
common sw_engine: code refactoring & stabilizing.
Apply tvg Array instead of std::vector

Also Fixed to compList in update() to passed by reference, not copying.
Also Fixed Composition Target memory leak

Here is the binary size result:

[libthorvg.so] 1785376 >> 1607416
[text] 121255 >> 118277
[data] 7792 >> 7736
[dec] 129119 >> 126085
2020-12-09 19:56:59 +09:00
Hermet Park
d13cd37094 fix typo 2020-12-09 15:29:22 +09:00
Hermet Park
d4515d2732 common array: Introduce Array function to common.
This Array is promoted from SvgVector to use it widely in tvg.
It's similar with std::vector, we can use it instead of it.

Also, svg_loader replaced with it subsequently.
2020-12-09 15:29:22 +09:00
Hermet Park
ca6639bb2c svg_loader: code refactoring
Use custom vector data algorithm for optimizing binary size.
Plus remove tuple usage since it leads unnecessary instance copying.

binary size comparison:

[libthorvg.so] 1811400 >> 1785448
[text] 122914 >> 121255
[data] 7824 >> 7792
[dec] 130810 >> 129119
2020-12-09 14:52:47 +09:00
Hermet Park
924490a7a5 sw_engine renderer: code refactoring.
Unify Shape+Stroke composition with CompositeCtx which is added for Scene Composition

This fixes clipping issue as well.

@Issues: 164
2020-12-09 12:54:13 +09:00
JunsuChoi
e794c678ec svg_loader SceneBuilder: No propagate opacity to child
Scene's opacity() propagates opacity value inside.
Therefore, unnecessary opacity calculation.
2020-12-08 12:32:05 +09:00
Hermet Park
af88da976d wasm: code refactoring.
Use Picture::size() method instead of scale()

Picture newly supports size() method to resize image.
It's more convenient for users in its usage.
2020-12-08 12:30:58 +09:00
Hermet Park
1e78d1f845
picture: replace size parameter to float.
Considering smooth-resizing on sub-pixeling.
2020-12-08 12:27:13 +09:00
Hermet Park
ea969ad0e2 sw_engine renderer: fix a crash issue.
This stroking composition condition must be initialized
even when exceptional cases. We moved the condition setting to
handle it always.
2020-12-07 19:52:56 +09:00
Hermet Park
77e8a195b4
sw_engine renderer: support scene opacity composition
this is an additional enhancement of af8c278c5e

Now scene opacity composition is supported.

Also, this implementaion fixes an incorrect scene bounding box computation.

Plus, adding stroking feathering to shape bounding box size.
2020-12-07 15:45:44 +09:00
Hermet Park
20de2bfc15 common picture: revise resize method.
this implementation handles the center-aligned scale.
Also removed viewbox usage since we have size() method.
2020-12-07 13:56:50 +09:00
JunsuChoi
6889f0ad1f
common Picture : Introduce Picture's size setter, getter APIs
* common Picture : Introduce Picture's size setter, getter APIs

If picture or file loaded by picture has an explicit Size(width, height),
it is transformed to fit the size.
2020-12-04 15:03:25 +09:00
Hermet Park
ceb14e73a8 sw_engine renderer: refactoring code & optimize composition.
Move the prepare stage of shape & stroking composition stage to a separate function
this returns SwImage to use in composite stage.

Also clear partial region buffer since we know composition area.
2020-12-03 18:59:42 +09:00
JunsuChoi
3881f20e9c svg_loader SceneBuilder: Use opacity() without using alpha color
If opacity value is set in node,
opacity() API is used without composing alpha color.
2020-12-03 18:50:39 +09:00
JunsuChoi
d3020b7bbe svg_loader Loader,XmlParser: String that has not been parsed returns false
Existing parser functions always return true.
Parser function's return value was not being properly used.
So, add a return to check whether it is parsed or not.
2020-12-03 18:39:47 +09:00
Hermet Park
ee1522a446 sw_engine math: fix regression bug.
There is 1 pixel misaligned issue observed.
Found out transform() increases 0.5 pt always.

This transform() logic was broken by this change - e00f948705
and now recorvered to origin.
2020-12-03 18:30:47 +09:00
Hermet Park
af8c278c5e sw_engine raster: support opacity composition.
This implementation supports shape + stroke opacity composition.

Currently, tvg shape provides individual alpha values for filling & stroking

These alpha values are working individually, meaning that if stroking is half translucent,
user can see that translucent stroking is crossed the shape outlines.

Sometimes this result can be expected but user also expects the shape filling is invisible
behind of translucent stroking.

For this reason, Paint provides an additional api opacity()
that applies opacity value to whole paint attributes.

This is a little expensive job, please consider if you can possibly avoid that usage.

See Opacity example.

@Issues: 94
2020-12-03 13:07:17 +09:00
Hermet Park
1743db705b
sw_engine raster: code refactoring & optimize code.
* sw_engine raster: code refactoring & optimize code.

1. move the computation out of rolling if possible.
2. renamed internal variables & function prototypes.
2020-12-02 16:49:53 +09:00
Hermet Park
2c78945483 gl_engine renderer: fix build break.
interface has been changed. make it up-to-date
2020-12-01 16:13:51 +09:00
Michal Szczecinski
a36e25e178 common capi: Added scene clear API
Scene::clear() API allows users to remove shapes on their own, without
a crash in paint->dispose() or tvg_paint_del() methods. This case is
needed especially when thorvg is used to draw frames, when in one frame
we have scene with shape, and in next frames (future time stamps) user
deletes shapes

@API additions
Result Scene::clear();
Tvg_Result tvg_scene_clear(Tvg_Paint *scene);

Example:
```c
Tvg_Paint *scene = tvg_scene_new();
Tvg_Paint *shape = tvg_shape_new();

tvg_scene_push(scene, shape);
tvg_scene_clear();
//Now we can safelly free resources manually
tvg_paint_del(scene);
//Without tvg_scene_clear() memory allocatad for shape was double released
tvg_paint_del(shape);
```
2020-12-01 15:39:08 +09:00
JunsuChoi
676e824719 common Scene: Fix validation check for child's bounds
Fix typo. and Change return to continue.
Even if the child's boundary calculation is wrong,
other child's boundary should be calculated.
2020-11-30 15:36:36 +09:00
JunsuChoi
1bdf1c72a4 common Test: Add Paint.bounds unit test 2020-11-30 15:36:36 +09:00
JunsuChoi
d8d754e969 sw_engine Raster: Add null check for transform
If transform is null, identify matrix is used.
2020-11-30 15:32:30 +09:00
Michal Maciola
7ec52e6c9e Picture capi binding 2020-11-30 13:16:20 +09:00
Michal Szczecinski
01aef488f0
capi: Added fill rule API.
Added capi binding for fill rule setter and getter.

@API changes:

enum Tvg_Fill_Rule {
  TVG_FILL_RULE_WINDING = 0,
  TVG_FILL_RULE_EVEN_ODD,
}

Tvg_Result     tvg_shape_set_fill_rule(Tvg_Paint* paint, Tvg_Fill_Rule rule)
Tvg_Fill_Rule  tvg_shape_get_fill_rule(Tvg_Paint* paint, Tvg_Fill_Rule* rule)
2020-11-30 13:08:24 +09:00
Hermet Park
b125a7ea2e examples: ignore loading raw image file.
in the last commit, it added a raw image file in the images folder.
It breaks Multicanvas, Svg which try to load all kinds of files in it.

We don't need to load all files by figuring out file extension name.
2020-11-23 18:56:23 +09:00
JunsuChoi
e00f948705
raw_loader Loader: Introduce Raw image loader
Add RawLoader class that loads and display raw images,
and adds a Rasterizer for image data.
Image data can be loaded via picture.
Loaded image supports Composition, Transformation and Alpha blending.

New API
Result load(uint32_t* data, uint32_t width, uint32_t height, bool isCopy) noexcept;
2020-11-23 18:12:36 +09:00
Michal Szczecinski
e259213b44 capi: Added free flag to clear API.
Cpp implementaiton of library has free flag which was not used in
capi bindings.

@API changes
from: tvg_canvas_clear(Tvg_Canvas *canvas);
to: tvg_canvas_clear(Tvg_Canvas *canvas, bool free);
2020-11-20 12:04:22 +09:00
Hermet Park
a71773f98d
common taskScheduler: code refactoring
removed unnecessary code.
2020-11-11 13:55:46 +09:00
Subhransu Mohanty
c2e1583e94 common taskScheduler: fix a synchronization data race.
std mutex shouldn't be used among threads. behavior is unexpected by implmentation.

This resolves it by introducing conditional value.
2020-11-10 16:45:52 +09:00