Commit graph

361 commits

Author SHA1 Message Date
Hermet Park
0fb8ed38d7 api: remove extern "C"
Remove extern "C specifier. ThorVG has the C binding,
C++ apis doesn't need to be compatibile with a C compiler.
This limits the C++ style template interface.
2023-05-15 12:07:55 +09:00
Hermet Park
aa000f7c56 api: remove deprecated apis
- Result Paint::bounds(float* x, float* y, float* w, float* h) const noexcept;
- Result Picture::load(const char* data, uint32_t size, bool copy = false) noexcept;

@Issue: https://github.com/thorvg/thorvg/issues/1372
2023-05-13 18:30:11 +09:00
Hermet Park
ddc846289c apis: Let's promote the beta APIs to official ones.
- enum class CompositeMethod::LumaMask
- Result Picture::load(uint32_t* data, uint32_t w, uint32_t h, bool copy)
2023-05-09 23:19:15 +09:00
Hermet Park
84012651cc common engine: code refactoring
Introduce the RenderMesh structure to reduce the number of required parameters.
2023-04-27 10:16:12 +09:00
Hermet Park
69063d2405 infra: specify TVG_API for both static/dynamic linking.
The previous meson script was incomplete,
therefore this change requires it to be revised.

To enable static linking use the next meson option.
"-Ddefault_library=static"

Issue: https://github.com/thorvg/thorvg/issues/1234
2023-04-22 18:32:22 +09:00
Mira Grudzinska
69a9583354 common: order(bool strokeFirst) api introduced
The new api is introduced to handle the rendering
order of a stroke and a fill. By default fill is
rendered as the first one, stroke as the second
one. This order can be reversed by calling
order(true).

@Issue: https://github.com/thorvg/thorvg/issues/1340
2023-04-18 22:21:55 +09:00
Hermet Park
110f4a5cc9 common paint: keep clean apis and small size.
these are no more necessary.
2023-02-04 16:25:50 +09:00
Hermet Park
476643928d doc: updated the header description. 2023-01-26 21:37:14 +09:00
Mira Grudzinska
0de3872be3 common: ignoring color/alpha/opacity of a clip object
According to the svg specs clip's fill and opacity
should be ignored. Till now setting the alpha/opacity
value to zero resulted in the shape's rendering abort.

@Issue: https://github.com/Samsung/thorvg/issues/1192
2023-01-19 23:21:34 +01:00
Mira Grudzinska
1980d9d0e3 all: Trailing spaces removed 2023-01-07 10:53:51 +09:00
Hermet Park
dc477e197b common Accessor: removed deprecated api.
the old version of Accessor::access() is redundant,
we replaced it with set().

It's still under the beta, we can remove it immediately.
Note that we've planned to promote them official APIs in v0.9.

Newly changed, tagging beta again...w
2022-11-26 19:02:11 +09:00
JunsuChoi
3ba0b8adff common Accessor: Add access API using std::function 2022-11-25 15:25:49 +09:00
JunsuChoi
6e26aab1b6 common Accessor: Add access api that with data parameter
It supports data parameters that
can pass user data to the callback function.

std::unique_ptr<Picture> access(std::unique_ptr<Picture> picture, bool(*func)(const Paint* paint, void* data), void* data) noexcept;
2022-11-25 15:25:49 +09:00
Hermet Park
ddb9bbdf0e common picture: code refactoring.
keep api parameter naming consistency.

ptsCnt, cmdCnt, triangleCnt ...
2022-08-20 15:21:31 +09:00
Hermet Park
c0a246ee71 apis: removed BETA_API tag for identifiers and Accessor.
These apis are promoted to the official apis, released in v0.9
2022-08-20 14:28:48 +09:00
projectitis
3dd65dfed0 common picture: support image mesh feature
Tvg Picture newly provides mesh() api to support texture mapping.
These apis allows to have a coarse triangle list which have polygon coordinates
and texture uvs those are used for traditional polygon texture mapping.

Note that these apis are beta version.

@API Additions:

Result mesh(const Polygon* triangles, const uint32_t triangleCount) noexcept
uint32_t mesh(const Polygon** triangles) const noexcept

@Examples:

//Mapping with two polygons
Polygon polygon[2];

//First polygon
polygon[0].vertex[0].pt = {0, 0};
polygon[0].vertex[1].pt = {100, 0};
polygon[0].vertex[2].pt = {0, 100};
polygon[0].vertex[0].uv = {0, 0};
polygon[0].vertex[1].uv = {1, 0};
polygon[0].vertex[2].uv = {0, 1};

//Second polygon
polygon[1].vertex[0].pt = {100, 0};
polygon[1].vertex[1].pt = {100, 100};
polygon[1].vertex[2].pt = {0, 100};
polygon[1].vertex[0].uv = {1, 0};
polygon[1].vertex[1].uv = {1, 1};
polygon[1].vertex[2].uv = {0, 1};

//Apply polygons to the picture
picture->mesh(polygon, 2);

@Issues: https://github.com/Samsung/thorvg/issues/1218
2022-08-20 11:58:55 +09:00
Vincent Torri
6687defc0b Windows: set TVG_EXPORT to dllexport also for mingw
In addition, remove TVG_EXPORT from enum class. They are types
not symbols
2022-08-20 11:45:01 +09: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
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
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
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
e2dd889e1a apis: promote beta apis to the official ones.
these apis are good to open in the next release.
2021-11-11 14:17:43 +09:00
Hermet Park
3b2e1f4291 Revert "loaders: Consider colorspaces (#838)"
This reverts commit cd5116b053.

Ah this breaks the Stress example due to Picture::duplicate() is not available...

Need to consider and come back again.
2021-11-01 16:53:25 +09:00
Michal Maciola
cd5116b053
loaders: Consider colorspaces (#838)
* common: added colorSpace() function

This patch introduces colorSpace() function for SW and GL engine.

* infra: change LoadModule:read() into LoadModule:read(uint32_t colorspace)

This patch changes LoadModule:read() into LoadModule:read(uint32_t colorspace)

* picture: implement passing colorspace into loader

This patch implements passing colorspace into loaders.
Loader->read is now called on the first update.

* external_jpg_loader: support colorspaces

* external_png_loader: support colorspaces
2021-11-01 16:10:22 +09:00
Michal Maciola
479cea74cc common: Unmultiplicated colorspace
This patch introduces _STRAIGHT colorspaces (ABGR8888_STRAIGHT and
ARGB8888_STRAIGHT) whose colors are un-alpha-premultiplied. Unmultiplicated
colors are especially needed for wasm thorvg loader and svg2png / tvg2png.
Only C version now.

@issue: #791
2021-11-01 15:57:13 +09:00
Hermet Park
f24409a76d doc: updated api doc.
use @retval for the multiple return values.
2021-10-23 11:52:10 +09:00
Hermet Park
47334800c6 common: code refactoring
renamed internal module name IteratorModule -> IteratorAccessor
2021-10-22 23:20:29 +09:00
Hermet Park
999c01ede8 api: not allow the inheritance of the Saver.
We missed the final keyword for the Saver,
This inheritance is out of our policy.

It might be break apis but Saver class is just opened,
and we're pretty sure that there is no any extension of this.

I know this is the bad decision, but we have a chance yet,
so we must correct it before further late.
2021-10-22 19:15:05 +09:00
Hermet Park
36270f588e common: replace the id() -> identifier() 2021-10-22 18:47:05 +09:00
Hermet Park
78d85d714a common: Introduce class type identifier apis.
This identifier is useful when user identify the instance type in runtime.

ThorVG basically don't prefer to dynamic_cast() nor typeid(),
it compiles with -fno-rtti option for the optimial size.

Here is an example for the simple usage.

if (paint->identifier() == Shape::identifier())
  auto shape = static_cast<Shape*>(paint);

@Issue: https://github.com/Samsung/thorvg/issues/693
2021-10-22 18:47:05 +09:00
Ji2z
fcb0258b3c common: Fix typo
Fix typo backeneds to backends
2021-10-22 15:10:02 +09:00
Mira Grudzinska
e0aa007659 common: new api for a grad transformation
The new apii allows to transform the gradient fill.
2021-10-19 17:43:24 +09:00
JunsuChoi
fe35f69530 common: Fix typo 2021-10-19 16:28:28 +09:00
Mira Grudzinska
39af185de8 docs: ++ 2021-10-12 14:04:18 +02:00
Mira Grudzinska
6a63a5feac docs: saver module description ++ 2021-10-12 14:52:20 +09:00
Mira Grudzinska
dc55070ba7 docs: c and c++ apis docs improved 2021-10-06 22:11:17 +09:00
Mira Grudzinska
e7c3a91aa1 all: fixing clang warnings
fopen->fopen_s, strdup -> _strdup, strncpy -> strncpy_s
__declspec(dllexport) -> __attribute__ ((visibility ("default")))
2021-10-06 11:13:12 +09:00
Mira Grudzinska
fc29d888f1 docs: ++ docs of the load apis 2021-10-05 14:16:41 +02:00
Mira Grudzinska
5b7f94a527 capi: picture size apis added 2021-10-05 16:03:10 +09:00
Mira Grudzinska
aeda0e0ad3
docs: minor changes (#868) 2021-10-04 10:03:48 +02:00
Mira Grudzinska
9ad9c3e3f4
docs: improving c++ and c apis docs 2021-10-01 15:10:40 +09:00
Mira Grudzinska
79f7c744c5 svg_loader: fixing minor warnings 2021-09-28 12:07:52 +02:00
Hermet Park
74954db56d common paint: refine the bounds() api to return the values after applying transformation.
Current paint::bounds() returns the coordinates under the raw status,
the values are not quite useful if the paint object has the transformed children.

Thus, we extends the feature and give an additional parameter "transformed"
to return the coordinates values after transformation by user demands.

This is also necessary for tvg format, since we need the exact view size of the scene information.

The previous api is deprecated and we introduce a new api to replace it.

@APIs:
+ Result Paint::bounds(float* x, float* y, float* w, float* h, bool transformed) const noexcept;
- Result Paint::bounds(float* x, float* y, float* w, float* h) const noexcept;

@Issues: https://github.com/Samsung/thorvg/issues/746
2021-09-24 11:25:49 +09:00
Hermet Park
000d3ec2f0 apis: release official apis.
tvg picture is going to be released, we need the Saver as well.
Also, two stable periperal apis are released in v0.5

@APIs:
Result Picture::load(const char* data, uint32_t size, const std::string& mimeType, bool copy = false) noexcept;
CompositeMethod Paint::composite(const Paint** target) const noexcept;
Result Saver::save(std::unique_ptr<Paint> paint, const std::string& path, bool compress = true) noexcept;
Result Saver::sync() noexcept;
static std::unique_ptr<Saver> Saver::gen() noexcept;
2021-09-24 11:25:27 +09:00
Hermet Park
e784143ff8 api: remove the redundant api, Picture::paint().
tvg::Picture is replaced to tvg::Scene if the picture has the vector tree,
Thus it's useless since it won't be reached logically.
2021-09-23 20:15:23 +09:00
Hermet Park
4e9452c4b8 api: removed unused 2021-09-09 14:18:46 +09:00
Michal Maciola
2a2ccb30bd
Wasm: allow iterator and add functions for layers revising (#730)
* common: move iterator functionality into separate IteratorModule
* wasm: allow internal lib dependencies and iterator
* wasm: added functions for layers revising

This patch adds functions to thorvgwasm.cpp:
 layers() - that return a list of paints in a picture
 bounds() - that returns a bounds of a given paint
 setOpacity() - that sets the opacity of a given paint
2021-09-09 13:06:13 +09:00
Hermet Park
79933d9efa api: set default value nullptr for user convenience. 2021-09-09 12:40:43 +09:00