Commit graph

1253 commits

Author SHA1 Message Date
Hermet Park
bbfbe95ecc test: remove gtest & its infra.
thorvg is going to use catch2 framework, this is a cleanup work
before introducing catch2 utc.

See Catch2:
https://github.com/catchorg/Catch2/tree/v2.x
2021-06-03 17:38:07 +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
a8a120942e sw_engine: data optimization.
changed alpha channel data type to 32 bits from 8 bits,
since subsequent data operations requires 32 bits values.

this 8 bits (since channel range is up to 255) doesn't helpful
for saving memory size because it would generate additional data casting by compiler.

I compared the binary size and this patch saves about 600bytes.
2021-06-02 21:15:58 +09:00
Mira Grudzinska
6ccebb3234
sw_engine common: improving the alpha blending algorithm
Calculations accuracy in ALPHA_BLEND function has been
improved. Until now blending resulted in a slight hue change
(all color channels affected). The chosen method of calculation
is a compromise between the accuracy and the performance.
2021-06-02 21:01:12 +09:00
Hermet Park
c7a156d5a6 capi: fix usage after this - 2c37191584. 2021-06-02 20:14:10 +09:00
Mira Grudzinska
ed7d8b73b9 common: added API to get the transformation matrix of the object 2021-06-02 19:03:20 +09:00
Hermet Park
2c37191584 api: --inproper const syntax.
compoiste() requires internal data change, its api syntax should not contain "const"

though this changes the api spec, but won't affect build break
since it allows wider usage.

@API Modification

from:
Result Paint::composite(std::unique_ptr<Paint> target, CompositeMethod method) const noexcept

to:
Result Paint::composite(std::unique_ptr<Paint> target, CompositeMethod method) noexcept
2021-06-02 16:42:08 +09:00
Hermet Park
54fa59e7c3 docs: -- beta tag.
Scene::clear() is ready to public.
2021-05-28 16:24:48 +09:00
Hermet Park
0394fa5ef5 common: fix a potential memory leak after clear()
Paints must clear canvas engine data if they were dismissed from the canvas,

1. Canvas::clear(free = false) must retain all the paints from the paints hierarchy
so that user keeps the all dangled paints lifecycle.
In this scenario, it could leak the engine data of paints, this patch fixes it.

2. Previously, t just keeps the immediate paints lives of canvas, but not them of children of scene nor picture.
This patch changes a policy which was not considered seriously,
Now it keeps the all paints lives through the tree-hieararchy.

3. Also changed the Scene::clear() behavior identical to Canvas::clear() for consistency.

@API Modification:

From: Result Scene::clear() noexcept;
To: Result Scene::clear(bool free = true) noexcept;
2021-05-28 16:19:01 +09:00
Mira Grudzinska
3911a252e2 svg_loader: the viewBox clipping composite layer added independently of the shapes bounds
For now the bounding box of all the shapes was established and if it was larger
than the viewBox of the SVG, the clipping layer was added. The bounds api
returns the rectangle that encloses the shapes before any transformations.
So comparing it with the viewBox doesn't make sense. The comparison is removed
and the clipping layer is always added.
2021-05-28 14:39:02 +09:00
Hermet Park
61f07677c5 sw_engine renderer: fix aliasing problem.
a corner case is detected that anti-aliasing is missing at shapes
if the shape has the dash-style stroke.

By adding the condition, it applies anti-aliasing properly.

@Issues: 394
2021-05-28 14:24:37 +09:00
Mira Grudzinska
f1d5571aad Revert "svg_loader: clipping composite layer is added independently on the bounds of the shapes"
This reverts commit c38e4e40a7.
It was pushed by mistake. The same changes are currently under rev in PR #399
2021-05-28 04:30:09 +02:00
Mira Grudzinska
c38e4e40a7 svg_loader: clipping composite layer is added independently on the bounds of the shapes 2021-05-27 12:54:08 +02:00
JunsuChoi
ed8dfbc529 common Initializer: Fix init count
Calling init repeatedly doesn't increment count.
This leads to unwanted termination due to mismatch of the pair.
2021-05-27 17:03:38 +09:00
Mira Grudzinska
fbd24c3c93 common scene: fixing the initial values of variables in the bounds getter
The values of the most bottom right corner of the scene bounding box
should be initialized with the biggest negative values.
Also an empty line removed.
2021-05-27 13:33:03 +09:00
Mira Grudzinska
aeb10fafec sw_engine: refactoring of the radial gradient rle rastering function
The translucent rastering function is split into 3 other (instead of if/else statement).
An additional function is introduced to decide which one of the 3 should be called.
This refactoring is done to preserve the convention used for all other rastering functs.
2021-05-26 12:47:47 +09:00
Mira Grudzinska
c2d6fc4fdd sw_engine: refactoring of the radial gradient rect rastering function
The translucent rastering function is split into 3 other (instead of if/else statement).
An additional function is introduced to decide which one of the 3 should be called.
This refactoring is done to preserve the convention used for all other rastering functs.
2021-05-26 12:47:47 +09:00
Mira Grudzinska
7cb08bebe6 sw_engine: refactoring of the linear gradient rect rastering function
The translucent rastering function is split into 3 other (instead of if/else statement).
An additional function is introduced to decide which one of the 3 should be called.
This refactoring is done to preserve the convention used for all other rastering functs.
2021-05-26 12:47:47 +09:00
Hermet Park
aef3095464 docs: fixed relative thorvg image path to the absolute one. 2021-05-25 15:31:07 +09:00
JunsuChoi
6565465306 infra Documentation: Update main page and remove treeview 2021-05-25 15:15:51 +09:00
JunsuChoi
8eb3517da8 infra Documentation: Introduce ThorVG documentation page.
This is a documentation page based on doxygen.

CSS: https://jothepro.github.io/doxygen-awesome-css/
2021-05-25 14:21:09 +09:00
Mira Grudzinska
7b931b5e32 sw_engine: refactoring the linear gradient rle rastering function
The translucent rastering function is split into 3 other (instead of if/else statement).
An additional function is introduced to decide which one of the 3 should be called.
This refactoring is done to preserve the convention used for all other rastering functs.
2021-05-25 13:00:59 +09:00
Mira Grudzinska
f18fca5173 sw_engine: gradient shapes with opacity < 255 rastered properly
The cases with gradient shapes with composition are handled
in the same function as gradint shapes with opacity < 255.
Parts of the code from _rasterOpaque... grad functions moved to
_rasterTranslucent... grad functions.
2021-05-24 11:17:44 +02:00
Hermet Park
e52a6555d2
Update README.md 2021-05-22 16:14:12 +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
Mira Grudzinska
edaafd99b3 sw_engine: fixing wrong 'if else' statement handling when gradient shapes rastered
The cases when composition was applied were handled only for AlphaMask and
InvAlphaMask. When opacity value was to be < 255, there was no code
to handle this.
2021-05-21 18:18:21 +09:00
Mira Grudzinska
d999a05750 sw_engine: 'inv2a' variable from the SwRadial struct replaced by 'inva'
This change reduces the number of multiplications in the fillFetchRadal function.
2021-05-18 11:38:57 +09:00
Hermet Park
706dc68d56 res: remove icon 2021-05-17 13:58:52 +09:00
Hermet Park
4c8152e7eb
Update README.md 2021-05-16 23:59:02 +09:00
Hermet Park
498a07a984
Update README.md 2021-05-15 23:14:52 +09:00
Hermet Park
9c0b59301a
Update README.md 2021-05-15 21:56:31 +09:00
Hermet Park
ecafda3e05
Add files via upload 2021-05-15 20:19:34 +09:00
Hermet Park
af01f5b899 api doc: replace beta api desc to beta tag 2021-05-14 19:49:28 +09:00
JunsuChoi
f8f90f3f34 log SvgLoader: Enhance log message
- Change tag name "Doc" to "Svg"
- Fix "Mask" tag name.
- Add element to skip output
 - title
- Add attribute to skip output
 - id, data-name, version, overflow=visible, xmlns*, xml:space
2021-05-13 23:46:17 +09:00
Mira Grudzinska
dc637d0beb doc: linguistic changes in C++ API docs 2021-05-13 23:44:26 +09:00
Hermet Park
824b56acc1
Update README.md 2021-05-13 19:47:37 +09:00
Hermet Park
4ba4f47541
Update README.md 2021-05-13 19:41:17 +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
f676d6a25c infra: remove PULL REQUEST TEMPLATE.
By far, this is not so useful since commit message template and PR is very simliar.

It just bring messing up the PR contents.

Rather than it, we don't allow violating commit message rules. So... its unnecessary.

See CONTRIBUTING.md
2021-05-11 22:24:15 +09:00
Hermet Park
00dc7fb04f
Update CONTRIBUTING.md 2021-05-11 22:23:35 +09:00
Mira Grudzinska
924ea15cfa capi: added check against null pointer before dereferencing
TVG_RESULT_INVALID_ARGUMENT returned in case a nullptr passed as an argument
(does not apply to color getters).
The change is addressed in the docs file.
2021-05-11 12:09:23 +02:00
Mira Grudzinska
335880c58c docs: polishing up the C API docs 2021-05-06 14:12:37 +02:00
Hermet Park
557ad2daf3
Update README.md 2021-05-03 21:14:52 +09:00
Hermet Park
814cfe2f3b
Update README.md 2021-05-03 19:25:30 +09:00
JunsuChoi
475fc22f6d loader SvgLoader: Fix memory leak
Add memory release for style->comp.url, which is the leaking memory.

[Valgrind Test Result]
==21595== 32 bytes in 1 blocks are definitely lost in loss record 29 of 152
==21595==    at 0x4C3217F: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==21595==    by 0x5C248C6: _idFromUrl(char const*) (tvgSvgLoader.cpp:272)
==21595==    by 0x5C24DE1: _handleClipPathAttr(SvgLoaderData*, SvgNode*, char const*) (tvgSvgLoader.cpp:860)
==21595==    by 0x5C260CC: _attrParseGNode(void*, char const*, char const*) (tvgSvgLoader.cpp:953)
==21595==    by 0x5C2ABA9: simpleXmlParseAttributes(char const*, unsigned int, bool (*)(void*, char const*, char const*), void const*) (tvgXmlParser.cpp:272)
==21595==    by 0x5C26F6E: _createGNode(SvgLoaderData*, SvgNode*, char const*, unsigned int) (tvgSvgLoader.cpp:1063)
==21595==    by 0x5C27A04: _svgLoaderParserXmlOpen(SvgLoaderData*, char const*, unsigned int, bool) (tvgSvgLoader.cpp:2168)
==21595==    by 0x5C27CE9: _svgLoaderParser(void*, SimpleXMLType, char const*, unsigned int) (tvgSvgLoader.cpp:2226)
==21595==    by 0x5C2AC8C: simpleXmlParse(char const*, unsigned int, bool, bool (*)(void*, SimpleXMLType, char const*, unsigned int), void const*) (tvgXmlParser.cpp:378)
==21595==    by 0x5C27E09: SvgLoader::run(unsigned int) (tvgSvgLoader.cpp:2571)
==21595==    by 0x5C1A7C1: operator() (tvgTaskScheduler.h:68)
==21595==    by 0x5C1A7C1: tvg::TaskSchedulerImpl::run(unsigned int) (tvgTaskScheduler.cpp:138)
==21595==    by 0x5EED6DE: ??? (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.25)
2021-05-03 16:29:30 +09:00
Mira Grudzinska
2a4898cd19 Update README.md
Fixed example and minor linguistic changes
2021-05-03 15:59:27 +09:00
Hermet Park
1638844dfc
Update README.md
updated contents
2021-05-02 00:19:14 +09:00
Hermet Park
89e712fd2b
Update README.md
+ Practices: Tizen, Rive
2021-05-01 23:50:07 +09:00
Hermet Park
379b46f4e0
Update README.md 2021-05-01 14:58:30 +09:00
Hermet Park
ea316a348a res: updated images 2021-05-01 14:54:15 +09:00