Commit graph

119 commits

Author SHA1 Message Date
Hermet Park
097e10fea4 sw_engine renderer: fix the invalid memory access in the corner case.
Tasks can be disposed while the renderer referencing it.
Now, we can delete the tasks with lazy approach by introducing some tags.

@Issue: https://github.com/Samsung/thorvg/issues/995
2021-11-09 20:38:12 +09:00
Hermet Park
cbcb85cd7c sw_engine renderer: code refactoring
free the member resources in the destructor.
2021-11-09 16:09:44 +09:00
Mira Grudzinska
abc3b40a37 sw_engine: var/funct renaming
Changed names:
shape->rect -> shape->fastTrack
_factTrack -> _axisAlignedRect
2021-11-02 11:41:14 +09:00
Mira Grudzinska
26f99372b0 sw_engine: fastTrack with clips
After 362d2df the fastTrack cases were applied even for shapes with clips.
These changes fixed this - the check whether a shape is a rect should be done
only if it has no clips.
2021-11-01 22:21:17 +09:00
Hermet Park
3b2e1f4291 Revert "loaders: Consider colorspaces (#838)"
This reverts commit cd5116b053.

Ah this breaks the Stress example due to Picture::duplicate() is not available...

Need to consider and come back again.
2021-11-01 16:53:25 +09:00
Michal Maciola
cd5116b053
loaders: Consider colorspaces (#838)
* common: added colorSpace() function

This patch introduces colorSpace() function for SW and GL engine.

* infra: change LoadModule:read() into LoadModule:read(uint32_t colorspace)

This patch changes LoadModule:read() into LoadModule:read(uint32_t colorspace)

* picture: implement passing colorspace into loader

This patch implements passing colorspace into loaders.
Loader->read is now called on the first update.

* external_jpg_loader: support colorspaces

* external_png_loader: support colorspaces
2021-11-01 16:10:22 +09:00
Michal Maciola
479cea74cc common: Unmultiplicated colorspace
This patch introduces _STRAIGHT colorspaces (ABGR8888_STRAIGHT and
ARGB8888_STRAIGHT) whose colors are un-alpha-premultiplied. Unmultiplicated
colors are especially needed for wasm thorvg loader and svg2png / tvg2png.
Only C version now.

@issue: #791
2021-11-01 15:57:13 +09:00
Hermet Park
875e200767 common: code refactoring
removed invalid nullptr checks.

New allocation doesn't gurantee that returns nullptr when it's failed.
It's useless on the modern compliers and our policy respects it.
2021-11-01 12:09:32 +09:00
Hermet Park
36270f588e common: replace the id() -> identifier() 2021-10-22 18:47:05 +09:00
Mira Grudzinska
78363c3aad Revert "sw_engine: border cases for gradients"
This reverts commit 284298445b.
2021-10-06 01:13:02 +02:00
Mira Grudzinska
284298445b sw_engine: border cases for gradients
According to the svg standard, in a case when 'x1==x2 and y1==y2'
for a linear gradient or when 'r==0' for a radial gradient, the area
should be painted as a single color - the last gradient stop color.
2021-10-05 15:24:07 +02:00
Hermet Park
1ea9692841 sw_engine image: fix the clipped image issue.
there was a wrong condition introduced the bug that image was not updated,
because transformation is not re-applied after the first created the internal image data.

@Issues: https://github.com/Samsung/thorvg/issues/751
2021-09-09 11:31:05 +09:00
Mira Grudzinska
5cad097485 sw_engine: handling clips from outside the render region
Clips from outside the rendering region were ignored resulting
in rendering shapes, which should be completely clipped.
In case of the clip fast track, the bounding box width/height
overflow occured and shape, that should be clipped, could be
visible (not always).
2021-09-06 13:16:45 +09:00
Hermet Park
02081d8cdc common picture: correct non-working size() behavior.
Pixel-based image picture doesn't work at size() method.
Obvisouly, we missed to implement it properly.

This patch corrects it.

@Issue: https://github.com/Samsung/thorvg/issues/656
2021-07-29 11:44:18 +09:00
Hermet Park
386888bd11 sw_engine: flush memory pool after drawing.
if many canvas instances own private memory pool,
the memory usage can be increased linearly.

To prevent memory usage, flush out memory pool from the clear()
if the canvas uses private memory pool.
2021-07-28 17:22:35 +09:00
Hermet Park
57e086db64 sw_engine renderer: ++exception handling.
initialize a member with the default value.
2021-07-26 16:51:25 +09:00
Hermet Park
e949883049 common log: use the log macro to replace the print method easier.
We can replace the system logger method by changing single line print source in common,
This also helps to remove the THORVG_LOG_ENABLED macro from each use-cases.

TVGLOG(): To print the hint & tip messages for users.
TVGERR(): To print the error message for debugging.

@Issues: https://github.com/Samsung/thorvg/issues/36
2021-07-23 21:17:01 +09:00
Hermet Park
9ea6962c5a sw_engine renderer: code refactoring
+ trivial changes while reading the code.
2021-07-19 17:22:27 +09:00
Mira Grudzinska
96f22e282d
sw_engine: preventing a double application of the opacity (#540)
For filled and stroked shapes with a gradient, the opacity
was applied during the composition and during the ctable update.
To prevent this, in case the composition occured, ctable
is updated with the opacity = 255.
2021-07-19 16:02:10 +09:00
Hermet Park
7bf6f97691 sw_engine renderer: fix memory leak.
prepared compositors can be dangled if the rendering is not occured.

free them by doubl-checking in the destructor.

@Issue: https://github.com/Samsung/thorvg/issues/547
2021-07-08 20:29:31 +09:00
Hermet Park
c31156e737 sw_engine renderer: fix a broken composition bug
tvg sw_engine tries to skip composition as far as its doable,
it tries composition only if the translucent shape with stroking is there.

There has been a condition bug that composition is applied unnecessarily
even if stroking is disabled. This resulted in broken blending
at gradient filling since it applied alpha values multiple times.

Issues:
https://github.com/Samsung/thorvg/issues/445
2021-06-29 14:44:09 +09:00
Mira Grudzinska
f3fac71a12 sw_engine: added check whether surface width <= surface stride
In a case width > stride segf occured. Such a case should be treated
as an invalid arg.
2021-06-08 17:20:46 +09:00
Mira Grudzinska
419751c736 sw_engine: fixing the composition for canvas width != canvas stride
When canvas width was smaller than its stride and a composition is used,
the plots were drawn incorrectly. This is fixed by setting the image width
(image from a compositor) to be equal to the surface stride, instead of its width.
The image data are now allocated accordingly the fixed image width.
2021-06-08 17:19:59 +09:00
Hermet Park
1c53d47f81 sw_engine mempool: tiny optimization.
don't mempool anything if the option is same.
2021-06-07 19:40:56 +09:00
Hermet Park
50b2b1c7de sw_engine renderer: fix to success SwCanvas Unit Test.
render init count shouldn't be counted when it's in a fail-case.
2021-06-07 18:09:35 +09:00
Hermet Park
eda022365f canvas: fix for SwCanvas Unit Test
Fixed to fail canvas generation if engines are not initialized.
2021-06-07 18:01:26 +09:00
Hermet Park
61f07677c5 sw_engine renderer: fix aliasing problem.
a corner case is detected that anti-aliasing is missing at shapes
if the shape has the dash-style stroke.

By adding the condition, it applies anti-aliasing properly.

@Issues: 394
2021-05-28 14:24:37 +09:00
Hermet Park
6dd414ee3b sw_engine: fix invalid data sharing at multi-threading.
We have encountered that multi-threading usage that user creates,
multiple canvases owned by multiple user threads.

Current sw_engine memory pool has been considered only for multi-threads,
spawned by tvg task scheduler.

In this case it's safe but when user threads introduced, it can occur race-condition.

Thus, Here is a renewal policy that non-threading tvg(initialized threads with zero),
takes care of multiple user threads bu changing its policy,
each of canvases should have individual memory pool to guarantee mutual-exclusion.

@API additions

enum MempoolPolicy
{
    Default = 0, ///< Default behavior that ThorVG is designed to.
    Shareable,   ///< Memory Pool is shared among the SwCanvases.
    Individual   ///< Allocate designated memory pool that is only used by current instance.
};

Result SwCanvas::mempool(MempoolPolicy policy) noexcept;

All in all, if user calls multiple threads, set memory pool policy to Individual.
2021-05-12 10:59:50 +09:00
Michal Szczecinski
2f334f50c5 sw_engine: Added sanity checks.
This commit fixes crash when update target surface is not created yet.
2021-05-01 12:34:30 +09:00
Hermet Park
f1fe36d8f6 common sw_engine: optimize single rectangle ClipPath.
If ClipPath is a singular rectangle,
we don't need to apply this to all children nodes to adjust rle span regions.

Rather than its regular sequence,
we can adjust render region as merging viewport that is introduced internally,

All in all,
If a Paint has a single ClipPath that is Rectangle,
it sets viewport with Rectangle area that viewport is applied to
raster engine to cut off the rendering boundary.

In the normal case it brings trivial effects.
but when use SVGs which has a viewbox, it could increase the performance
up to 10% (profiled with 200 svgs rendering at the same time)

Note that, this won't be applied if the Paint has affine or rotation transform.

@Issues: 294
2021-03-26 17:10:35 +09:00
Hermet Park
4a8f45577a
sw_engine: code refactoring
1. unified clip & bounding box in rle processing
2. unified outline boundingbox functions between shape & image.
2021-03-24 18:48:39 +09:00
Hermet Park
1a7d41ce71 updated copyright 2021-03-23 14:31:58 +09:00
Hermet Park
e5381da223
common engines: code refactoring
Introduce RenderRegion structure for region data
to simplify the methods paratemers.

also depends on the NRVO for the return data.
2021-03-23 14:18:17 +09:00
Hermet Park
e8cf21a3c9 initializer: add reference counting for the engines initialization.
Introduced the reference counting for the backend engines so that
tvg prevents unpaired engine initialization/termination calls by user mistake.

@Issues: 296
2021-03-19 19:45:39 +09:00
Hermet Park
c0362cb69c sw_engine: fix a composition crash issue.
Added an exceptional handling for out of buffer boundary.
2021-02-24 20:02:10 +09:00
JunsuChoi
70e1e7f1c6 sw_engine Renderer: Fix build problem caused by merge conflict. 2021-02-19 17:33:15 +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
JunsuChoi
08c37978a9 common: Pointer that can declare const are refactored to use const
Pointer and reference parameters should be "const" if the corresponding object is not modified
2021-02-19 16:51:50 +09:00
JunsuChoi
3c7adb0a95 common: Functions that can declare const are refactored to use const
Member functions that don't mutate their objects should be declared "const"
2021-02-19 16:51:50 +09:00
Mira Grudzinska
3dfc3c4943 sw_engine renderer: rendering optimization of shapes without strokes
The value of 'a' for shapes without a stroke could hold the fill 'a' value.
Added checking if stroke exists before calling rastering functions.
2021-02-02 11:53:58 +09:00
Hermet Park
0e9115cd00 sw_engine renderer: fix invalid rle issue.
if shape rendering is failed, all the prepared data must be reset
because those are invalid.

@Issues: 180
2021-01-10 17:39:57 +09:00
Hermet Park
736d6ee4ef
common sw_engine: revise the masking implementation.
We re-implement the masking feature with image composition method.

This patch is working only for single shape but settle up coming extensions.
2021-01-04 00:46:59 +09:00
Hermet Park
cfa2d187bf
sw_engine: apply opacity to graident fill case.
previously, opacity value is ignored to gradient fill.

This patch implements that case.
2020-12-30 12:38:32 +09:00
Hermet Park
c3d0a79d3e sw_engine renderer: fix a regression bug.
recover a broken shape+stroking opacity that introduced in ealier refactoring...
2020-12-29 12:07:05 +09:00
Hermet Park
7d9023ac5c common sw_engine: code refactoring
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.
2020-12-25 20:54:56 +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
ac43ec591e sw_engine renderer: fix wrong conditional check.
unsigned int won't be less than 0.
2020-12-22 11:09:48 +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
abc9e89517 common log: notify opacity composition usage log.
replaced [XXX] log prefix with XXX:
2020-12-15 14:29:52 +09:00