Commit graph

130 commits

Author SHA1 Message Date
Hermet Park
f0141e63de updated copyright date. 2022-01-12 14:08:48 +09:00
Hermet Park
df64a7b0dc sw_engine raster: fix a crash at the texmap clipping.
Handle correctly duplicated spans from the multiple y span data.

Previous logic only expected the one single y span data from the rle.
However rle might have multiple y span data if the anti-aliasing is applied.

This patch also removed the bad design of the common engine
which handles the anti-alising option to ignore the anti-aliasing rle generation.

Just realized, it's difficult to control that condition due to scene-composition.
2021-12-17 19:15:27 +09:00
Hermet Park
45132a7051 sw_engine raster: improve the transformed rle image rasterizer.
replace the transformed rle rgba image with the texmap raster.

this patch removes the several scattered transformed image rasterizer,
reuse the unified one texmap method instead.

yay, it's much clean and optimal.
2021-12-14 19:04:16 +09:00
Hermet Park
4cdf648e14 sw_engine image: support non-premultiplied alpha images.
Previously, translucent png images are not displayed properly
due to alpha channels premultiplication.

This patch implements that missing part to support it properly
by introducing the Surface data between canvas engine & rasterizer

@Issue: https://github.com/Samsung/thorvg/issues/655
2021-12-02 17:10:12 +09:00
Hermet Park
72ee1c4343 sw_engien renderer: ++safety
+exceptional handling for the drawing region.
2021-11-25 15:04:56 +09:00
Hermet Park
f887edf562 common paint: fix the wrong fast track logic.
There was a missing sorting between the left-top & right-bottom corner.
that results in the negative values of the viewport...

Now fixed it.

+ refactored to use math functions...
+ still it's a buggy, sometimes no draw at 90' in stress. don't know reason. :(
2021-11-22 17:33:34 +09:00
Hermet Park
b38996f5c9 sw_engine image: code refactoring
Image raster sequence is getting quite complex...

Clean up before further image optimization.
2021-11-19 13:43:12 +09:00
Hermet Park
93da844d94 sw_engine raster: clarify the internal function name.
"Solid" in this raster context is "Opaque" actually.
So remove the solid from it.
2021-11-19 13:12:40 +09:00
Hermet Park
ee60a04f20 sw_engine image: code refactoring
revert d520da2db8

After considered the scneario seriously,
this doesn't helpful for the performance at all...
just increased code complexity. earlier bad decision... revert it.
2021-11-15 11:27:29 +09:00
Hermet Park
d520da2db8 sw_engine image: optimized image rendering.
Applied the fast-track routine for axis-aligned images.
This helps to remove outline generation if no clips.
2021-11-12 16:28:15 +09:00
Hermet Park
ae3dae8c55 sw_engine image: introduce the stride property for the image.
we are considering the larger space of the image buffer,
in this case stride info is necessary.
2021-11-12 10:49:36 +09:00
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