Skip to content

Commit 5675c76

Browse files
committed
Merge pull request #96658 from akien-mga/thorvg-0.14.9
thorvg: Update to 0.14.9
2 parents 90801df + a6ab039 commit 5675c76

15 files changed

+72
-138
lines changed

thirdparty/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -907,7 +907,7 @@ instead of `miniz.h` as an external dependency.
907907
## thorvg
908908

909909
- Upstream: https://github.com/thorvg/thorvg
910-
- Version: 0.14.7 (e3a6bf5229a9671c385ee78bc33e6e6b611a9729, 2024)
910+
- Version: 0.14.9 (81a0fbfd590873b21e53c3af77969c71d3d9b586, 2024)
911911
- License: MIT
912912

913913
Files extracted from upstream source:

thirdparty/thorvg/inc/config.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@
1515
// For internal debugging:
1616
//#define THORVG_LOG_ENABLED
1717

18-
#define THORVG_VERSION_STRING "0.14.8"
18+
#define THORVG_VERSION_STRING "0.14.9"
1919
#endif

thirdparty/thorvg/patches/pr2702-sw_engine-handle-small-cubics.patch

Lines changed: 0 additions & 96 deletions
This file was deleted.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
From 41d67213607e7ff20b7a3ca833f1cfde9780da65 Mon Sep 17 00:00:00 2001
2+
From: Hermet Park <[email protected]>
3+
Date: Sat, 7 Sep 2024 01:35:09 +0900
4+
Subject: [PATCH] renderer: ++reliability in text drawing
5+
6+
Allow the canvas to pass through
7+
even if text elements are not properly supported.
8+
9+
issue: https://github.com/thorvg/thorvg/issues/2715
10+
---
11+
src/renderer/tvgText.h | 1 +
12+
1 file changed, 1 insertion(+)
13+
14+
diff --git a/thirdparty/thorvg/src/renderer/tvgText.h b/thirdparty/thorvg/src/renderer/tvgText.h
15+
index 746b85bea6..55d33ffd4b 100644
16+
--- a/thirdparty/thorvg/src/renderer/tvgText.h
17+
+++ b/thirdparty/thorvg/src/renderer/tvgText.h
18+
@@ -89,6 +89,7 @@ struct Text::Impl
19+
20+
bool render(RenderMethod* renderer)
21+
{
22+
+ if (!loader) return true;
23+
renderer->blend(paint->blend(), true);
24+
return PP(shape)->render(renderer);
25+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
diff --git a/thirdparty/thorvg/src/common/tvgLines.cpp b/thirdparty/thorvg/src/common/tvgLines.cpp
2+
index 49d992f127..9d704900a5 100644
3+
--- a/thirdparty/thorvg/src/common/tvgLines.cpp
4+
+++ b/thirdparty/thorvg/src/common/tvgLines.cpp
5+
@@ -79,7 +79,7 @@ float _bezAt(const Bezier& bz, float at, float length, LengthFunc lineLengthFunc
6+
Bezier left;
7+
bezSplitLeft(right, t, left);
8+
length = _bezLength(left, lineLengthFunc);
9+
- if (fabsf(length - at) < BEZIER_EPSILON || fabsf(smallest - biggest) < 1e-3f) {
10+
+ if (fabsf(length - at) < BEZIER_EPSILON || fabsf(smallest - biggest) < BEZIER_EPSILON) {
11+
break;
12+
}
13+
if (length < at) {

thirdparty/thorvg/src/common/tvgLines.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ float _bezAt(const Bezier& bz, float at, float length, LengthFunc lineLengthFunc
7979
Bezier left;
8080
bezSplitLeft(right, t, left);
8181
length = _bezLength(left, lineLengthFunc);
82-
if (fabsf(length - at) < BEZIER_EPSILON || fabsf(smallest - biggest) < 1e-3f) {
82+
if (fabsf(length - at) < BEZIER_EPSILON || fabsf(smallest - biggest) < BEZIER_EPSILON) {
8383
break;
8484
}
8585
if (length < at) {

thirdparty/thorvg/src/common/tvgMath.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,8 @@ bool mathInverse(const Matrix* m, Matrix* out)
4343
m->e12 * (m->e21 * m->e33 - m->e23 * m->e31) +
4444
m->e13 * (m->e21 * m->e32 - m->e22 * m->e31);
4545

46-
if (mathZero(det)) return false;
47-
48-
auto invDet = 1 / det;
46+
auto invDet = 1.0f / det;
47+
if (std::isinf(invDet)) return false;
4948

5049
out->e11 = (m->e22 * m->e33 - m->e32 * m->e23) * invDet;
5150
out->e12 = (m->e13 * m->e32 - m->e12 * m->e33) * invDet;
@@ -137,7 +136,6 @@ Point operator*(const Point& pt, const Matrix& m)
137136
uint8_t mathLerp(const uint8_t &start, const uint8_t &end, float t)
138137
{
139138
auto result = static_cast<int>(start + (end - start) * t);
140-
if (result > 255) result = 255;
141-
else if (result < 0) result = 0;
139+
mathClamp(result, 0, 255);
142140
return static_cast<uint8_t>(result);
143141
}

thirdparty/thorvg/src/common/tvgMath.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
#define _USE_MATH_DEFINES
2727

2828
#include <float.h>
29-
#include <math.h>
29+
#include <cmath>
3030
#include "tvgCommon.h"
3131

3232
#define MATH_PI 3.14159265358979323846f
@@ -68,6 +68,13 @@ static inline bool mathEqual(float a, float b)
6868
}
6969

7070

71+
template <typename T>
72+
static inline void mathClamp(T& v, const T& min, const T& max)
73+
{
74+
if (v < min) v = min;
75+
else if (v > max) v = max;
76+
}
77+
7178
/************************************************************************/
7279
/* Matrix functions */
7380
/************************************************************************/

thirdparty/thorvg/src/loaders/svg/tvgSvgLoader.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3288,6 +3288,7 @@ static void _svgLoaderParserXmlClose(SvgLoaderData* loader, const char* content,
32883288
for (unsigned int i = 0; i < sizeof(graphicsTags) / sizeof(graphicsTags[0]); i++) {
32893289
if (!strncmp(tagName, graphicsTags[i].tag, sz)) {
32903290
loader->currentGraphicsNode = nullptr;
3291+
if (!strncmp(tagName, "text", 4)) loader->openedTag = OpenedTagType::Other;
32913292
loader->stack.pop();
32923293
break;
32933294
}
@@ -3361,11 +3362,9 @@ static void _svgLoaderParserXmlOpen(SvgLoaderData* loader, const char* content,
33613362
node = method(loader, parent, attrs, attrsLength, simpleXmlParseAttributes);
33623363
if (node && !empty) {
33633364
if (!strcmp(tagName, "text")) loader->openedTag = OpenedTagType::Text;
3364-
else {
3365-
auto defs = _createDefsNode(loader, nullptr, nullptr, 0, nullptr);
3366-
loader->stack.push(defs);
3367-
loader->currentGraphicsNode = node;
3368-
}
3365+
auto defs = _createDefsNode(loader, nullptr, nullptr, 0, nullptr);
3366+
loader->stack.push(defs);
3367+
loader->currentGraphicsNode = node;
33693368
}
33703369
} else if ((gradientMethod = _findGradientFactory(tagName))) {
33713370
SvgStyleGradient* gradient;
@@ -3403,7 +3402,6 @@ static void _svgLoaderParserText(SvgLoaderData* loader, const char* content, uns
34033402
auto text = &loader->svgParse->node->node.text;
34043403
if (text->text) free(text->text);
34053404
text->text = strDuplicate(content, length);
3406-
loader->openedTag = OpenedTagType::Other;
34073405
}
34083406

34093407

thirdparty/thorvg/src/renderer/sw_engine/tvgSwCommon.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -495,8 +495,7 @@ SwFixed mathSin(SwFixed angle);
495495
void mathSplitCubic(SwPoint* base);
496496
SwFixed mathDiff(SwFixed angle1, SwFixed angle2);
497497
SwFixed mathLength(const SwPoint& pt);
498-
bool mathSmallCubic(const SwPoint* base);
499-
bool mathFlatCubic(const SwPoint* base, SwFixed& angleIn, SwFixed& angleMid, SwFixed& angleOut);
498+
bool mathSmallCubic(const SwPoint* base, SwFixed& angleIn, SwFixed& angleMid, SwFixed& angleOut);
500499
SwFixed mathMean(SwFixed angle1, SwFixed angle2);
501500
SwPoint mathTransform(const Point* to, const Matrix& transform);
502501
bool mathUpdateOutlineBBox(const SwOutline* outline, const SwBBox& clipRegion, SwBBox& renderRegion, bool fastTrack);

0 commit comments

Comments
 (0)