Skip to content

Commit 0091be4

Browse files
authored
feat(thorvg): update thorvg to 0.15.3 (lvgl#7103)
Signed-off-by: lhdjply <[email protected]>
1 parent 4aa74e1 commit 0091be4

File tree

668 files changed

+6491
-4417
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

668 files changed

+6491
-4417
lines changed

src/libs/thorvg/config.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@
1111

1212
#define THORVG_LOTTIE_LOADER_SUPPORT LV_USE_LOTTIE
1313

14-
#define THORVG_VERSION_STRING "0.13.5"
14+
#define THORVG_VERSION_STRING "0.15.3"
1515

src/libs/thorvg/thorvg.h

Lines changed: 330 additions & 322 deletions
Large diffs are not rendered by default.

src/libs/thorvg/thorvg_capi.h

Lines changed: 388 additions & 210 deletions
Large diffs are not rendered by default.

src/libs/thorvg/thorvg_lottie.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ namespace tvg
1515
*
1616
* @see Animation
1717
*
18-
* @note Experimental API
18+
* @since 0.15
1919
*/
2020

2121
#include "../../lv_conf_internal.h"
@@ -81,13 +81,13 @@ class TVG_API LottieAnimation final : public Animation
8181
* @note Experimental API
8282
*/
8383
const char* marker(uint32_t idx) noexcept;
84-
84+
8585
/**
8686
* @brief Creates a new LottieAnimation object.
8787
*
8888
* @return A new LottieAnimation object.
8989
*
90-
* @note Experimental API
90+
* @since 0.15
9191
*/
9292
static std::unique_ptr<LottieAnimation> gen() noexcept;
9393
};

src/libs/thorvg/tvgAccessor.cpp

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,21 @@
2424
#if LV_USE_THORVG_INTERNAL
2525

2626
#include "tvgIteratorAccessor.h"
27+
#include "tvgCompressor.h"
2728

2829
/************************************************************************/
2930
/* Internal Class Implementation */
3031
/************************************************************************/
3132

32-
static bool accessChildren(Iterator* it, function<bool(const Paint* paint)> func)
33+
static bool accessChildren(Iterator* it, function<bool(const Paint* paint, void* data)> func, void* data)
3334
{
3435
while (auto child = it->next()) {
3536
//Access the child
36-
if (!func(child)) return false;
37+
if (!func(child, data)) return false;
3738

3839
//Access the children of the child
3940
if (auto it2 = IteratorAccessor::iterator(child)) {
40-
if (!accessChildren(it2, func)) {
41+
if (!accessChildren(it2, func, data)) {
4142
delete(it2);
4243
return false;
4344
}
@@ -47,26 +48,46 @@ static bool accessChildren(Iterator* it, function<bool(const Paint* paint)> func
4748
return true;
4849
}
4950

51+
5052
/************************************************************************/
5153
/* External Class Implementation */
5254
/************************************************************************/
5355

54-
unique_ptr<Picture> Accessor::set(unique_ptr<Picture> picture, function<bool(const Paint* paint)> func) noexcept
56+
TVG_DEPRECATED unique_ptr<Picture> Accessor::set(unique_ptr<Picture> picture, function<bool(const Paint* paint)> func) noexcept
57+
{
58+
auto backward = [](const tvg::Paint* paint, void* data) -> bool
59+
{
60+
auto func = reinterpret_cast<function<bool(const Paint* paint)>*>(data);
61+
if (!(*func)(paint)) return false;
62+
return true;
63+
};
64+
65+
set(picture.get(), backward, reinterpret_cast<void*>(&func));
66+
return picture;
67+
}
68+
69+
70+
Result Accessor::set(const Picture* picture, function<bool(const Paint* paint, void* data)> func, void* data) noexcept
5571
{
56-
auto p = picture.get();
57-
if (!p || !func) return picture;
72+
if (!picture || !func) return Result::InvalidArguments;
5873

5974
//Use the Preorder Tree-Search
6075

6176
//Root
62-
if (!func(p)) return picture;
77+
if (!func(picture, data)) return Result::Success;
6378

6479
//Children
65-
if (auto it = IteratorAccessor::iterator(p)) {
66-
accessChildren(it, func);
80+
if (auto it = IteratorAccessor::iterator(picture)) {
81+
accessChildren(it, func, data);
6782
delete(it);
6883
}
69-
return picture;
84+
return Result::Success;
85+
}
86+
87+
88+
uint32_t Accessor::id(const char* name) noexcept
89+
{
90+
return djb2Encode(name);
7091
}
7192

7293

src/libs/thorvg/tvgAnimation.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ float Animation::duration() const noexcept
9898

9999
Result Animation::segment(float begin, float end) noexcept
100100
{
101-
if (begin < 0.0 || end > 1.0 || begin >= end) return Result::InvalidArguments;
101+
if (begin < 0.0 || end > 1.0 || begin > end) return Result::InvalidArguments;
102102

103103
auto loader = pImpl->picture->pImpl->loader;
104104
if (!loader) return Result::InsufficientCondition;

src/libs/thorvg/tvgArray.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ struct Array
6262
data[count++] = element;
6363
}
6464

65-
void push(Array<T>& rhs)
65+
void push(const Array<T>& rhs)
6666
{
6767
if (rhs.count == 0) return;
6868
grow(rhs.count);

src/libs/thorvg/tvgBinaryDesc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ using TvgBinFlag = TvgBinByte;
3939
#define TVG_HEADER_SIZE 33 //TVG_HEADER_SIGNATURE_LENGTH + TVG_HEADER_VERSION_LENGTH + 2*SIZE(float) + TVG_HEADER_RESERVED_LENGTH + TVG_HEADER_COMPRESS_SIZE
4040
#define TVG_HEADER_SIGNATURE "ThorVG"
4141
#define TVG_HEADER_SIGNATURE_LENGTH 6
42-
#define TVG_HEADER_VERSION "001200" //Major 00, Minor 12, Micro 00
42+
#define TVG_HEADER_VERSION "001500" //Major 00, Minor 15, Micro 00
4343
#define TVG_HEADER_VERSION_LENGTH 6
4444
#define TVG_HEADER_RESERVED_LENGTH 1 //Storing flags for extensions
4545
#define TVG_HEADER_COMPRESS_SIZE 12 //TVG_HEADER_UNCOMPRESSED_SIZE + TVG_HEADER_COMPRESSED_SIZE + TVG_HEADER_COMPRESSED_SIZE_BITS

src/libs/thorvg/tvgCanvas.h

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,15 @@
2929
#include "tvgPaint.h"
3030

3131

32+
enum Status : uint8_t {Synced = 0, Updating, Drawing, Damaged};
33+
3234
struct Canvas::Impl
3335
{
34-
enum Status : uint8_t {Synced = 0, Updating, Drawing};
35-
3636
list<Paint*> paints;
3737
RenderMethod* renderer;
3838
RenderRegion vport = {0, 0, INT32_MAX, INT32_MAX};
3939
Status status = Status::Synced;
4040

41-
bool refresh = false; //if all paints should be updated by force.
42-
4341
Impl(RenderMethod* pRenderer) : renderer(pRenderer)
4442
{
4543
renderer->ref();
@@ -90,33 +88,30 @@ struct Canvas::Impl
9088
return Result::Success;
9189
}
9290

93-
void needRefresh()
94-
{
95-
refresh = true;
96-
}
97-
9891
Result update(Paint* paint, bool force)
9992
{
10093
if (paints.empty() || status == Status::Drawing) return Result::InsufficientCondition;
10194

10295
Array<RenderData> clips;
10396
auto flag = RenderUpdateFlag::None;
104-
if (refresh || force) flag = RenderUpdateFlag::All;
97+
if (status == Status::Damaged || force) flag = RenderUpdateFlag::All;
98+
99+
auto m = Matrix{1, 0, 0, 0, 1, 0, 0, 0, 1};
105100

106101
if (paint) {
107-
paint->pImpl->update(renderer, nullptr, clips, 255, flag);
102+
paint->pImpl->update(renderer, m, clips, 255, flag);
108103
} else {
109104
for (auto paint : paints) {
110-
paint->pImpl->update(renderer, nullptr, clips, 255, flag);
105+
paint->pImpl->update(renderer, m, clips, 255, flag);
111106
}
112-
refresh = false;
113107
}
114108
status = Status::Updating;
115109
return Result::Success;
116110
}
117111

118112
Result draw()
119113
{
114+
if (status == Status::Damaged) update(nullptr, false);
120115
if (status == Status::Drawing || paints.empty() || !renderer->preRender()) return Result::InsufficientCondition;
121116

122117
bool rendered = false;
@@ -132,19 +127,20 @@ struct Canvas::Impl
132127

133128
Result sync()
134129
{
135-
if (status == Status::Synced) return Result::InsufficientCondition;
130+
if (status == Status::Synced || status == Status::Damaged) return Result::InsufficientCondition;
136131

137132
if (renderer->sync()) {
138133
status = Status::Synced;
139134
return Result::Success;
140135
}
141136

142-
return Result::InsufficientCondition;
137+
return Result::Unknown;
143138
}
144139

145140
Result viewport(int32_t x, int32_t y, int32_t w, int32_t h)
146141
{
147-
if (status != Status::Synced) return Result::InsufficientCondition;
142+
if (status != Status::Damaged && status != Status::Synced) return Result::InsufficientCondition;
143+
148144
RenderRegion val = {x, y, w, h};
149145
//intersect if the target buffer is already set.
150146
auto surface = renderer->mainSurface();
@@ -154,7 +150,7 @@ struct Canvas::Impl
154150
if (vport == val) return Result::Success;
155151
renderer->viewport(val);
156152
vport = val;
157-
needRefresh();
153+
status = Status::Damaged;
158154
return Result::Success;
159155
}
160156
};

0 commit comments

Comments
 (0)