Commit graph

125 commits

Author SHA1 Message Date
Mira Grudzinska
924ea15cfa capi: added check against null pointer before dereferencing
TVG_RESULT_INVALID_ARGUMENT returned in case a nullptr passed as an argument
(does not apply to color getters).
The change is addressed in the docs file.
2021-05-11 12:09:23 +02:00
Mira Grudzinska
335880c58c docs: polishing up the C API docs 2021-05-06 14:12:37 +02:00
Hermet Park
28008e2f91
doc: polish up api documentation. 2021-04-30 18:53:20 +09:00
JunsuChoi
3908397d95 doc common: Add enum and struct docs in capi 2021-04-29 15:06:54 +09:00
JunsuChoi
706df374cf doc common: Groupping c APIs
C APIs
 - Initializer
 - Canvas
  - SwCanvas
 - Paint
 - Shape
 - Gradient
 - Picture
 - Scene
2021-04-29 15:06:54 +09:00
JunsuChoi
d7b3f0103e doc common: Add grouping of C++ api and C api
group ThorVG C++ APIs
group ThorVGCapi C APIs
2021-04-29 12:11:06 +09:00
Mira Grudzinska
ec1232b9b4 doc common: change of the return value in the composite API 2021-04-28 15:06:00 +02:00
Mira Grudzinska
3d5006740c doc common: adding the documentation for the C++ APIs
Added the missing descriptions for Sw/Gl/Canvas and Initializer.
@retval command applied.
2021-04-28 19:46:58 +09:00
JunsuChoi
6241fd054d doc common: Fix typo and missing parameter 2021-04-27 11:54:22 +02:00
Mira Grudzinska
7e35ec339a doc common: adding the documentation for the C++ APIs
The descriptions have been changed and new ones added.
There are still few apis for which descriptions are missing.
2021-04-25 17:16:13 -07:00
JunsuChoi
2cfc2bd241 doc common: Draft documentation for C++ header APIs
Write documentation for some of the APIs that have already been cleared up.
2021-04-21 17:57:24 +09:00
Michal Szczecinski
3ae9832684 capi: Added Inverted Alpha Mask composition enumeration.
Added missing composite method. Backend supports this compostion type.
2021-04-20 17:59:22 +09:00
Hermet Park
cb425fa4bb capi: fix incorrect composite api.
Api prototype is completely wrong, now it's corrected.
2021-03-04 11:33:24 +09:00
Mira Grudzinska
d86032df36
sw_engine: adding a gradient as a stroke feature
* sw_engine: adding a gradient as a stroke feature

Similarly as a shape may have a gradient fill so can the stroke.

* Capi: adding APIs for a gradient stroke

Co-authored-by: Hermet Park <hermetpark@gmail.com>
2021-02-19 17:16:10 +09:00
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