* 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>
Renamed internal interfaces.
We need both blender & compositor interfaces.
Renamed SwCompositor -> SwBlender which is for pixel joining methods.
Added (SwCompositor, Compositor) which is designed for compositing images.
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.
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
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
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.
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.
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
* sw_engine raster: code refactoring & optimize code.
1. move the computation out of rolling if possible.
2. renamed internal variables & function prototypes.
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;
we introduced shared memory pool for avoiding reallocate memory
while it process the stroke outlines, It experimentally increase
the outline data if we use the allocated memory for multiples shape strokes,
we don't need to alloc/free memory during the process.
This shared outline memory is allocated for threads count
so that we don't interrupt memory access during the tasks.
@Issues: 75
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
It missed to update shape data if visilibity is changed from false to true by alpha.
Also, it needs to update engine shape data for every requests.
There scenario can be allowed,
1. update shape
2. change shape property
3. update shape
4. draw
previously engine could skip step 3, its result was not properly expected.
@fix #84
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
we should avoid code insertion during file dependencies,
such as #include "xxx.h" which has implementations.
This could increase binary size, we can avoid it as possible.
Current patch improves binary size like this:
From: file(2059008) = text(120360) data(8096) bss(80) dec(128536)
To : file(1921832) = text(118429) data(7872) bss(56) dec(126357)
More additional patches will come in to optmize binary size.
tvg canvas must draw retained shapes for every draw call
even though user missed call update() for shapes.
that case canvs must draw shapes without update,
it means drawing them within previous condition.
previous implementation didn't consider multiple canvases,
multiple canvas shared one renderer engine that brought corrupted contexts.
Thus, each canvas instances should have designated renderer engine instances.
Now fixed.
Now, we have 2 points for asynchronous behaviors.
1. update shapes:
Each shape update will be performed by async when you push shape to canvas.
Meaning, if you have time gap between update and rendering in process main-loop,
you can have a benefit by this.
2. rasterization by canvas:
Canvas.draw() will be performed asynchnously until you call canvas.sync();
Meaing, if you can trigger tvg rendering eariler than composition time.
You can have a benefit by this.
If these 1, 2 points might not work for your program,
You can just toggle off async by setting threads number zero at initialization.
Or if you could apply either point of them for your program,
It might be good for performance.
But the best approach is to make both async properly.
Though this might need to fine-grained tuning integration between your program & tvg,
You could achieve the best peformance by parallelzing tasks as possible without any jobs delaying.
Change-Id: I04f9a61ebb426fd897624f5b24c83841737e6b5b
remove unnecessary condition.
implementation won't be included multiple times not like headers.
Thus this condition is unnecessary.
Change-Id: Id37e675c40ce7213a06c950da8e5ca17ff7245c9
Now, stabilizing is pretty enough.
Remove assert code so that we never abort process in any cases.
This also reduce the binary size.
Change-Id: Ia7d2d5c5a0757b12481eaebad7a86aade6a89c1e
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
we can't control any threads count that could drop the performance.
remove async() and will come back with fine-tuned threading-pool.
Change-Id: I17c39792234acfce6db334abc0ce12da23978a9a
Basically, stroke width size is linear,
engine couldn't apply scale factor from the matrix which contains 2 dimensional values.
Thus, we can apply it if the scale factor of x/y is identical.
Otherwise, we should transform every stroke points in the stroking process.
That scenario can be improved with another patch.
Change-Id: I070dcf29d2e42f21e182bdf4239781464158ef73