From da379fdf722dc5df60caefed012952117a5ce4b4 Mon Sep 17 00:00:00 2001 From: Kaylee Lubick Date: Tue, 16 Jun 2026 16:59:17 -0400 Subject: [PATCH] Handle w<=0 conics SkPath had special logic for degenerate conics [1] and SkGeometry has an assumption of positive weights [2][3] (possibly other places too), so this restores that logic to turn it into a lineTo. [1] https://github.com/google/skia/blob/19936eb1b23fef5187b07fb2e0e67dcf605c0672/src/core/SkPath.cpp#L754-L756 [2] https://github.com/google/skia/blob/d7196b0b493925df3be1e259f41a3c6678732b45/src/core/SkGeometry.h#L350 [3] https://review.skia.org/667436 [4] https://review.skia.org/1225597 Bug: https://issues.chromium.org/issues/520506316 Change-Id: I6946e755c5cacade8a487bc882ba0ce5e34531a1 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/1267718 Auto-Submit: Kaylee Lubick Commit-Queue: Florin Malita Reviewed-by: Florin Malita --- include/core/SkPathBuilder.h | 4 ++- src/core/SkPathBuilder.cpp | 3 ++ tests/PathBuilderTest.cpp | 65 +++++++++++++++++++++++++++++++++++- 3 files changed, 70 insertions(+), 2 deletions(-) diff --git a/include/core/SkPathBuilder.h b/include/core/SkPathBuilder.h index d4b1907a58..ad6882dab0 100644 --- a/include/core/SkPathBuilder.h +++ b/include/core/SkPathBuilder.h @@ -252,12 +252,14 @@ public: Appends kMove_Verb to verb array and (0, 0) to SkPoint array, if needed. - If w is finite and not one, appends kConic_Verb to verb array; + If w is finite, positive, and not one, appends kConic_Verb to verb array; and pt1, pt2 to SkPoint array; and w to conic weights. If w is one, appends kQuad_Verb to verb array, and pt1, pt2 to SkPoint array. + If w is zero, this is the same as lineTo(pt2) + If w is not finite, appends kLine_Verb twice to verb array, and pt1, pt2 to SkPoint array. diff --git a/src/core/SkPathBuilder.cpp b/src/core/SkPathBuilder.cpp index 76d418a7be..833763d3fc 100644 --- a/src/core/SkPathBuilder.cpp +++ b/src/core/SkPathBuilder.cpp @@ -202,6 +202,9 @@ SkPathBuilder& SkPathBuilder::quadTo(SkPoint pt1, SkPoint pt2) { SkPathBuilder& SkPathBuilder::conicTo(SkPoint pt1, SkPoint pt2, SkScalar w) { this->ensureMove(); + if (w <= 0) { + return this->lineTo(pt2); + } SkPoint* p = fPts.push_back_n(2); p[0] = pt1; p[1] = pt2; -- 2.53.0