Commit graph

913 commits

Author SHA1 Message Date
Hermet Park
73ea4abf51 infra: just released v0.2.0 2021-06-06 17:36:48 +09:00
Hermet Park
59198d2735 infra: set higher version to try the devel symbols with higher priority than released ones. 2021-06-06 17:12:41 +09:00
Michal Szczecinski
f8b636d4d0 common gradient: Fix possible crash in color setter
Memcpy is not allowed on nullptr. If colorStops is invalid colors are
cleared.
2021-06-04 21:36:16 +09:00
Michal Maciola
718578532c capi: include <stdint.h> into thorvg_capi.h 2021-06-04 19:52:34 +09:00
Hermet Park
1fedb49e59
Update CONTRIBUTING.md
fix typos.
2021-06-04 17:46:04 +09:00
Hermet Park
5abcb19e6c
Update CONTRIBUTING.md
++ self-test & verification
2021-06-04 17:43:04 +09:00
Hermet Park
b299157123 capi: add tvg_paint_get_transform() api. 2021-06-04 16:48:00 +09:00
Hermet Park
6b7aa8ad9e
tests: introduce catch2 unit tests infrastructure.
Catch2 is a multi-paradigm test framework for C++.
It is primarily distributed as a single header file,
very easy and simple to adopt this to thorvg project.

This patch introduces catch2 infrastsructure and one prototype as a sample.

You can refer "testInitializer.cpp", how to add unit test!
while ignoring else files such as "catch2.hpp", "testMain.cpp"

Also, enable Unit-tests with meson option when you change any thorvg code.

$meson build -Dtests=true.

launch tvgUnitTest in the build result then verify 100% coverage
before submitting any patches.
2021-06-04 16:46:34 +09:00
Hermet Park
efa0035fe6 common initializer: correct the result value.
When memory is not allocated successully, it must return the FailedAllocation as the return value.
Previous initializer wrongly returns the value that case, this corrects it.
2021-06-03 20:48:02 +09:00
Hermet Park
c2b2aa92c3 infra: install capi header file only its binding option is enabled.
decouple the capi header from the default headers by replacing it in capi folder.
now it's also installed optionally.
2021-06-03 20:43:39 +09:00
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