Commit graph

361 commits

Author SHA1 Message Date
Patryk Kaczmarek
905fd46ccf sw_engine composition: invert alpha masking
composition invert alpha masking

@Examples: added InvMasking

@Issues: 31

Change-Id: I2ee9d428d5749240ddf2e6adbb7677dccbe1926f
2021-02-02 11:47:30 +09:00
Patryk Kaczmarek
9b4769076f Capi: Composite Method binding 2021-01-26 20:36:40 +09:00
Michal Szczecinski
975fdc8a39 capi: Added doxygen comments and doxygen config file. 2021-01-25 23:25:11 +09:00
mmaciola
d0799d8fa1
Capi: Shape bounds binding
Co-authored-by: Michal Maciola <m.maciola@samsung.com>
2020-12-30 12:40:03 +09:00
Hermet Park
4767f83b99
common composite: code refactoring
Splited out ClipPath routine from other pixel compositions'
since yet it's unlikely compatible...

Also revise internal engine interfaces to be simpler.

This is a step forward to enhance masking feature.
2020-12-25 19:47:01 +09:00
Hermet Park
1e02d62d01 inc header: remove unnecessary declaration.
This log tag is not used. We can introduce it when it's necessary.
2020-12-18 19:25:24 +09:00
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
1e78d1f845
picture: replace size parameter to float.
Considering smooth-resizing on sub-pixeling.
2020-12-08 12:27:13 +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
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
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
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
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
Michal Szczecinski
d1d54e8b8f
capi examples: Added scene API C bindings.
Scene CAPI allows to use scene functionaliy in C applications such as
set opacity to few shapes at one time or implement transparent layers.

@API Additions:
```c
Tvg_Paint* tvg_scene_new();
Tvg_Result tvg_scene_reserve(Tvg_Paint* scene, uint32_t size);
Tvg_Result tvg_scene_push(Tvg_Paint* scene, Tvg_Paint *paint);
```

Examples:
```c
Tvg_Paint *scene = tvg_scene_new();

Tvg_Paint *shape1 = tvg_shape_new();
tvg_shape_append_rect(shape1, 10, 10, 100, 100, 0, 0);
tvg_shape_set_fill_color(shape1, 255, 0, 0, 255);

Tvg_Paint *shape2 = tvg_shape_new();
tvg_shape_append_rect(shape2, 120, 10, 100, 100, 0, 0);
tvg_shape_set_fill_color(shape2, 255, 0, 0, 255);

tvg_scene_push(scene, shape1);
tvg_scene_push(scene, shape2);

tvg_paint_set_opacity(scene, 100);

tvg_canvas_push(canvas, scene);
```

Co-authored-by: Michal Szczecinski <m.szczecinsk@partner.samsung.com>
2020-11-10 12:13:48 +09:00
Michal Szczecinski
882188c752 common capi: Added opacity C bindings.
Added opacity setter/getter to CAPI. They will be useful to simplify
code responsible for set visiblility of paint.

@API Additions:
Tvg_Result tvg_paint_set_opacity(Tvg_Paint* paint, uint8_t opacity)
Tvg_Result tvg_paint_get_opacity(Tvg_Paint* paint, uint8_t* opacity)
2020-11-04 10:37:55 +09:00
Hermet Park
0399d84478 common paint: introduce opacity() method.
We introduced separate opacity interface to adjust alpha value by paint.
This opacity will affect to whole paint image if paint is a group of paints.

Also, this opacity is to multipy with fill/stroke alpha values.
This means if the opacity is valid, the paint might deal with a composition step,
which is very expensive due to additional rendering step.

One tip is, if you want to toggle on/off for a certian paint,
you can set opacity to 255 or 0.

@API Additions:

Result Paint::opacity(uint8_t o) noexcept;
uint8_t Paint::opacity() const noexcept;

@Examples: examples/Opacity

@Issues: 94
2020-10-26 19:23:54 +09:00
Hermet Park
0b767750e6 common api: interface refactoring
returning color fill() method renamed to fillColor() as like others-strokeXXX, fillRule- do.

This change is for naming consistency.
2020-10-23 12:23:59 +09:00
Hermet Park
c807010554 examples FillRule: added shape::fillRule() example
one shape shows Winding, the other one shows EvenOdd.
2020-10-22 13:50:04 +09:00
Hermet Park
04aa038339 common fill: add fill-rule interface.
Fill rule is used to select how paths are filled.

For both fill rules, wheter or not a point is included in the fill is determined by taking a ray
from that point to infinity and looking at intersections with the path. The ray can be in any
direction, as long as it doens't pass through the end point of a segment or have a tricky
intersection such as intersecting tangent to the path.

@API Addtions:

enum class TVG_EXPORT FillRule { Winding = 0, EvenOdd };
Result Fill::rule(FillRule r) noexcept;
FillRule Fill::rule() const noexcept;

@Examples:

shape->rule(FillRule::EvenOdd);

@issue: 97
2020-10-20 20:10:59 +09:00
Hermet Park
8422e8c62b common canvas: revise clear method.
Canvas::clear() introduces a new argument "free" that deterimes freeing the retained paints.

If free is true, Canvas won't delete the retained paints so that user keep paints valid.

In this scenario, user must have paints pointers, free them manually or push them again to the canvas.

This scenario is useful if user wants to re-organize paints order in the list or reuse them.
2020-10-08 12:07:27 +09:00
Hermet Park
a200c6d4e2
common: code refactoring
renamed the enum CompMethod -> CompositionMethod

added FIXME comment
also clean up internals for less code.
2020-10-07 16:25:09 +09:00
JunsuChoi
c70d1b1e45
SwRender & tvgPaint: Implement ClipPath feature (#68)
common sw_engine: Implement ClipPath feature

Paint object can composite by using composite API.
ClipPath composite is clipping by path unit of paint.
The following cases are supported.

Shape->composite(Shape);
Scene->composite(Shape);
Picture->composite(Shape);

Add enum
  enum CompMethod { None = 0, ClipPath };

Add APIs
  Result composite(std::unique_ptr<Paint> comp, CompMethod method) const noexcept;

* Example: Added testClipPath
2020-10-07 11:21:23 +09:00
mmaciola
145bafbec8
bindings/capi: Added gradient getter
Co-authored-by: Michal Maciola <m.maciola@samsung.com>
2020-09-23 15:09:08 +09:00
Hermet Park
d601021b8f common fill: code refactoring
removed unique_ptr in the interface because it's hard to get polymorphism benefits in programming perspective.
2020-09-22 11:00:33 +09:00
Hermet Park
12cd858d72
common fill: implement duplicate() method. 2020-09-21 19:20:51 +09:00
Hermet Park
eef7620bc8
common: binary optimization. (#65)
removed unique_ptr usages from pImpl pattern.
that increased binary size.

2204082 -> 2045672
2020-09-18 16:34:12 +09:00
Hermet Park
87fbff63cb common: code refactoring.
revise duplicate() approach with stategy pattern.
2020-09-18 12:22:28 +09:00
Michal Szczecinski
538db6e881 shape: added duplicate api.
Changes:
1. New shape->duplicate(Shape) api.
2. New example: testDuplicate
3. Added capi binding for duploicate api
4. Added capi duplication test in testCapi.c

Description:

Added implementation of duplicate api. For now it supports stroke
properties and shape properties (fill color, path) duplication.

TODO:
Implement gradient properties duplication
2020-09-17 11:01:52 +09:00
Hermet Park
7a27ca3613 capi: correct interfaces.
put missing const parameter and correct set/get naming.

attention, these two apis are changed!

tvg_gradient_color_stops() => tvg_gradient_set_color_stops()
tvg_gradient_spread() = tvg_gradient_set_spread()
2020-09-16 17:56:47 +09:00
Piotr Kalota
7d08f202a8 bindings/capi: Added path getters + test in testCapi.c 2020-09-16 16:55:00 +09:00
Michal Szczecinski
438f3360b9 bindings/capi: Added stroke/gradient getters. 2020-09-15 19:32:00 +09:00
Hermet Park
8efef7714c common initializer: don't try initialize engine duplicatedly.
Change-Id: I58c715745b8db40fe759582545082f2e6e10626a
2020-08-21 15:56:45 +09:00
Hermet Park
657e6daddb common taskscheduler: revise functionalities.
initialization interfaces has been changed for threads count.

if you want to set concrete threads count by system, please specify thread count with it.

std threads:
tvg::Initializer::init(tvg::CanvasEngine::Sw, std:🧵:hardware_concurrency());

if your system provides designed threads info, you can use it.

efl:
tvg_engine_init(TVG_ENGINE_SW, eina_cpu_count());

I recommend to avoid max threads usage for better performance.

Change-Id: I22cfa315768f73fa941be136956cdbb2cf837c20
2020-08-21 12:26:57 +09:00
Hermet Park
06d8d06993 sw_engine: replace rgba8888 with abgr8888
Actually Dali rendering system requires abgr8888.

We could add more colorspaces if it's necessary.

Change-Id: Ia42a6575d1313629e55efc3077e302992c47b6c0
2020-08-19 18:39:23 +09:00
Hermet Park
f4d1065d52 sw_engine: convert colorspace ARGB -> RGBA in default.
We can use RGBA colorspace rather ARGB for pixel data.
This would be better for many rendering system,
since it's more widely preferred than ARGB including opengl.

Change-Id: Ibbfe6a511d77bf0ef30ce261995467c11164d306
2020-08-15 18:22:43 +09:00
Hermet Park
7ab71c52d0 picture svg: introduce load() with memory data input source.
picture now affords the memory data as input source so that
user can pass svg data memory directly.

Change-Id: I246c09b682a2d60e53ad556ce0c90337142ee4f1
2020-08-14 19:41:04 +09:00
Hermet Park
1eb11f249e common initializer: introduce thread count api.
this interface controls the number of threads working behind.

default is 0 == only syncrhonous.

Change-Id: I8404f33359e6213acc5e578061568fede50cd9a6
2020-08-14 18:53:01 +09:00
Hermet Park
9893af979f replace license from Apache 2.0 to MIT
Change-Id: I61f7cb2b0e407bc035f3b2ec7da9b7f230057e24
2020-08-13 16:53:38 +09:00
Mateusz Palkowski
083fa57c3e capi: Added C wrapper for setting spread type
and test

Change-Id: I3b4cd3740a82446fea60ed050814b03f32632f6d
2020-08-06 08:09:40 +00:00
Hermet Park
05757ec07c capi: revise some common paint interfaces and added picture stuff.
Change-Id: I9850cbead5ce1ab172f284738fe8456cd19dc3f9
2020-08-04 09:37:08 +09:00
Hermet Park
e98988da02 common shape: support pie filling from arc.
last argument pie=true makes arc to pie shape.

Change-Id: I6f22d00fed77bf728a4ff6e5f1ca42f476ac1664
2020-08-03 20:02:31 +09:00
Hermet Park
0be10ce140 Merge "common shape: added arc implementation" into tizen 2020-08-03 09:50:52 +00:00
Michal Szczecinski
214072babe common shape: added arc implementation
Change-Id: Ib483e24d8e358b2860ca8d46e8b88d58d12bdb62
2020-08-03 08:31:54 +02:00
Mateusz Palkowski
7b9c7de1e5 capi: Added C wrappers for gradient func
Change-Id: If41dab9b06f6cec2831ea1361f30b50a193e99c4
2020-07-31 11:34:49 +02:00
Hermet Park
f15aefa5dc test: updated svg sample
also revise size() method of Picture for proper aligning.

Change-Id: I58a0886968f6058e65a062477e2a873224d8ea8f
2020-07-30 21:10:02 +09:00
Hermet Park
e9a4e2ccb6 common: code refactoring
remove duplicated code among the Paint types.

Change-Id: Ia7c09f29531e6aef73d2ba1f951f8dfdf488deb8
2020-07-30 19:52:48 +09:00