Commit graph

35 commits

Author SHA1 Message Date
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
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
9b3c34c3b1 updated copyright. 2023-01-14 13:48:11 +09:00
Mira Grudzinska
1980d9d0e3 all: Trailing spaces removed 2023-01-07 10:53:51 +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
mgrudzinska
0925aa84a5 sw_engine: fixing oveflow
An overflow occurred for big shapes with a dashed stroke,
since a contour end points were stored as the uint16 type
(instead of the uint32 type).
2022-03-23 16:14:51 +09:00
Mira Grudzinska
c44d667f10 sw_engine: float casted on the unsigned int type
uint32_t -> int32_t
2022-01-21 15:21:35 +09:00
Hermet Park
f0141e63de updated copyright date. 2022-01-12 14:08:48 +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
06cef2a710 sw_engine image: introduced scaled image raster logics.
These raster functions are accelerated only for the scaled images.
(no rotation, skrewed)
2021-11-23 11:41:53 +09:00
Hermet Park
e195ac8b30 sw_engine image: code refactoring
+++
2021-11-19 13:22:32 +09:00
Hermet Park
c9377708a9 sw_engine image: ++optimization
apply fast track to fast up the image rasterization.

only shifted image doesn't need to have the matrix-transform computation,
we can avoid it by just shifting offset xy by simple caculating.

@Issue: https://github.com/Samsung/thorvg/issues/206
2021-11-15 17:38:57 +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
1592443c3e common paint: improve rotation condition precision
cover the four cases: 0, 90, 180, 270 degrees...
2021-11-12 19:45:01 +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
3b54e4797e sw_engine image: fix memory leak.
reset rle is supposed to be reused, image should keep its pointer.

@Issue: https://github.com/Samsung/thorvg/issues/982
2021-11-02 19:33:32 +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
362d2dfd0f sw_engine: refactoring
The rasterization region was rearranged in the case of fastTrack,
but its validation and boundaries weren't check, causing segf in some
cases. Fixed.
2021-10-29 10:52:29 +09: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
Hermet Park
e1d5ade705 sw_engine: memory optimization.
Save the size of the Countour array,
16 bits is large enough to count the points number in one Shape.
2021-08-12 20:13:58 +09:00
Hermet Park
e15b1dbc5f sw_engine: allow sharing shapes & connected strokes all in one.
This patch enhanced the sw raster engine to allow the both closed & open pathes
in one shape rendering.

@Issue: https://github.com/Samsung/thorvg/issues/266
2021-08-12 18:39:46 +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
f7f241cff5 common picture: remove viewbox() api.
picture provides size() interface to return the image size,
viewbox() is conceptually not correct with the Picture.

Remove it under the beta api.
2021-07-28 13:07:43 +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
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
5e01fd8b4b Revert "sw_engine shape/image: substituting logical 'and' with 'or'"
This reverts commit 74b27c74af.

This patch breaks Stroke example. 1 line drawings...

There is a possibility that less 1 (i.e: 0.5) width axis-aligned line drawings...

So logically "&&" is correct.
2021-03-09 20:13:44 +09:00
Mira Grudzinska
74b27c74af sw_engine shape/image: substituting logical 'and' with 'or'
In the case when the height or width of the bounding box is 0
it is not necessary to calculate Rle.
2021-03-09 19:44:29 +09:00
JunsuChoi
415fca577e common: TVG_UNUSED marking on unused parameter 2021-02-19 16:51:50 +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
Shinwoo Kim
e9772efbd1 wasm: work with log option
The wasm is using the ThorVG output starting whith "SVG:" to show
unsupported element and attribute of svg file.
This patch updates wasm_build.sh to make ThorVG prints log,
and removes build errors.

  - Following commit needs to include 'algorithm'
    1ed6113 common sw_engine: code refactoring & stabilizing.

  - Following commit needs to include 'string'
    5481633 svg_loader XmlParser: Print unsupported elements, ...
2020-12-15 17:38:22 +09:00
Hermet Park
64d3897816
common sw_engine: apply partial composition.
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
2020-12-14 12:29:37 +09:00
Hermet Park
1743db705b
sw_engine raster: code refactoring & optimize code.
* sw_engine raster: code refactoring & optimize code.

1. move the computation out of rolling if possible.
2. renamed internal variables & function prototypes.
2020-12-02 16:49:53 +09:00
JunsuChoi
e00f948705
raw_loader Loader: Introduce Raw image loader
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;
2020-11-23 18:12:36 +09:00