| 1 |
From da379fdf722dc5df60caefed012952117a5ce4b4 Mon Sep 17 00:00:00 2001 |
| 2 |
From: Kaylee Lubick <[email protected]> |
| 3 |
Date: Tue, 16 Jun 2026 16:59:17 -0400 |
| 4 |
Subject: [PATCH] Handle w<=0 conics |
| 5 |
|
| 6 |
SkPath had special logic for degenerate conics [1] and SkGeometry |
| 7 |
has an assumption of positive weights [2][3] (possibly other places |
| 8 |
too), so this restores that logic to turn it into a lineTo. |
| 9 |
|
| 10 |
[1] https://github.com/google/skia/blob/19936eb1b23fef5187b07fb2e0e67dcf605c0672/src/core/SkPath.cpp#L754-L756 |
| 11 |
[2] https://github.com/google/skia/blob/d7196b0b493925df3be1e259f41a3c6678732b45/src/core/SkGeometry.h#L350 |
| 12 |
[3] https://review.skia.org/667436 |
| 13 |
[4] https://review.skia.org/1225597 |
| 14 |
|
| 15 |
Bug: https://issues.chromium.org/issues/520506316 |
| 16 |
Change-Id: I6946e755c5cacade8a487bc882ba0ce5e34531a1 |
| 17 |
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/1267718 |
| 18 |
Auto-Submit: Kaylee Lubick <[email protected]> |
| 19 |
Commit-Queue: Florin Malita <[email protected]> |
| 20 |
Reviewed-by: Florin Malita <[email protected]> |
| 21 |
--- |
| 22 |
include/core/SkPathBuilder.h | 4 ++- |
| 23 |
src/core/SkPathBuilder.cpp | 3 ++ |
| 24 |
tests/PathBuilderTest.cpp | 65 +++++++++++++++++++++++++++++++++++- |
| 25 |
3 files changed, 70 insertions(+), 2 deletions(-) |
| 26 |
|
| 27 |
diff --git a/include/core/SkPathBuilder.h b/include/core/SkPathBuilder.h |
| 28 |
index d4b1907a58..ad6882dab0 100644 |
| 29 |
--- a/include/core/SkPathBuilder.h |
| 30 |
+++ b/include/core/SkPathBuilder.h |
| 31 |
@@ -252,12 +252,14 @@ public: |
| 32 |
|
| 33 |
Appends kMove_Verb to verb array and (0, 0) to SkPoint array, if needed. |
| 34 |
|
| 35 |
- If w is finite and not one, appends kConic_Verb to verb array; |
| 36 |
+ If w is finite, positive, and not one, appends kConic_Verb to verb array; |
| 37 |
and pt1, pt2 to SkPoint array; and w to conic weights. |
| 38 |
|
| 39 |
If w is one, appends kQuad_Verb to verb array, and |
| 40 |
pt1, pt2 to SkPoint array. |
| 41 |
|
| 42 |
+ If w is zero, this is the same as lineTo(pt2) |
| 43 |
+ |
| 44 |
If w is not finite, appends kLine_Verb twice to verb array, and |
| 45 |
pt1, pt2 to SkPoint array. |
| 46 |
|
| 47 |
diff --git a/src/core/SkPathBuilder.cpp b/src/core/SkPathBuilder.cpp |
| 48 |
index 76d418a7be..833763d3fc 100644 |
| 49 |
--- a/src/core/SkPathBuilder.cpp |
| 50 |
+++ b/src/core/SkPathBuilder.cpp |
| 51 |
@@ -202,6 +202,9 @@ SkPathBuilder& SkPathBuilder::quadTo(SkPoint pt1, SkPoint pt2) { |
| 52 |
SkPathBuilder& SkPathBuilder::conicTo(SkPoint pt1, SkPoint pt2, SkScalar w) { |
| 53 |
this->ensureMove(); |
| 54 |
|
| 55 |
+ if (w <= 0) { |
| 56 |
+ return this->lineTo(pt2); |
| 57 |
+ } |
| 58 |
SkPoint* p = fPts.push_back_n(2); |
| 59 |
p[0] = pt1; |
| 60 |
p[1] = pt2; |
| 61 |
-- |
| 62 |
2.53.0 |
| 63 |
|