Commit graph

2053 commits

Author SHA1 Message Date
Mira Grudzinska
333ff25c7e svg_loader: fix grad update
The grad update should be handled after the postponed nodes are cloned.
2022-01-11 13:56:14 +09:00
Mira Grudzinska
1f6c236fa3 svg_loader: preventing memory leak
A memory leak occured when the 'id' attribute was given multiple times
for a given gradient element. Fixed.
2022-01-11 13:55:21 +09:00
Hermet Park
eb75745a19
Update AUTHORS 2022-01-10 14:21:23 +09:00
K. S. Ernest (iFire) Lee
607fd5de3f Update AUTHORS 2022-01-10 14:20:45 +09:00
Mira Grudzinska
e409bb2984 svg_loader: LumaMask used only for masks other than white
For the performance reasons, the LumaMask is used only when
it's necessary - when the mask color is other than white.
Otherwise the AlphaMask is enough.
2022-01-08 02:26:52 +01:00
Mira Grudzinska
d3053777a8 svg_loader: typo fixed
_svgLoaderParerXmlClose -> _svgLoaderParserXmlClose
2022-01-08 00:39:21 +01:00
Mira Grudzinska
2f7e7e9923 svg_loader: mask-type attribute introduced
In an svg file the mask-type attribute can be specified.
It takes one of the two values: Luminosity or Alpha.
After the LumaMask is introduced into TVG, this attribute can be
properly read by the svg loader.
2022-01-07 12:45:34 +09:00
Hermet Park
1f5b66c256 svg_loader: ++robustness
prevent a crash with an exceptional handling.

@Issue: https://github.com/Samsung/thorvg/issues/1131
2022-01-06 13:40:00 +09:00
Hermet Park
440cc81b4d sw_engine raster: fix a regression bug.
Picture example were broken by 90fa26b7bb

the correct condition must be like this change.
2022-01-06 12:40:22 +09:00
JunsuChoi
90fa26b7bb sw_engine SwRaster: Initialize uninitialized transform value 2022-01-05 17:08:59 +09:00
Mira Grudzinska
a6781734dc svg_loader: composite node splitted on mask and clip nodes
The SvgCompositeNode is replaced by the SvgMaskNode and SvgClipNode.
This is needed for using Luma/AlphaMask in the svg loader and in the future,
when we introduce other mask's features.
2022-01-03 12:30:01 +09:00
Michal Maciola
a18f85cca8
example: added LumaMasking.cpp (#621)
Added an example LumaMasking.cpp that tests CompositeMethod::LumaMask
2021-12-30 15:56:25 +01:00
Michal Maciola
4cbeb5e3df compositeMethod: introduced LumaMask
Introduced CompositeMethod::LumaMask that converts the source pixels to the
grayscale (luma value) before alpha blending. Thanks to it, mask works more like
typical mask in graphics editor software.
Grayscale is calculated with  weighted method:
(0.0721*B + 0.7154*G + 0.2125*R) * A
Introduced surface->blender.lumaValue function
2021-12-30 21:27:32 +09:00
Hermet Park
906679cbeb infra: just changed naming. 2021-12-24 14:04:08 +09:00
Shinwoo Kim
d349f73222 example: add script to execute all
This patch will save your time to check example.

  ./all.sh [interval time between examples, default is 1 second]
2021-12-24 14:01:55 +09:00
Hermet Park
100d98d82e common: Introduced Accessor for traversing the scene-tree.
Basically, this Accessor is a utility to debug the Scene structure,
by traversing the scene-tree by users.

You can search specific nodes to read the property information,
figure out the structure of the scene tree and its size.

We actually don't recommend you to touch the property unless you really
know the each paint's position and role because it's not visible, difficult to
understand its anatomy.

Also, You must underatnd that modifying the nodes of the scene will be going
well with both the art-design structure and the prorgram logic.

In this first version, Accessor only supports for the Picture class.

@example:

auto picture = tvg::Picture::gen();
picture->load("test.svg");

//The callback function from lambda expression.
//This function will be called for every paint nodes of the tree.
auto f = [](const tvg::Paint* paint) -> bool
{
    if (paint->identifier() == Shape::identifier()) {
        //override properties?
        uint8_t r, g, b, a;
        paint->fillColor(&r, &g, &b, &a);
        paint->fill(r / 2, g / 2, b / 2, a);
    }

    //You can return false, to stop traversing immediately.
    return true;
};

auto accessor = tvg::Accessor::gen();

picture = accessor->access(move(picture), f);

...

@Issue: https://github.com/Samsung/thorvg/issues/693
2021-12-23 11:54:44 +09:00
Hermet Park
9915d41164 Revert "common: introduce iterator"
This reverts commit e947fef9a4.

Bad... This patch was wrongly applied...
2021-12-23 11:29:58 +09:00
Hermet Park
77d33b2d9f sw_engine texmap: fix trivial compiler warnings.
warning: suggest braces around initialization of subobject [-Wmissing-braces]
2021-12-23 10:40:09 +09:00
Hermet Park
686e47d2cd doc: up to date v0.7 2021-12-22 19:11:22 +09:00
Hermet Park
5fd32acf73 infra: just released v0.7.0 2021-12-22 19:10:58 +09:00
Hermet Park
0aefbc3fb8 examples: update tvg binaries. 2021-12-22 18:48:49 +09:00
Hermet Park
8c29caf803 Backup tvg binaries of v0.6 2021-12-22 18:46:26 +09:00
Hermet Park
6a2aaa2064 sw_engine texmap: ++safety
Prevent range over just in case.
2021-12-22 16:40:27 +09:00
K. S. Ernest (iFire) Lee
33018aa123 Hide the thorvg LZW implementation. 2021-12-19 10:43:24 +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
05fefcf61f sw_engine raster: ++safety of the scaled image rasterization
Prevent out of buffer boundary access.

@Issues: https://github.com/Samsung/thorvg/pull/1119
2021-12-17 16:46:37 +09:00
Hermet Park
e947fef9a4 common: introduce iterator
+++

auto picture = tvg::Picture::gen();

auto func = [](const tvg::Paint* paint, const tvg::Paint* parent, bool hasChildren) -> int
{
    if (paint->identifier() == Shape::identifier())
        //TODO: override properties.

    //return true to continue, return false to stop.
    return true;
};

picture = tvg::Iteratorv::iterate(move(picture), func);
2021-12-17 12:16:14 +09:00
Mira Grudzinska
5b3252ecf9 capi: missing arg description added 2021-12-17 11:21:08 +09:00
Hermet Park
e258a2a662 sw_engine texmap: implemented fast span-edge anti-aliasing
This Anti-Aliasing mechanism is originated from Hermet Park's idea.
To understand this AA logic, you can refer this page:
www.hermet.pe.kr/122 (hermetpark@gmail.com)

@Issue: https://github.com/Samsung/thorvg/issues/161
2021-12-16 15:56:20 +09:00
JunsuChoi
791275c30a sw_engine SwShape: Fix coding style 2021-12-15 15:19:19 +09:00
JunsuChoi
c326b6ac3e sw_engine SwShape: Prevent null access
strokeOutline returned strokeExportOutline() is the address of mpool->strokeOutline[idx].
Assuming this value is null, mpoolRetStrokeOutline on line 617 will access mpool->strokeOutline[idx].
Logically, the logic of the mpool* functions does not occur in this case.
2021-12-15 15:19:19 +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
36da47af80 png_loaders: fix the wrong premultiplying operations.
It should not modify the alpha channel value while premultiplying
that turned out with the wrong visual result.

@Issue: https://github.com/Samsung/thorvg/issues/655
2021-12-13 23:46:15 -08:00
Hermet Park
62c9feb80a common paint: code refactoring
Grouping the composite data to add source paint necessarily.

this refactoring is a prerequisite job for the texmap anti-aliasing.
2021-12-13 20:44:07 +09:00
Hermet Park
d3f3a50309 common picture: remove unused variable. 2021-12-13 19:46:09 +09:00
Hermet Park
1d4db59a25 common: revise the identifier() implementation
Migrate the id property to the base class internals
so that pimpl classes could access the data easier.

This is a sort of prerequisite change for the coming texmap anti-aliasing.
2021-12-13 19:10:31 +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
e7b7705875 sw_engine raster: remove unnecessary functions.
These alpha/inverse alpha blender table is not useful so far,
we remove them since it just decrease the performance by by-pass addressing.
2021-12-01 18:36:12 +09:00
JunsuChoi
d8797092b5 sw_engine SwCommon: Change spans's x,y value type
The x and y of spans cannot be negative
because they are specified as coordinates inside the buffer.
Change the type to fix warnings and potential problems
that occur in conversion between int16_t and uint32_t.
2021-12-01 16:55:22 +09:00
JunsuChoi
e36c2029ce sw_engine SWRaster: Explicitly declare type cast to uint32_t 2021-11-30 15:46:26 +09:00
JunsuChoi
5715270dfb sw_engine SWRaster: Initialize uninitialized local variable 2021-11-30 14:54:55 +09:00
Hermet Park
c0cd645bb5 sw_engine raster: fix the regression bug of the image simple scaling rendering.
Gave up the optimization this logic.

It brings too many digressed code, not good for maintenance...
2021-11-30 12:03:10 +09:00
Hermet Park
46bdc8f1dc sw_engine texmap: remove unnecessary conditions.
remove exceptional handling for the performance.
2021-11-26 20:16:00 +09:00
Mira Grudzinska
4485db4f15 svg_loader: a function to establish shapes boundries without a stroke introduced
To handle the objectBoundingBox units, the shape's boundaries have to be known.
According to the SVG standard, a stroke shouldn't be taken into account. Since
the bounds() api uses the shape's stroke information, a new function is introduced,
that compensates this and returns boundaries without any strokes.
2021-11-26 11:47:15 +01:00
Mira Grudzinska
bd7c19a592 svg_loader: struct used to pass 1 args instead of 4 of them
The Box struct is introduced to replace the four functions
args: vx, vy, vw, vh, so all of them can be passed at once.
2021-11-26 11:47:15 +01:00
Hermet Park
19aa102749 sw_engine raster: fix the texmap regression bug.
Wrong inline function with C-preprocessing doesn't work at all...
Correct them with including the separate files instead.
2021-11-26 17:41:33 +09:00
Hermet Park
d2640c6313 Revert "sw_engine raster: code refactoring."
This reverts commit 860068301a.

found a regression bug. this macro doesn't work actually.
2021-11-26 17:21:27 +09:00
Hermet Park
860068301a sw_engine raster: code refactoring.
+ blending stages using macro magics.

I know this is a bit bad for code readibility but good for the maintanence
2021-11-25 20:07:39 +09:00
Hermet Park
eddaf615c3 sw_engine: code refactoring
unified the two color interpolate methods.
2021-11-25 20:04:37 +09:00
Hermet Park
2ca6f76d91 sw_engine texmap: code refactoring.
Unrolled the blending stages by applying macro magics.

I know this is a bit bad for code readibility
but good for the performance and the optimal LOC.
2021-11-25 18:51:04 +09:00