Commit graph

1526 commits

Author SHA1 Message Date
Mira Grudzinska
74a99867df examples: terminate the same engine as was initialized 2022-01-21 23:55:17 +01: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
0f87685c85 svg_loader: ++robustness
Prevent recursive calls by counting just in case.

The size is arbitrary value, we can adjust it experimentally.

@Issue: https://github.com/Samsung/thorvg/issues/1161
2022-01-20 19:18:22 +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
Mira Grudzinska
922e3e10c0 svg_loader: group tags misinterpreted as parent nodes
Group tags in a format <tag .../> finds no application
to the rest of the svg file and should be skipped.
2022-01-19 16:42:06 +09:00
Rémi Verschelde
0c6c37b616 build: Add missing <cstring> includes for MinGW compatibility 2022-01-19 16:40:30 +09:00
Rémi Verschelde
4e14e30447 tvg_loader: Convert tvgJpgd.h EOL to LF
This makes it consistent with the rest of the codebase.
2022-01-19 16:35:38 +09:00
JunsuChoi
a5f5cd6d98 gl_engine GlRenderer: Fix build error
Change id() to identifier().

error log
```
../src/lib/gl_engine/tvgGlRenderer.cpp:333:19: error: ‘const class tvg::Fill’ has no member named ‘id’
  333 |     switch (fill->id()) {
```
2022-01-19 16:35:07 +09:00
Mira Grudzinska
99da490ef7 svg_loader: memleak prevention
If image href set more than once, the memory was not freed.
2022-01-18 18:22:01 +01:00
Hermet Park
a08d6e5079
Update README.md 2022-01-18 12:38:07 +09:00
Hermet Park
48a81301e1
Update README.md 2022-01-18 12:37:05 +09:00
JunsuChoi
ad132eae12 infra: Fix ubuntu version and meson install
libefl-dev -> libefl-all-dev
ubuntu 19 -> 20
meson user install -> root install
2022-01-17 15:04:16 +09:00
Mira Grudzinska
ed3b17b228 svg_loader: preventing memcpy from a nullptr
In a case when a polygon/polyline had no points, there is nothing
to be copied.
2022-01-17 12:05:34 +09:00
Mira Grudzinska
04d3bb0ec0 svg_loader: fixing cyclic cloning of nodes
The reference node doesn't have to be placed inside the defs block,
so when refering to it, it is necessary to search the entire node tree.
In case of invalid svg file this can lead to circular references.
Added prevention against such a sutuation.
2022-01-17 12:03:57 +09:00
Michal Maciola
9212c0d158 sw_engine: fix comparison of integer expressions of different signedness
Some gcc versions and configurations was giving an error:
error: "comparison of integer expressions of different signedness: 'const SwCoord'
{aka 'const long int'} and 'uint32_t' {aka 'unsigned int'} [-Werror=sign-compare]"
This patch should fix the error
2022-01-17 12:02:51 +09:00
Michal Maciola
a0895cc91b sw_engine: fixed declaration of 'i' shadows a previous local
Some gcc versions and configurations was giving an error: error:
"declaration of 'i' shadows a previous local"
This patch should fix these errors
2022-01-17 12:01:58 +09:00
Mira Grudzinska
43e5644e8b svg_loader: fixing memleak
Memory was not freed before reallocation (grad->ref can be overwritten
without freeing memory first) - fixed.
2022-01-15 17:26:20 +01:00
Mira Grudzinska
6fb0984b49 svg_loader: postponed nodes properly cloned
In case when no defs tag was used, no child node was found.
Also the node attributes should not override those set in the ancestor.
2022-01-12 09:54:57 +01:00
Hermet Park
f0141e63de updated copyright date. 2022-01-12 14:08:48 +09:00
Mira Grudzinska
2217b94361 svg_loader: changed the order of if conditions
The weekest condition should be checked as the last one.
Otherwise CDATA marker was never found.
2022-01-11 14:05:00 +09:00
Mira Grudzinska
baf45823cb svg_loader: the color attribute properly inherited
The color attribute hat to be inherited regardles whether it is used
in the child node or not - it may be used i.e. in the grandchild node.
2022-01-11 14:04:39 +09:00
Mira Grudzinska
4b0037fe6a svg_loader: removing repeated lines
The clip-path and the mask attributes are both parsed in _attrParseGNode
function, which is called in th _attrParseUseNode.
2022-01-11 14:03:33 +09:00
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