Commit graph

66 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
f4717fb4c3 sw_engine: --redundant comment. 2023-07-27 00:56:22 +09:00
Hermet Park
f93fbc9e59 sw_engine: enforce the drawing of small stroke cubic outlines.
At the construction stage, some stroke points can be skipped
if the distance between the points is too narrow.

Previously, this was assumed to be an error case,
but it's clearly intended to remove unnecessary points introduced in a small area of drawing.

This sometimes leads to a flickering issue when super small-sized vector images are drawn.

Now, it's fixed.
2023-07-27 00:40:37 +09:00
Hermet Park
cf09ba5abd common sw_engine: code refactoring
Even though this enlarges the binary size by 300bytes,
use the array instead of individual implementations for better maintenance.
2023-07-17 20:14:58 +09:00
Hermet Park
20466ea78f sw_engine rle: The out-of-range memory access has been fixed.
@Issue: https://github.com/thorvg/thorvg/issues/1370
2023-04-26 00:23:03 +09:00
Hermet Park
bd695c6631 sw_engine rle: fix RLE intersect.
IntersectSpansRegion() wasn't working correctly,
as it didn't take care of some corner cases.

This fix makes the algorithm more accurate.
2023-04-16 22:03:36 +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
9b3c34c3b1 updated copyright. 2023-01-14 13:48:11 +09:00
Rémi Verschelde
46c3fc1f94 Format code files with dos2unix, ensure newline at EOF 2022-07-10 23:21:05 +09:00
Hermet Park
f0141e63de updated copyright date. 2022-01-12 14:08:48 +09:00
Hermet Park
9c8e785fdc updated license
Add missing original copyright texts in the source code.
2021-10-20 22:50:07 +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
7e5311fb86 sw_engine: -- unused header 2021-07-27 23:36:54 +09:00
Michal Maciola
330e258495
sw_engine: removed unused rleAlphaMask 2021-07-23 21:27:39 +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
Michal Maciola
934a95777c
common: style fixes (#644) 2021-07-22 13:35:26 +02:00
Hermet Park
1154986a58 sw_engine: fix broken MSVC compatibility.
error: use of undeclared identifier 'ulong'

@Issue: https://github.com/Samsung/thorvg/issues/541
2021-07-01 12:06:18 +09:00
Hermet Park
38fa5107bf sw_engine rle: -- sanitizer reports.
The code is actually intended, we can modify it to ignore the
annoying sanitizer reports.

@Issue: https://github.com/Samsung/thorvg/issues/483
2021-06-29 15:56:11 +09:00
Hermet Park
a864a5a0ac sw_engine rle: code refactoring.
keep it neat code, --loc
2021-06-03 11:45:59 +09:00
Hermet Park
d49e91f683 sw_engine rle: ++ precise alpha in anti-aliasing
could loss 1 pixel since it divides 255 values by 256.
2021-05-21 19:56:39 +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
105a59b5b3
sw_engine: optimize rle clipping
We don't need to copy the rle data unecessarily,
we can just replace the completed clip rle.
2021-03-16 10:23:11 +09:00
JunsuChoi
ac1434bb74 sw_engine rleClipPath: Modify clippath spans creation size.
When updating rle for clipped area, realloc size should be larger than spans size.
so this patch prevents the problem while realloc.
2021-03-15 17:12:21 +09:00
Hermet Park
197879f2ef fixed all wasm build breaks. 2021-02-23 10:47:46 +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
Mira Grudzinska
29ca149b4b sw_engine rle: fixing clipping with non overlaping figures
For clip that did not overlap with the plotted source, the whole
source was plotted - the size of the rle data was not updated.
2021-02-19 15:11:20 +09:00
Hermet Park
849ed12050 sw_engine log: adding missed line wrap. 2020-12-21 18:38:12 +09:00
Hermet Park
4c66018c97 sw_engine log: + log clipPath case.
These functions are one of special compositions.
2020-12-21 18:35:11 +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
462bf277f2 sw_engine rle: fix an invalid memory access.
There is a mistake that over-access boundary.

This fix it.

@Issues: 178
2020-12-10 14:16:41 +09:00
Hermet Park
1ed611386d
common sw_engine: code refactoring & stabilizing.
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
2020-12-09 19:56:59 +09:00
Hermet Park
006e6e0920 sw_engine rle: performance optimization.
Tis is a subsequential trial of 1b8188ee67
for opimizing memory alloc count.

In this time, it concentrates on rle span.

@Issues: 75
2020-11-05 17:32:42 +09:00
Hermet Park
65cbbcf724 sw_engine shape: support fillRule method
this change supports EvenOdd fillrule in shape rendering

@Examples: examples/FillRule.cpp

@Isuses: 97
2020-10-22 17:29:39 +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
6365d02a96 optimization: cut off file dependencies.
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.
2020-09-23 20:57:30 +09:00
Hermet Park
c407d4d13d sw_engine: code refactoring.
removed unused macro.
2020-09-15 12:26:57 +09:00
Hermet Park
04c6295974 code refactoring
remove unnecessary condition.
implementation won't be included multiple times not like headers.

Thus this condition is unnecessary.

Change-Id: Id37e675c40ce7213a06c950da8e5ca17ff7245c9
2020-08-20 16:16:46 +09:00
Hermet Park
ffa4a7248b code refactoring
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
2020-08-19 14:53:38 +09:00
Hermet Park
70b4703707 remove print/cout logs.
we need a comprehensive logging interface for this.

right now, leave as "LOG:" to replace later.

Change-Id: I25321223cd48ec13a1de5e4140cfea75a2f42866
2020-08-18 20:35:13 +09:00
Hermet Park
8abef404cf sw_engine: remove unnecessary assert() call
Change-Id: I8cb249b6b7f32992f7ce9c86e408546c14856330
2020-08-13 19:29:23 +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
2555e82f0d fix compile warnings
comparison of unsigned expression < 0 is always false [-Werror=type-limits]

Change-Id: I8cee625056bcde1f2a3cb2b9ce704b33be5bd725
2020-08-06 17:06:36 +09:00
Hermet Park
8a924cbd78 sw_engine: fix out of cell memory.
we can adjust cell size if the cell memory is out.
the main rle logic missed the exception handling.

Change-Id: I4419eefefccafd788729111eafeb65aa4e6a20e9
2020-07-29 13:40:11 +09:00
Hermet Park
2929fa5c57 sw_engine: optimize rle rendering.
we don't need to apply anti-aliasing if stroke is there.
here turns off anti-alias if stroke width is more than 2.
magic number 2 is experimentally confirmed.

Change-Id: I09031dc2a0a84f31c5904651ed1e62004645ba9a
2020-07-03 18:32:50 +09:00
Hermet Park
9ffc1d40f6 sw_engine: optimize memory allocation.
there are a logical wrong that memory increase size,
it correct that also tune the number to reduce memory allocation time.

Now scene transform test works smoothly.

Change-Id: If0674e33426d794546801a96ad9de711b5de0dcd
2020-06-23 18:59:12 +09:00
Hermet Park
55e215e6ea sw_engine: optimize span generation.
there are unnecessary partial spans generated in orthogonal rectangle.

we can merge those partial spans to others if they are on the same scanline...

Change-Id: I35a437a4f2eec106bd50f46f0390c652e617311d
2020-06-23 17:29:28 +09:00
Hermet Park
4e3f8284e8 sw_engine: grow cell memory buffer up to allow larger shapes
Change-Id: I7a8feaa11d3dad81dd1004782e07a8ac4a768d91
2020-06-09 11:03:18 +09:00
Hermet Park
f335779ce5 sw_engine stroke: stabilizing line drawing.
Also added StrokeLine test

Change-Id: I91143039823d744bf9287534227927556a2f51e1
2020-06-03 19:10:14 +09:00