summaryrefslogtreecommitdiffstats
path: root/thirdparty/thorvg/src/renderer/sw_engine/tvgSwShape.cpp
diff options
context:
space:
mode:
authorMartin Capitanio <capnm@capitanio.org>2024-01-26 10:04:27 +0100
committerMartin Capitanio <capnm@capitanio.org>2024-01-26 12:09:26 +0100
commit73589f6db604c9c93d3c5ab4cc2cd51f9628256f (patch)
treea2569d1553f7a97cd4067c96c7bf340a43129714 /thirdparty/thorvg/src/renderer/sw_engine/tvgSwShape.cpp
parent99ac3d332ac8aec3ef93b13e8aa9755da667efb0 (diff)
downloadredot-engine-73589f6db604c9c93d3c5ab4cc2cd51f9628256f.tar.gz
ThorVG: update from v0.12.1 to v0.12.3
https://github.com/thorvg/thorvg/releases/tag/v0.12.3 + Full Changelog: https://github.com/thorvg/thorvg/compare/v0.12.1...v0.12.3 Godot-related SVG bug fixes: + svg_loader: Add missing transform functions skewX and skewY. thorvg/thorvg#1928 + sw_engine: Rectified dash line drawing issue. thorvg/thorvg#1932
Diffstat (limited to 'thirdparty/thorvg/src/renderer/sw_engine/tvgSwShape.cpp')
-rw-r--r--thirdparty/thorvg/src/renderer/sw_engine/tvgSwShape.cpp45
1 files changed, 7 insertions, 38 deletions
diff --git a/thirdparty/thorvg/src/renderer/sw_engine/tvgSwShape.cpp b/thirdparty/thorvg/src/renderer/sw_engine/tvgSwShape.cpp
index e001ced2a8..45322c07b4 100644
--- a/thirdparty/thorvg/src/renderer/sw_engine/tvgSwShape.cpp
+++ b/thirdparty/thorvg/src/renderer/sw_engine/tvgSwShape.cpp
@@ -64,12 +64,16 @@ static void _outlineEnd(SwOutline& outline)
{
if (outline.pts.empty()) return;
outline.cntrs.push(outline.pts.count - 1);
+ outline.closed.push(false);
}
static void _outlineMoveTo(SwOutline& outline, const Point* to, const Matrix* transform)
{
- if (outline.pts.count > 0) outline.cntrs.push(outline.pts.count - 1);
+ if (outline.pts.count > 0) {
+ outline.cntrs.push(outline.pts.count - 1);
+ outline.closed.push(false);
+ }
outline.pts.push(mathTransform(to, transform));
outline.types.push(SW_CURVE_TYPE_POINT);
@@ -128,7 +132,7 @@ static void _dashLineTo(SwDashStroke& dash, const Point* to, const Matrix* trans
_outlineLineTo(*dash.outline, to, transform);
}
} else {
- while (len > dash.curLen) {
+ while (len - dash.curLen > 0.0001f) {
Line left, right;
if (dash.curLen > 0) {
len -= dash.curLen;
@@ -185,7 +189,7 @@ static void _dashCubicTo(SwDashStroke& dash, const Point* ctrl1, const Point* ct
_outlineCubicTo(*dash.outline, ctrl1, ctrl2, to, transform);
}
} else {
- while (len > dash.curLen) {
+ while ((len - dash.curLen) > 0.0001f) {
Bezier left, right;
if (dash.curLen > 0) {
len -= dash.curLen;
@@ -315,21 +319,6 @@ static SwOutline* _genDashOutline(const RenderShape* rshape, const Matrix* trans
dash.outline = mpoolReqDashOutline(mpool, tid);
- //smart reservation
- auto closeCnt = 0;
- auto moveCnt = 0;
-
- for (auto cmd = rshape->path.cmds.data; cmd < rshape->path.cmds.end(); ++cmd) {
- if (*cmd == PathCommand::Close) ++closeCnt;
- else if (*cmd == PathCommand::MoveTo) ++moveCnt;
- }
-
- //No idea exact count.... Reserve Approximitely 20x...
- //OPTIMIZE: we can directly copy the path points when the close is occupied with a point.
- dash.outline->pts.grow(20 * (closeCnt + ptsCnt + 1));
- dash.outline->types.grow(20 * (closeCnt + ptsCnt + 1));
- dash.outline->cntrs.grow(20 * (moveCnt + 1));
-
while (cmdCnt-- > 0) {
switch (*cmds) {
case PathCommand::Close: {
@@ -435,29 +424,9 @@ static bool _genOutline(SwShape* shape, const RenderShape* rshape, const Matrix*
//No actual shape data
if (cmdCnt == 0 || ptsCnt == 0) return false;
- //smart reservation
- auto moveCnt = 0;
- auto closeCnt = 0;
-
- for (auto cmd = rshape->path.cmds.data; cmd < rshape->path.cmds.end(); ++cmd) {
- if (*cmd == PathCommand::Close) ++closeCnt;
- else if (*cmd == PathCommand::MoveTo) ++moveCnt;
- }
-
shape->outline = mpoolReqOutline(mpool, tid);
auto outline = shape->outline;
- //OPTIMIZE: we can directly copy the path points when the close is occupied with a point.
- outline->pts.grow(ptsCnt + closeCnt + 1);
- outline->types.grow(ptsCnt + closeCnt + 1);
- outline->cntrs.grow(moveCnt + 1);
-
- //Dash outlines are always opened.
- //Only normal outlines use this information, it sholud be same to their contour counts.
- outline->closed.reserve(outline->cntrs.reserved);
-
- memset(outline->closed.data, 0x0, sizeof(bool) * outline->closed.reserved);
-
//Generate Outlines
while (cmdCnt-- > 0) {
switch (*cmds) {