Commit graph

286 commits

Author SHA1 Message Date
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
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
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
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
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
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
Michal Szczecinski
214072babe common shape: added arc implementation
Change-Id: Ib483e24d8e358b2860ca8d46e8b88d58d12bdb62
2020-08-03 08:31:54 +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
Hermet Park
ec6e5618e2 common picture: introduce picture feature which is for vector file extensions.
Now Scene is only specialized for composition of Paint objects.

Change-Id: I16426913f029c89e9f9ac4d5e0afed11d1a228d0
2020-07-30 17:13:00 +09:00
Hermet Park
8dca270a30 common: code refactoring for simplicity.
Introduce internal PaintMethod since there more derived paint classes are coming.

This PaintMethod is a sort of Strategy Pattern method.

Change-Id: I29c49f5d4ddbfb9e429d4976636b20b39914ee20
2020-07-30 14:51:31 +09:00
Hermet Park
80d47fd7d3 common: revise canvas interfaces.
1. removed async option which doesn't work currently,
rather than it, we can add async option in initiailizer class.

2. removed update() method.
Instead, we can call update(paint = nullptr); which has exactly same behavior.

Change-Id: I7909a50d804b97baf413a2ff6365a3cf79a3689e
2020-07-30 13:43:18 +09:00
Hermet Park
9e0c4666af common: revise transform interfaces.
transform interfaces are getting duplicated in derived classes.

we moved to the super for smaller apis count.

Applied strategy pattern to hide the inheritance.

Change-Id: I7b0c3ff9317e9bf3c97bb0c849bf55e79ee9a591
2020-07-29 16:52:40 +09:00
Hermet Park
ef4d7a3956 common shape: expand rectangle arguement to support both corner radius x, y
this is useful for svg loader

Change-Id: Ia11c2d1c6ea88f3fd65c7f75cef8b59bef426bcb
2020-07-07 13:09:46 +09:00
Hermet Park
56e866dd36 renamed project name tizenvg => thorvg
we're going to open this project as the independent one,

thus removed tizen naming here.

Change-Id: Ib3c898067dd9186e893f7cb0903fd70d2ce7b31f
2020-06-25 13:57:41 +09:00
Renamed from inc/tizenvg.h (Browse further)