sw_engine: hotfix a regression bug of line drawing.

fixed one more corner case problem, just observed.
it's a side effect by 925009c4a5
This commit is contained in:
Hermet Park 2024-03-31 23:22:38 +09:00 committed by Hermet Park
parent e8e9ba5ea0
commit c503f688db

View file

@ -28,10 +28,19 @@
/* Internal Class Implementation */ /* 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) static bool _outlineEnd(SwOutline& outline)
{ {
//Make a contour if lineTo/curveTo without calling close/moveTo beforehand.
if (outline.pts.empty()) return false; if (outline.pts.empty()) return false;
outline.cntrs.push(outline.pts.count - 1); outline.cntrs.push(outline.pts.count - 1);
outline.closed.push(false); outline.closed.push(false);
@ -402,7 +411,7 @@ static bool _genOutline(SwShape* shape, const RenderShape* rshape, const Matrix*
shape->outline = mpoolReqOutline(mpool, tid); shape->outline = mpoolReqOutline(mpool, tid);
auto outline = shape->outline; auto outline = shape->outline;
bool closed = false; auto closed = false;
//Generate Outlines //Generate Outlines
while (cmdCnt-- > 0) { while (cmdCnt-- > 0) {
@ -417,13 +426,13 @@ static bool _genOutline(SwShape* shape, const RenderShape* rshape, const Matrix*
break; break;
} }
case PathCommand::LineTo: { case PathCommand::LineTo: {
if (closed) closed = _outlineEnd(*outline); if (closed) closed = _outlineBegin(*outline);
_outlineLineTo(*outline, pts, transform); _outlineLineTo(*outline, pts, transform);
++pts; ++pts;
break; break;
} }
case PathCommand::CubicTo: { case PathCommand::CubicTo: {
if (closed) closed = _outlineEnd(*outline); if (closed) closed = _outlineBegin(*outline);
_outlineCubicTo(*outline, pts, pts + 1, pts + 2, transform); _outlineCubicTo(*outline, pts, pts + 1, pts + 2, transform);
pts += 3; pts += 3;
break; break;