Commit graph

167 commits

Author SHA1 Message Date
Hermet Park
24711e485c infra: renames the source folders
lib -> renderer
bin -> tools
utils -> common
2023-08-28 13:11:24 +09:00
Hermet Park
624b275628 sw_engine: improve the masking methods
Corrected subtract/intersect masking behaviors that were inaccurately functioning
within chain-masking.

This also helps to enhance the masking performance by reducing the
masking region when applying subtract/intersect.

@Issue: https://github.com/thorvg/thorvg/issues/1606
2023-08-28 11:55:01 +09:00
Mira Grudzinska
478e45f9f3 common: stroke dash offset support added
The feature is supported also in the svg loader.

@Issue: https://github.com/thorvg/thorvg/issues/1591
2023-08-23 12:40:27 +09:00
Hermet Park
921bd94b6f sw_engine renderer: fix a memory leak.
disposed of task memory properly, detected by Memory Sanitizer.
2023-07-29 16:16:37 +09:00
Hermet Park
b7dfe661b5 common: --unnecessary null check. 2023-07-03 15:49:16 +09:00
Hermet Park
4482664740 common array: ++enhance the usability.
+ end() which indicates the end of the data pointer.
2023-06-26 14:58:30 +09:00
Hermet Park
c50d2fde5f common sw_engine: support blending methods.
The blending feature allows user to combine colors to create visually appealing effects,
including transparency, lighting, shading, and color mixing, among others.

Its process involves the combination of colors or images from the source paint object
with the destination (the lower layer image) using blending operations.

The blending operation is determined by the chosen @p BlendMethod,
which specifies how the colors or images are combined.

@APIs:
 - enum class BlendMethod::Normal, Add, Screen, Multiply, Overlay, Lighten, Difference, Exclusion, SrcOver, Darken, Lighten, ColorDodge, ColorBurn
 - BlendMethod Paint::blend() const noexcept;
 - Result Paint::blend(BlendMethod method) const noexcept;

@Issue: https://github.com/thorvg/thorvg/issues/307

Co-authored-by: Peter Vullings <peter@projectitis.com>
Co-authored-by: Hermet Park <hermetpark@lottiefiles.com>
2023-06-20 11:30:18 +09:00
Hermet Park
814d87626c common engines: optimizing data packing for compactness.
Standardized the opacity data type to use 1 byte
across all instances to maintain consistency and reduce scattered usage.
2023-06-15 10:35:34 +09:00
Hermet Park
89db13037d common sw_engine: gather scattered stroking composition.
There are two branches for completing stroke composition between the canvas and sw_engine.

It is necessary to centralize the task on the canvas engine side so that
we can maintain the logic without confusion.
2023-05-19 10:35:24 +09:00
Hermet Park
7956a21fc2 sw_engine: fix the dead lock issue.
fully recovered from the scene clipping multi-tasksing.

@Issue: https://github.com/thorvg/thorvg/issues/1430
2023-05-09 15:56:30 +09:00
Hermet Park
da6216f9bf sw_engine: specify buffer size so that we can clearly access the buffer data.
Also, it introduces the 'pixel_t' type to ensure that anonymous pixel data
follows the system's decision.
2023-05-08 10:55:03 +09:00
Hermet Park
f18d2557e3 sw_engine raster: code refactoring.
Move partial region in rasterClear()
2023-05-08 10:55:03 +09:00
Hermet Park
527b1af926 common sw_engine: applied colorspace format size.
Now backend engines know which channel size is required for
compositions.

@Issue: https://github.com/thorvg/thorvg/issues/976
2023-05-08 10:55:03 +09:00
Hermet Park
01b26c43a6 engine: add Renderer::colorSpace() interface
This is necessary for acquiring current format size.

@Issue: https://github.com/thorvg/thorvg/issues/976
2023-05-08 10:55:03 +09:00
Hermet Park
1302c18f28 common sw_engine: polished code
--OOM handling
++exception handling
++log info
2023-05-08 10:55:03 +09:00
Hermet Park
3c8a4afaa7 sw_engine: fix the broken scene clipping.
The implementation has been reverted by https://github.com/thorvg/thorvg/issues/1409

Since the sanitizer is not matured fully and it's false positive as far as I figured,
We revert the scene clipping part.

@Issue: https://github.com/thorvg/thorvg/issues/524
2023-05-06 19:22:21 +09:00
Hermet Park
e8eef1af1d common taskscheduler: revert 4db25db962
There is a report of the thread sanitizer.
It could be a false-positive as far as I reviewed,
but we hate to be bothered by it. So let's revert it.

@Issue: https://github.com/thorvg/thorvg/issues/1409
2023-05-04 13:42:50 +09:00
Hermet Park
bc7b448c01 sw_engine: ++thread-safety
One more regression bug by afea40a947

As tasks will now be triggered by other tasks on the worker threads,
the designated memory pool data (outline) for each thread should be
reset before moving on to other tasks.

@Issue: https://github.com/thorvg/thorvg/issues/1409
2023-04-30 20:28:12 +09:00
Hermet Park
e9b12aa9f7 engine/loaders: Migrate alpha premultiplying to the engine side.
It's not efficient to handle alpha premultiplying in every loader.
The backend engine should be responsible for it.
Now, we can remove duplicate code.
2023-04-29 12:37:09 +09:00
Hermet Park
c710af2560 loaders: Remove the color space conversion on the loader side.
Now, the job is completely delegated to the backend engine.
2023-04-28 15:27:53 +09:00
Hermet Park
b733030357 sw_engine: supports the color space conversion.
Currently implements only the necessary functions for converting
between ARGB and ABGR.

Now conversion can be accelerated by the backend engines.
2023-04-28 15:27:53 +09:00
Hermet Park
cf4484c1ad engine/loaders: develop the ColorSpace feature infrastructure
Replace the existing fragile usage of the colorspace data type
with a new and robust concrete ColorSpace type.
2023-04-28 15:27:53 +09:00
Hermet Park
84012651cc common engine: code refactoring
Introduce the RenderMesh structure to reduce the number of required parameters.
2023-04-27 10:16:12 +09:00
Hermet Park
6d08586883 common engine: code refactoring
Unify renderImage and renderImageMesh and hide their routines in backends.
2023-04-27 10:16:12 +09:00
Mira Grudzinska
69a9583354 common: order(bool strokeFirst) api introduced
The new api is introduced to handle the rendering
order of a stroke and a fill. By default fill is
rendered as the first one, stroke as the second
one. This order can be reversed by calling
order(true).

@Issue: https://github.com/thorvg/thorvg/issues/1340
2023-04-18 22:21:55 +09:00
Hermet Park
b26672a1f6 sw_engine: support Scene ClipPath behavior.
Introduced SceneTask, it implements scene clippath behavior
by merging RLE of the scene children render data on any running thread.

Co-authored-by: Michal Szczecinski <m.szczecinsk@partner.samsung.com>

@Issue: https://github.com/thorvg/thorvg/issues/524
2023-04-16 22:03:36 +09:00
Hermet Park
a45275b779 sw_engine renderer: add clip() interface.
As there are multiple types of painting tasks,
the clip() interface has been newly designed to handle clipping behavior
according to each task's role when requested."

Now Scene clipper could implement clipping behavior on it.
2023-04-16 22:03:36 +09:00
Hermet Park
afea40a947 common taskscheduler: increase thread efficiency.
Revise the logic to avoid potential blocking of the main thread.
Move the clippers job completion to worker-threads to prevent main thread blocks
and enhance maximum parallelization efficiency.
2023-04-09 13:21:29 +09:00
JunsuChoi
507b11829c loader: Support ABGR colorspace
Since the color space is set at the time of specifying the target buffer of the canvas,
there is no way to know the color space when the picture is loaded.
So, check the color space applied to SwCanvas at the time of reload()
and change the color space.

There is an issue of BGR color space support for each loader.
The external_jpg loader resets the TJPF color space and calls read() to get a new buffer.
In the case of external_png, we need to change the color value directly
because it have to start over from begin_read_*.

This solution can affect performance as much as it access again image buffer
that have already been `read()` done. However, this only happens once.
2023-02-08 17:54:33 -08:00
Hermet Park
919c90a97e common shape: code refactoring & data optimization.
re-design the shape data structure so that render backends
are able to access them directly.

This also let us remove tvgShape member data from the Shape::Impl.

To achieve this, migrate shape/stroke/path
from the canvas interface to the render interface.
2023-02-05 12:06:09 +09:00
Hermet Park
d701f6dae4 common: enhance clipping behavior.
If a paint is used as a clipper, it must be determined in the paint behavior.
Propagate its decision to the immediate derived classes so that
not only shapes but also scenes must be dealt as a clipper properly.

This revised this change 0de3872be3
for better a solution.
2023-02-04 16:25:50 +09:00
Mira Grudzinska
0de3872be3 common: ignoring color/alpha/opacity of a clip object
According to the svg specs clip's fill and opacity
should be ignored. Till now setting the alpha/opacity
value to zero resulted in the shape's rendering abort.

@Issue: https://github.com/Samsung/thorvg/issues/1192
2023-01-19 23:21:34 +01:00
Hermet Park
9b3c34c3b1 updated copyright. 2023-01-14 13:48:11 +09:00
Hermet Park
ddb9bbdf0e common picture: code refactoring.
keep api parameter naming consistency.

ptsCnt, cmdCnt, triangleCnt ...
2022-08-20 15:21:31 +09:00
projectitis
3dd65dfed0 common picture: support image mesh feature
Tvg Picture newly provides mesh() api to support texture mapping.
These apis allows to have a coarse triangle list which have polygon coordinates
and texture uvs those are used for traditional polygon texture mapping.

Note that these apis are beta version.

@API Additions:

Result mesh(const Polygon* triangles, const uint32_t triangleCount) noexcept
uint32_t mesh(const Polygon** triangles) const noexcept

@Examples:

//Mapping with two polygons
Polygon polygon[2];

//First polygon
polygon[0].vertex[0].pt = {0, 0};
polygon[0].vertex[1].pt = {100, 0};
polygon[0].vertex[2].pt = {0, 100};
polygon[0].vertex[0].uv = {0, 0};
polygon[0].vertex[1].uv = {1, 0};
polygon[0].vertex[2].uv = {0, 1};

//Second polygon
polygon[1].vertex[0].pt = {100, 0};
polygon[1].vertex[1].pt = {100, 100};
polygon[1].vertex[2].pt = {0, 100};
polygon[1].vertex[0].uv = {1, 0};
polygon[1].vertex[1].uv = {1, 1};
polygon[1].vertex[2].uv = {0, 1};

//Apply polygons to the picture
picture->mesh(polygon, 2);

@Issues: https://github.com/Samsung/thorvg/issues/1218
2022-08-20 11:58:55 +09:00
Hermet Park
a00b68ba40 sw_engine renderer: code refactoring
remove unnecessary header inclusion.
2022-01-20 11:27:28 +09:00
Rémi Verschelde
4d58dae59f sw_engine: Replace non-portable min/max with tvgMath.h macros
This would fail building with Visual Studio 2017, at least downstream in Godot
where we undefine old Windows compilers' non-standard `min`/`max` macros (see
`minmax.h`/`NOMINMAX`).
2022-01-20 11:18:40 +09:00
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