diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2024-09-06 18:07:30 +0200 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2024-09-06 22:08:02 +0200 |
commit | a6ab039f2b9e2d524b45186586cc880134fbee98 (patch) | |
tree | 9cd88fdfa8ca80f878f73e86865259ea9f4f4212 /thirdparty/thorvg/src/common | |
parent | 05d985496c73577fb0b44291345da5f2dbe09844 (diff) | |
download | redot-engine-a6ab039f2b9e2d524b45186586cc880134fbee98.tar.gz |
thorvg: Update to 0.14.9
Fixes #96491.
Update fix for #96262 to a simple revert of the problematic commit,
as the upstream fix is still being debated and caused other issues.
Also include fix for upstream regression 2715 added in 0.14.9.
Diffstat (limited to 'thirdparty/thorvg/src/common')
-rw-r--r-- | thirdparty/thorvg/src/common/tvgLines.cpp | 2 | ||||
-rw-r--r-- | thirdparty/thorvg/src/common/tvgMath.cpp | 8 | ||||
-rw-r--r-- | thirdparty/thorvg/src/common/tvgMath.h | 9 |
3 files changed, 12 insertions, 7 deletions
diff --git a/thirdparty/thorvg/src/common/tvgLines.cpp b/thirdparty/thorvg/src/common/tvgLines.cpp index 49d992f127..9d704900a5 100644 --- a/thirdparty/thorvg/src/common/tvgLines.cpp +++ b/thirdparty/thorvg/src/common/tvgLines.cpp @@ -79,7 +79,7 @@ float _bezAt(const Bezier& bz, float at, float length, LengthFunc lineLengthFunc Bezier left; bezSplitLeft(right, t, left); length = _bezLength(left, lineLengthFunc); - if (fabsf(length - at) < BEZIER_EPSILON || fabsf(smallest - biggest) < 1e-3f) { + if (fabsf(length - at) < BEZIER_EPSILON || fabsf(smallest - biggest) < BEZIER_EPSILON) { break; } if (length < at) { diff --git a/thirdparty/thorvg/src/common/tvgMath.cpp b/thirdparty/thorvg/src/common/tvgMath.cpp index 0254cce9b8..c03b54e5f8 100644 --- a/thirdparty/thorvg/src/common/tvgMath.cpp +++ b/thirdparty/thorvg/src/common/tvgMath.cpp @@ -43,9 +43,8 @@ bool mathInverse(const Matrix* m, Matrix* out) m->e12 * (m->e21 * m->e33 - m->e23 * m->e31) + m->e13 * (m->e21 * m->e32 - m->e22 * m->e31); - if (mathZero(det)) return false; - - auto invDet = 1 / det; + auto invDet = 1.0f / det; + if (std::isinf(invDet)) return false; out->e11 = (m->e22 * m->e33 - m->e32 * m->e23) * invDet; out->e12 = (m->e13 * m->e32 - m->e12 * m->e33) * invDet; @@ -137,7 +136,6 @@ Point operator*(const Point& pt, const Matrix& m) uint8_t mathLerp(const uint8_t &start, const uint8_t &end, float t) { auto result = static_cast<int>(start + (end - start) * t); - if (result > 255) result = 255; - else if (result < 0) result = 0; + mathClamp(result, 0, 255); return static_cast<uint8_t>(result); } diff --git a/thirdparty/thorvg/src/common/tvgMath.h b/thirdparty/thorvg/src/common/tvgMath.h index df39e3b9af..50786754a1 100644 --- a/thirdparty/thorvg/src/common/tvgMath.h +++ b/thirdparty/thorvg/src/common/tvgMath.h @@ -26,7 +26,7 @@ #define _USE_MATH_DEFINES #include <float.h> -#include <math.h> +#include <cmath> #include "tvgCommon.h" #define MATH_PI 3.14159265358979323846f @@ -68,6 +68,13 @@ static inline bool mathEqual(float a, float b) } +template <typename T> +static inline void mathClamp(T& v, const T& min, const T& max) +{ + if (v < min) v = min; + else if (v > max) v = max; +} + /************************************************************************/ /* Matrix functions */ /************************************************************************/ |