Commit graph

998 commits

Author SHA1 Message Date
JunsuChoi
ea3d79f5f3 svg_loader: Support percentage unit of dash-array
Refers to the diagonal length of the viewport.
https://www.w3.org/TR/SVG2/coords.html#Units
2021-07-07 09:48:46 +09:00
Michal Maciola
1e1f232016 png_loader: added open from memory
Added PngLoader::open(const char* data, uint32_t size, bool copy)
Changed variables visibility to private
2021-07-06 18:32:08 +09:00
Mira Grudzinska
1507438ecc svg_loader: set the priority for the style attribute for stop properties
Stop properies stop-color and stop-opacity set using a style attribute should
have higher priority than properties set in a different way.
2021-07-06 10:13:58 +02:00
Mira Grudzinska
fff5bfee83 svg_loader: set the higher priority of style attributes
issue #515
2021-07-06 10:13:58 +02:00
Hermet Park
ca86907739 common: code refactoring.
remove unnecessary comments,
its field name is enough descriptive. (It has to be!)
2021-07-06 11:13:54 +09:00
Mira Grudzinska
795e520404 tvg_loader: change values of flags
It's a middle stage leading to removing flags from the tvgBinaryDesc.h file
and use the corresponding enums from the thorvg.h file.
2021-07-06 11:07:10 +09:00
Hermet Park
925b9c8ba9 sw_engine fill: correct the range of opacity,
also some minor code refactors.
2021-07-06 10:44:56 +09:00
Michal Maciola
7a8d7ceac6 svg_loader: fix dead loop on none digit char in stroke-dasharray fix #3
Added zero and negative value protection
2021-07-06 10:39:34 +09:00
Michal Maciola
bf8c633d38 svg_loader: fix dead loop on none digit char in stroke-dasharray fix #2
Moved _skipComma at the begining of the loop
2021-07-06 10:39:34 +09:00
Michal Maciola
2f8c00580d svg_loader: fix dead loop on none digit char in stroke-dasharray 2021-07-06 10:39:34 +09:00
Mira Grudzinska
a40d3f6fd7 sw_engine: stop-opacity value should be interpolated between stops
The opacity value is interpolated as are all color channels.
It's similar to the reverted commit ac95433, but with two slight changes
(alpha_blend was missing in the ctable init and 'a' was used in an if
statement instead of 'a2').
2021-07-06 10:33:02 +09:00
Hermet Park
15d6a51527 common linear_gradient: fix to allow zero size linear.
We can't judge zero size gradient is error case.
Non-filled linear is possibly intended by calculation.
2021-07-04 01:36:51 +09:00
Hermet Park
8e2765be39 common picture: fix invalid size returns from raw image.
picture/raw should update the size if the raw image
with size values are entered.
2021-07-03 16:15:57 +09:00
Hermet Park
8d31496648 infra: print enabled features in the meson summary list.
instead removed individual messages.
2021-07-03 14:58:17 +09:00
Michal Maciola
99263d54d1 svg_loader: multiple composition memory leak
Multiple composition are still not supported, but this patch fixes a
memory leak if it is tried to be applied.
2021-07-03 14:14:01 +09:00
Michal Maciola
6a09a8f015 svg_loader: memory leak after improper stop tag fix #1
Updated printf message
2021-07-03 13:50:03 +09:00
Michal Maciola
b005f97bcd svg_loader: memory leak after improper stop tag
<stop> tag should be always a child of a <linearGradient> or
<radialGradient> element, but there were files with <stop> tag inside <rect>.
This patch fixes a memory leak if no gradient is defined before <stop> tag.
2021-07-03 13:50:03 +09:00
Hermet Park
8aa941c4ab common picture: ++exception case.
Fixed load() to return InvalidArgument if the file path is invalid.
2021-07-02 14:01:52 +09:00
JunsuChoi
113ca8b845 svg_loader SvgPath: Added corner case handling for flags of Arc
Moved the if statement to check if it is a float.

This patch is that reverts and fixes the reverted patch 55a5b9.
2021-07-02 12:49:00 +09:00
Hermet Park
3f176b733b common picture: ++ exception case.
size() returns InsufficientCondition if it doesn't have any loaded data.
2021-07-02 12:07:34 +09:00
Hermet Park
2fd830c940 common shape: allow to reset stroke dash.
user may need to reset stroke dash to off,
now stroke api allows it.
2021-07-02 10:35:46 +09:00
Hermet Park
55a5b9492b Revert "svg_loader SvgPath: Added corner case handling for flags of Arc"
This reverts commit 5da4c81138.

Please double-check this regression bug:

examples/images/samsung-galaxy-s.svg
2021-07-01 18:04:25 +09:00
Hermet Park
e74ce7e315 sw_engine: --sanitizer errors
runtime error: load of value 190, which is not a valid value for type 'bool'

@Issue: https://github.com/Samsung/thorvg/issues/544
2021-07-01 17:59:27 +09:00
Hermet Park
480bd8376e common array: -- sanitizer errors
runtime error: null pointer passed as argument 1, which is declared to never be null

@Issue: https://github.com/Samsung/thorvg/issues/543
2021-07-01 17:41:56 +09:00
Hermet Park
e1eabf7dc3 Revert "sw_engine: stop-opacity value should be interpolated between stops"
This reverts commit ac95433b53.

Ahh this breaks examples/images/rg1024_eggs.svg
2021-07-01 17:34:59 +09:00
Mira Grudzinska
f411b5a64c svg_loader: recalculating the default values of grads
The default values of gradient properties were handled differently
than the values given by a user/in an svg file.
2021-07-01 12:15:55 +09: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
Mira Grudzinska
ac95433b53 sw_engine: stop-opacity value should be interpolated between stops
The opacity value is interpolated as are all color channels.
2021-06-30 19:32:52 +09:00
Michal Maciola
3086f28b55
svg_loader: allow multiple <defs> tags without data and memory leak (#528)
* svg_loader: allow multiple defs without data and memory leak

If the svg file contained multiple <defs> tags, each subsequent tag
overwritten the previous tag. This resulted in incorrect rendering of the
file and memory leaks.

@Issues: 491

* svg_loader: allow multiple defs without data and memory leak- fix #1

Changed the idea to abandon node creating instead of deleting it after
creation. Removed simpleXmlParseAttributes for _createDefsNode.
2021-06-30 17:21:30 +09:00
Hermet Park
19a3190245 svg_loader: fix a infinite loop error by circular dependency.
Composition can be applied recursively if its children nodes have composition target to this one.
This can be occured by wrong svg description, and tvg prevents this exception case.

@Issue: https://github.com/Samsung/thorvg/issues/494
2021-06-30 16:12:16 +09:00
Hermet Park
fcbc77bcdf svg_loader: code refactoring
unify to tvg fill rule.
2021-06-30 15:18:14 +09:00
Hermet Park
2c24a1fa5e svg_loader: recover partial code from 3e7888b538
oops, log was not tested in the patch...
2021-06-30 15:12:15 +09:00
Hermet Park
571a1e5caa svg_loader: code refactoring
remove more unused declarations...
2021-06-30 14:54:22 +09:00
Hermet Park
3e7888b538 svg_loader: code refactoring
use color structure to keep neat & compact code.
2021-06-30 14:54:12 +09:00
Hermet Park
8dc5d5204b svg_loader: code refactoring
remove unused declaration.
2021-06-30 13:47:22 +09:00
Hermet Park
6a79d2c06e svg_loader: fix the inifite loop bug when size has 'em' unit.
svg may have 'em' unit for fonts, strtof() must handle this case to not
drop in the infinite loop.

Yet thorvg doesn't support font feature in svg,
it must multiply values with font size if those values have 'em' size.

@Issue: https://github.com/Samsung/thorvg/issues/488
2021-06-30 11:27:31 +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
c31156e737 sw_engine renderer: fix a broken composition bug
tvg sw_engine tries to skip composition as far as its doable,
it tries composition only if the translucent shape with stroking is there.

There has been a condition bug that composition is applied unnecessarily
even if stroking is disabled. This resulted in broken blending
at gradient filling since it applied alpha values multiple times.

Issues:
https://github.com/Samsung/thorvg/issues/445
2021-06-29 14:44:09 +09:00
Mira Grudzinska
feb71ff36c svg_loader: currentColor - inheritance from a parent
The 'currentColor' attribute value was not inherited. Fixed.
2021-06-29 09:27:52 +09:00
Michal Maciola
520d6e7bbd svg_loader: negative attrs length fix
After finding no attributes but white spaces, attrs length could be negative
that resulted in segmentation fault in simpleXmlParseAttributes function.

@Issue: #487
2021-06-28 16:46:26 +09:00
Hermet Park
78bb8d1f2e svg_loader: fix trivial build warnings.
../src/loaders/svg/tvgSvgLoader.cpp: In function ‘void _copyAttr(SvgNode*, const SvgNode*)’:
../src/loaders/svg/tvgSvgLoader.cpp:1598:60: warning: ‘void* memcpy(void*, const void*, size_t)’ writing to an object of type ‘struct SvgStyleProperty’ with no trivial copy-assignment; use copy-assignment or copy-initialization instead [-Wclass-memaccess]
     memcpy(to->style, from->style, sizeof(SvgStyleProperty));

@Issue: 498
2021-06-28 13:47:15 +09:00
Mira Grudzinska
57a22b8462 svg_loader: finish the search after founding the proper color
In the _toColor func, after founding the proper color, the search
should be finiched.
2021-06-28 11:32:44 +09:00
Mira Grudzinska
f477933098 svg_loader: applying opacity to the gradient
Before this change the 'stroke-opacity' and the 'fill-opacity'
grad style attributes were not taken into account.
2021-06-28 10:34:14 +09:00
Mira Grudzinska
6eea979dae common: introducing the composite API (getter)
The new API gets the composite method and the pointer to the composite
target of the given paint object.
2021-06-25 22:16:06 +09:00
Mira Grudzinska
96d6b47a64 common: PaintType enum changed to identifier in Paint class
The PaintType enum was used to set the paint type in the internal Paint
implementation. This solution is switched to an identifier with id() getter,
so that the information about the type can be reached from outside the Paint.
2021-06-25 22:13:20 +09:00
Hermet Park
a6f9ec3080 svg_loader: fix memory violation issues.
copy attribute must copy the url data,
otherwise, url memory can be atempted freeing twice.

also, fix the memory leak in multiple composition case.
2021-06-25 10:28:27 +09:00
Mira Grudzinska
286f700305 svg_loader: handling the ColorStop offset values
The ColorStop offset < 0 and > 1 should be treated as 0 and 1 respectively.
The offset value < than the previous offset value should be replaced
by the previous value - without this change segfault occurred.
Validating the APIs parameters values is the user responsibility.
2021-06-24 20:54:03 +09:00
Hermet Park
750ad90bf0 sw_engine stroke: set stroke invalid if points are zero.
This valid tag is used for further progress.
we don't need it actually since we can count by points number.
2021-06-24 20:50:37 +09:00
Hermet Park
86fd0f67cf svg_loader: prevent heap memory overflow.
if the input points are odd-numberd by invalid svg data, it could access invalid memory.

Prevents it just in case.
2021-06-24 16:54:07 +09:00
JunsuChoi
5da4c81138 svg_loader SvgPath: Added corner case handling for flags of Arc
It handles the case what the flag of the arc of the path is defined
without spaces or commas, such as 00, 01, 11 or 10.
2021-06-24 08:52:30 +02:00