From c503f688db3883df301b66d6e3bc5d24e0bd1626 Mon Sep 17 00:00:00 2001 From: Hermet Park Date: Sun, 31 Mar 2024 23:22:38 +0900 Subject: [PATCH] sw_engine: hotfix a regression bug of line drawing. fixed one more corner case problem, just observed. it's a side effect by 925009c4a526f0e9578e1213b752e4f270466928 --- src/renderer/sw_engine/tvgSwShape.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/renderer/sw_engine/tvgSwShape.cpp b/src/renderer/sw_engine/tvgSwShape.cpp index f239c88b..c5436fde 100644 --- a/src/renderer/sw_engine/tvgSwShape.cpp +++ b/src/renderer/sw_engine/tvgSwShape.cpp @@ -28,10 +28,19 @@ /* Internal Class Implementation */ /************************************************************************/ +static bool _outlineBegin(SwOutline& outline) +{ + //Make a contour if lineTo/curveTo without calling close or moveTo beforehand. + if (outline.pts.empty()) return false; + outline.cntrs.push(outline.pts.count - 1); + outline.pts.push(outline.pts[outline.cntrs.last()]); + outline.types.push(SW_CURVE_TYPE_POINT); + return false; +} + static bool _outlineEnd(SwOutline& outline) { - //Make a contour if lineTo/curveTo without calling close/moveTo beforehand. if (outline.pts.empty()) return false; outline.cntrs.push(outline.pts.count - 1); outline.closed.push(false); @@ -402,7 +411,7 @@ static bool _genOutline(SwShape* shape, const RenderShape* rshape, const Matrix* shape->outline = mpoolReqOutline(mpool, tid); auto outline = shape->outline; - bool closed = false; + auto closed = false; //Generate Outlines while (cmdCnt-- > 0) { @@ -417,13 +426,13 @@ static bool _genOutline(SwShape* shape, const RenderShape* rshape, const Matrix* break; } case PathCommand::LineTo: { - if (closed) closed = _outlineEnd(*outline); + if (closed) closed = _outlineBegin(*outline); _outlineLineTo(*outline, pts, transform); ++pts; break; } case PathCommand::CubicTo: { - if (closed) closed = _outlineEnd(*outline); + if (closed) closed = _outlineBegin(*outline); _outlineCubicTo(*outline, pts, pts + 1, pts + 2, transform); pts += 3; break;