Reverts "Update all uses of mutable SkPath methods to use SkPathBuilder (#177738)" (#178125)
<!-- start_original_pr_link -->
Reverts: flutter/flutter#177738
<!-- end_original_pr_link -->
<!-- start_initiating_author -->
Initiated by: chingjun
<!-- end_initiating_author -->
<!-- start_revert_reason -->
Reason for reverting: Broke internal tests. Some shapes are not drawn.
<!-- end_revert_reason -->
<!-- start_original_pr_author -->
Original PR Author: kjlubick
<!-- end_original_pr_author -->
<!-- start_reviewers -->
Reviewed By: {jason-simmons}
<!-- end_reviewers -->
<!-- start_revert_body -->
This change reverts the following previous change:
Skia is removing the APIs that allow changing an SkPath. This updates
those callsites to use SkPathBuilder where appropriate.
## Pre-launch Checklist
- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [ ] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [ ] All existing and new tests are passing.
If you need help, consider asking for advice on the #hackers-new channel
on [Discord].
**Note**: The Flutter team is currently trialing the use of [Gemini Code
Assist for
GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code).
Comments from the `gemini-code-assist` bot should not be taken as
authoritative feedback from the Flutter team. If you find its comments
useful you can update your code accordingly, but if you are unsure or
disagree with the feedback, please feel free to wait for a Flutter team
member's review for guidance on which automated comments should be
addressed.
<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview
[Tree Hygiene]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
[test-exempt]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md
[Features we expect every widget to implement]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes
[Discord]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md
[Data Driven Fixes]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
<!-- end_revert_body -->
Co-authored-by: auto-submit[bot] <flutter-engprod-team@google.com>diff --git a/engine/src/flutter/display_list/geometry/dl_path.cc b/engine/src/flutter/display_list/geometry/dl_path.cc
index b6b3fbe..1ce4a0d 100644
--- a/engine/src/flutter/display_list/geometry/dl_path.cc
+++ b/engine/src/flutter/display_list/geometry/dl_path.cc
@@ -44,14 +44,14 @@
DlScalar top,
DlScalar right,
DlScalar bottom) {
- return DlPath(SkPath::Rect(SkRect::MakeLTRB(left, top, right, bottom)));
+ return DlPath(SkPath().addRect(left, top, right, bottom));
}
DlPath DlPath::MakeRectXYWH(DlScalar x,
DlScalar y,
DlScalar width,
DlScalar height) {
- return DlPath(SkPath::Rect(SkRect::MakeXYWH(x, y, width, height)));
+ return DlPath(SkPath().addRect(SkRect::MakeXYWH(x, y, width, height)));
}
DlPath DlPath::MakeOval(const DlRect& bounds) {
@@ -102,7 +102,7 @@
DlDegrees start,
DlDegrees sweep,
bool use_center) {
- SkPathBuilder path;
+ SkPath path;
if (use_center) {
path.moveTo(ToSkPoint(bounds.GetCenter()));
}
@@ -110,7 +110,7 @@
if (use_center) {
path.close();
}
- return DlPath(path.detach());
+ return DlPath(path);
}
const SkPath& DlPath::GetSkPath() const {
@@ -188,7 +188,9 @@
if (!offset.IsFinite()) {
return DlPath();
}
- return DlPath(data_->sk_path.makeOffset(offset.x, offset.y));
+ SkPath path = data_->sk_path;
+ path = path.offset(offset.x, offset.y);
+ return DlPath(path);
}
[[nodiscard]] DlPath DlPath::WithFillType(DlPathFillType type) const {
@@ -257,9 +259,9 @@
}
DlPath DlPath::operator+(const DlPath& other) const {
- SkPathBuilder path = SkPathBuilder(GetSkPath());
+ SkPath path = GetSkPath();
path.addPath(other.GetSkPath());
- return DlPath(path.detach());
+ return DlPath(path);
}
void DlPath::ReduceConic(DlPathReceiver& receiver,
diff --git a/engine/src/flutter/display_list/geometry/dl_path_builder.cc b/engine/src/flutter/display_list/geometry/dl_path_builder.cc
index 8f65ed1..7f78c7d 100644
--- a/engine/src/flutter/display_list/geometry/dl_path_builder.cc
+++ b/engine/src/flutter/display_list/geometry/dl_path_builder.cc
@@ -57,38 +57,31 @@
}
DlPathBuilder& DlPathBuilder::MoveTo(DlPoint p2) {
- path_.moveTo({p2.x, p2.y});
+ path_.moveTo(p2.x, p2.y);
return *this;
}
DlPathBuilder& DlPathBuilder::LineTo(DlPoint p2) {
- path_.lineTo({p2.x, p2.y});
+ path_.lineTo(p2.x, p2.y);
return *this;
}
DlPathBuilder& DlPathBuilder::QuadraticCurveTo(DlPoint cp, DlPoint p2) {
- path_.quadTo({cp.x, cp.y}, {p2.x, p2.y});
+ path_.quadTo(cp.x, cp.y, p2.x, p2.y);
return *this;
}
DlPathBuilder& DlPathBuilder::ConicCurveTo(DlPoint cp,
DlPoint p2,
DlScalar weight) {
- // Skia's SkPath object used to do these checks, but SkPathBuilder does not.
- if (!(weight > 0)) {
- return this->LineTo(p2);
- } else if (!std::isfinite(weight)) {
- this->LineTo(cp);
- return this->LineTo(p2);
- }
- path_.conicTo({cp.x, cp.y}, {p2.x, p2.y}, weight);
+ path_.conicTo(cp.x, cp.y, p2.x, p2.y, weight);
return *this;
}
DlPathBuilder& DlPathBuilder::CubicCurveTo(DlPoint cp1,
DlPoint cp2,
DlPoint p2) {
- path_.cubicTo({cp1.x, cp1.y}, {cp2.x, cp2.y}, {p2.x, p2.y});
+ path_.cubicTo(cp1.x, cp1.y, cp2.x, cp2.y, p2.x, p2.y);
return *this;
}
@@ -146,11 +139,13 @@
}
const DlPath DlPathBuilder::CopyPath() {
- return DlPath(path_.snapshot());
+ return DlPath(path_);
}
const DlPath DlPathBuilder::TakePath() {
- return DlPath(path_.detach());
+ DlPath path = DlPath(path_);
+ path_.reset();
+ return path;
}
} // namespace flutter
diff --git a/engine/src/flutter/display_list/geometry/dl_path_builder.h b/engine/src/flutter/display_list/geometry/dl_path_builder.h
index e150698..9a07616 100644
--- a/engine/src/flutter/display_list/geometry/dl_path_builder.h
+++ b/engine/src/flutter/display_list/geometry/dl_path_builder.h
@@ -7,7 +7,7 @@
#include "flutter/display_list/geometry/dl_geometry_types.h"
#include "flutter/display_list/geometry/dl_path.h"
-#include "flutter/third_party/skia/include/core/SkPathBuilder.h"
+#include "flutter/third_party/skia/include/core/SkPath.h"
namespace flutter {
@@ -132,7 +132,7 @@
const DlPath TakePath();
private:
- SkPathBuilder path_;
+ SkPath path_;
};
} // namespace flutter
diff --git a/engine/src/flutter/display_list/geometry/dl_path_unittests.cc b/engine/src/flutter/display_list/geometry/dl_path_unittests.cc
index 38b6b7c..7be51c1 100644
--- a/engine/src/flutter/display_list/geometry/dl_path_unittests.cc
+++ b/engine/src/flutter/display_list/geometry/dl_path_unittests.cc
@@ -9,7 +9,6 @@
#include "flutter/display_list/geometry/dl_path_builder.h"
#include "flutter/display_list/testing/dl_test_mock_path_receiver.h"
#include "flutter/third_party/skia/include/core/SkPath.h"
-#include "flutter/third_party/skia/include/core/SkPoint.h"
#include "flutter/third_party/skia/include/core/SkRRect.h"
namespace flutter {
@@ -393,18 +392,14 @@
}
TEST(DisplayListPath, ConstructFromPath) {
- SkPathBuilder pb1;
- pb1.moveTo({10, 10});
- pb1.lineTo({20, 20});
- pb1.lineTo({20, 10});
- SkPathBuilder pb2;
- pb2.moveTo({10, 10});
- pb2.lineTo({20, 20});
- pb2.lineTo({20, 10});
-
- SkPath sk_path1 = pb1.detach();
- SkPath sk_path2 = pb2.detach();
-
+ SkPath sk_path1;
+ sk_path1.moveTo(10, 10);
+ sk_path1.lineTo(20, 20);
+ sk_path1.lineTo(20, 10);
+ SkPath sk_path2;
+ sk_path2.moveTo(10, 10);
+ sk_path2.lineTo(20, 20);
+ sk_path2.lineTo(20, 10);
DlPath path(sk_path1);
ASSERT_EQ(sk_path1, sk_path2);
@@ -433,21 +428,22 @@
path_builder.LineTo({0, 100});
path_builder.Close();
- SkPathBuilder sk_path(SkPathFillType::kWinding);
- sk_path.moveTo({0, 0});
- sk_path.lineTo({100, 0});
- sk_path.lineTo({0, 100});
+ SkPath sk_path;
+ sk_path.setFillType(SkPathFillType::kWinding);
+ sk_path.moveTo(0, 0);
+ sk_path.lineTo(100, 0);
+ sk_path.lineTo(0, 100);
sk_path.close();
- EXPECT_EQ(path_builder.TakePath(), DlPath(sk_path.detach()));
+ EXPECT_EQ(path_builder.TakePath(), DlPath(sk_path));
}
TEST(DisplayListPath, IsLineFromSkPath) {
- SkPathBuilder sk_path;
- sk_path.moveTo({0, 0});
- sk_path.lineTo({100, 100});
+ SkPath sk_path;
+ sk_path.moveTo(SkPoint::Make(0, 0));
+ sk_path.lineTo(SkPoint::Make(100, 100));
- DlPath path = DlPath(sk_path.detach());
+ DlPath path = DlPath(sk_path);
DlPoint start;
DlPoint end;
@@ -511,16 +507,16 @@
}
TEST(DisplayListPath, DispatchSkiaPathOneOfEachVerb) {
- SkPathBuilder path;
+ SkPath path;
- path.moveTo({100, 200});
- path.lineTo({101, 201});
- path.quadTo({110, 202}, {102, 210});
- path.conicTo({150, 240}, {250, 140}, 0.5);
- path.cubicTo({300, 300}, {350, 300}, {300, 350});
+ path.moveTo(100, 200);
+ path.lineTo(101, 201);
+ path.quadTo(110, 202, 102, 210);
+ path.conicTo(150, 240, 250, 140, 0.5);
+ path.cubicTo(300, 300, 350, 300, 300, 350);
path.close();
- TestPathDispatchOneOfEachVerb(DlPath(path.detach()));
+ TestPathDispatchOneOfEachVerb(DlPath(path));
}
TEST(DisplayListPath, DispatchImpellerPathOneOfEachVerb) {
@@ -562,11 +558,11 @@
static void TestSkiaPathDispatchConicToQuads(
DlScalar weight,
const std::array<DlPoint, 4>& quad_points) {
- SkPathBuilder sk_path;
- sk_path.moveTo({10, 10});
- sk_path.conicTo({20, 10}, {20, 20}, weight);
+ SkPath sk_path;
+ sk_path.moveTo(10, 10);
+ sk_path.conicTo(20, 10, 20, 20, weight);
- TestPathDispatchConicToQuads(DlPath(sk_path.detach()), weight, quad_points);
+ TestPathDispatchConicToQuads(DlPath(sk_path), weight, quad_points);
}
static void TestImpellerPathDispatchConicToQuads(
@@ -666,12 +662,12 @@
}
TEST(DisplayListPath, DispatchUnclosedSkiaTriangle) {
- SkPathBuilder sk_path;
- sk_path.moveTo({10, 10});
- sk_path.lineTo({20, 10});
- sk_path.lineTo({10, 20});
+ SkPath sk_path;
+ sk_path.moveTo(10, 10);
+ sk_path.lineTo(20, 10);
+ sk_path.lineTo(10, 20);
- TestPathDispatchUnclosedTriangle(DlPath(sk_path.detach()));
+ TestPathDispatchUnclosedTriangle(DlPath(sk_path));
}
TEST(DisplayListPath, DispatchUnclosedImpellerTriangle) {
@@ -700,13 +696,13 @@
}
TEST(DisplayListPath, DispatchClosedSkiaTriangle) {
- SkPathBuilder sk_path;
- sk_path.moveTo({10, 10});
- sk_path.lineTo({20, 10});
- sk_path.lineTo({10, 20});
+ SkPath sk_path;
+ sk_path.moveTo(10, 10);
+ sk_path.lineTo(20, 10);
+ sk_path.lineTo(10, 20);
sk_path.close();
- TestPathDispatchClosedTriangle(DlPath(sk_path.detach()));
+ TestPathDispatchClosedTriangle(DlPath(sk_path));
}
TEST(DisplayListPath, DispatchClosedPathBuilderTriangle) {
@@ -742,19 +738,19 @@
}
TEST(DisplayListPath, DispatchMixedCloseSkiaPath) {
- SkPathBuilder sk_path;
- sk_path.moveTo({10, 10});
- sk_path.lineTo({20, 10});
- sk_path.lineTo({10, 20});
- sk_path.moveTo({110, 10});
- sk_path.lineTo({120, 10});
- sk_path.lineTo({110, 20});
+ SkPath sk_path;
+ sk_path.moveTo(10, 10);
+ sk_path.lineTo(20, 10);
+ sk_path.lineTo(10, 20);
+ sk_path.moveTo(110, 10);
+ sk_path.lineTo(120, 10);
+ sk_path.lineTo(110, 20);
sk_path.close();
- sk_path.moveTo({210, 10});
- sk_path.lineTo({220, 10});
- sk_path.lineTo({210, 20});
+ sk_path.moveTo(210, 10);
+ sk_path.lineTo(220, 10);
+ sk_path.lineTo(210, 20);
- TestPathDispatchMixedCloseTriangles(DlPath(sk_path.detach()));
+ TestPathDispatchMixedCloseTriangles(DlPath(sk_path));
}
TEST(DisplayListPath, DispatchMixedCloseImpellerPath) {
@@ -793,15 +789,15 @@
}
TEST(DisplayListPath, DispatchImplicitMoveAfterCloseSkiaPath) {
- SkPathBuilder sk_path;
- sk_path.moveTo({10, 10});
- sk_path.lineTo({20, 10});
- sk_path.lineTo({10, 20});
+ SkPath sk_path;
+ sk_path.moveTo(10, 10);
+ sk_path.lineTo(20, 10);
+ sk_path.lineTo(10, 20);
sk_path.close();
- sk_path.lineTo({-20, 10});
- sk_path.lineTo({10, -20});
+ sk_path.lineTo(-20, 10);
+ sk_path.lineTo(10, -20);
- TestPathDispatchImplicitMoveAfterClose(DlPath(sk_path.detach()));
+ TestPathDispatchImplicitMoveAfterClose(DlPath(sk_path));
}
TEST(DisplayListPath, DispatchImplicitMoveAfterClosePathBuilder) {
@@ -821,25 +817,25 @@
// supported by either Flutter public APIs or Impeller
TEST(DisplayListPath, CannotConstructFromSkiaInverseWinding) {
- SkPathBuilder sk_path(SkPathFillType::kInverseWinding);
- sk_path.moveTo({0, 0});
- sk_path.lineTo({100, 0});
- sk_path.lineTo({0, 100});
+ SkPath sk_path;
+ sk_path.setFillType(SkPathFillType::kInverseWinding);
+ sk_path.moveTo(0, 0);
+ sk_path.lineTo(100, 0);
+ sk_path.lineTo(0, 100);
sk_path.close();
- EXPECT_DEATH_IF_SUPPORTED(new DlPath(sk_path.detach()),
- "SkPathFillType_IsInverse");
+ EXPECT_DEATH_IF_SUPPORTED(new DlPath(sk_path), "SkPathFillType_IsInverse");
}
TEST(DisplayListPath, CannotConstructFromSkiaInverseEvenOdd) {
- SkPathBuilder sk_path(SkPathFillType::kInverseEvenOdd);
- sk_path.moveTo({0, 0});
- sk_path.lineTo({100, 0});
- sk_path.lineTo({0, 100});
+ SkPath sk_path;
+ sk_path.setFillType(SkPathFillType::kInverseEvenOdd);
+ sk_path.moveTo(0, 0);
+ sk_path.lineTo(100, 0);
+ sk_path.lineTo(0, 100);
sk_path.close();
- EXPECT_DEATH_IF_SUPPORTED(new DlPath(sk_path.detach()),
- "SkPathFillType_IsInverse");
+ EXPECT_DEATH_IF_SUPPORTED(new DlPath(sk_path), "SkPathFillType_IsInverse");
}
#endif
diff --git a/engine/src/flutter/impeller/toolkit/interop/path.cc b/engine/src/flutter/impeller/toolkit/interop/path.cc
index f85f732..d7f09c0 100644
--- a/engine/src/flutter/impeller/toolkit/interop/path.cc
+++ b/engine/src/flutter/impeller/toolkit/interop/path.cc
@@ -4,20 +4,18 @@
#include "impeller/toolkit/interop/path.h"
-#include "third_party/skia/include/core/SkRect.h"
-
namespace impeller::interop {
-Path::Path(const SkPath& path) : path_(SkPathBuilder(path)) {}
+Path::Path(const SkPath& path) : path_(path) {}
Path::~Path() = default;
-SkPath Path::GetPath() const {
- return path_.snapshot();
+const SkPath& Path::GetPath() const {
+ return path_;
}
ImpellerRect Path::GetBounds() const {
- const auto bounds = path_.computeFiniteBounds().value_or(SkRect());
+ const auto bounds = path_.getBounds();
return ImpellerRect{
.x = bounds.x(),
.y = bounds.y(),
diff --git a/engine/src/flutter/impeller/toolkit/interop/path.h b/engine/src/flutter/impeller/toolkit/interop/path.h
index c1c0481..bd68d9e 100644
--- a/engine/src/flutter/impeller/toolkit/interop/path.h
+++ b/engine/src/flutter/impeller/toolkit/interop/path.h
@@ -6,7 +6,6 @@
#define FLUTTER_IMPELLER_TOOLKIT_INTEROP_PATH_H_
#include "flutter/third_party/skia/include/core/SkPath.h"
-#include "flutter/third_party/skia/include/core/SkPathBuilder.h"
#include "impeller/toolkit/interop/impeller.h"
#include "impeller/toolkit/interop/object.h"
@@ -23,12 +22,12 @@
Path& operator=(const Path&) = delete;
- SkPath GetPath() const;
+ const SkPath& GetPath() const;
ImpellerRect GetBounds() const;
private:
- SkPathBuilder path_;
+ SkPath path_;
};
} // namespace impeller::interop
diff --git a/engine/src/flutter/impeller/toolkit/interop/path_builder.cc b/engine/src/flutter/impeller/toolkit/interop/path_builder.cc
index 08fc057..978b271 100644
--- a/engine/src/flutter/impeller/toolkit/interop/path_builder.cc
+++ b/engine/src/flutter/impeller/toolkit/interop/path_builder.cc
@@ -61,12 +61,12 @@
ScopedObject<Path> PathBuilder::TakePath(FillType fill) {
builder_.setFillType(ToSkiaType(fill));
- return Create<Path>(builder_.detach());
+ return Create<Path>(std::move(builder_));
}
ScopedObject<Path> PathBuilder::CopyPath(FillType fill) {
builder_.setFillType(ToSkiaType(fill));
- return Create<Path>(builder_.snapshot());
+ return Create<Path>(builder_);
}
} // namespace impeller::interop
diff --git a/engine/src/flutter/impeller/toolkit/interop/path_builder.h b/engine/src/flutter/impeller/toolkit/interop/path_builder.h
index 762d492..e491927 100644
--- a/engine/src/flutter/impeller/toolkit/interop/path_builder.h
+++ b/engine/src/flutter/impeller/toolkit/interop/path_builder.h
@@ -5,7 +5,7 @@
#ifndef FLUTTER_IMPELLER_TOOLKIT_INTEROP_PATH_BUILDER_H_
#define FLUTTER_IMPELLER_TOOLKIT_INTEROP_PATH_BUILDER_H_
-#include "flutter/third_party/skia/include/core/SkPathBuilder.h"
+#include "flutter/third_party/skia/include/core/SkPath.h"
#include "impeller/geometry/path_source.h"
#include "impeller/geometry/point.h"
#include "impeller/geometry/rect.h"
@@ -53,7 +53,7 @@
ScopedObject<Path> CopyPath(FillType fill);
private:
- SkPathBuilder builder_;
+ SkPath builder_;
};
} // namespace impeller::interop
diff --git a/engine/src/flutter/lib/ui/painting/path.cc b/engine/src/flutter/lib/ui/painting/path.cc
index 7adfaa0..5357cf0 100644
--- a/engine/src/flutter/lib/ui/painting/path.cc
+++ b/engine/src/flutter/lib/ui/painting/path.cc
@@ -37,7 +37,7 @@
}
int CanvasPath::getFillType() {
- return static_cast<int>(sk_path_.fillType());
+ return static_cast<int>(sk_path_.getFillType());
}
void CanvasPath::setFillType(int fill_type) {
@@ -51,23 +51,23 @@
}
void CanvasPath::relativeMoveTo(double x, double y) {
- sk_path_.rMoveTo({SafeNarrow(x), SafeNarrow(y)});
+ sk_path_.rMoveTo(SafeNarrow(x), SafeNarrow(y));
resetVolatility();
}
void CanvasPath::lineTo(double x, double y) {
- sk_path_.lineTo({SafeNarrow(x), SafeNarrow(y)});
+ sk_path_.lineTo(SafeNarrow(x), SafeNarrow(y));
resetVolatility();
}
void CanvasPath::relativeLineTo(double x, double y) {
- sk_path_.rLineTo({SafeNarrow(x), SafeNarrow(y)});
+ sk_path_.rLineTo(SafeNarrow(x), SafeNarrow(y));
resetVolatility();
}
void CanvasPath::quadraticBezierTo(double x1, double y1, double x2, double y2) {
- sk_path_.quadTo({SafeNarrow(x1), SafeNarrow(y1)},
- {SafeNarrow(x2), SafeNarrow(y2)});
+ sk_path_.quadTo(SafeNarrow(x1), SafeNarrow(y1), SafeNarrow(x2),
+ SafeNarrow(y2));
resetVolatility();
}
@@ -75,8 +75,8 @@
double y1,
double x2,
double y2) {
- sk_path_.rQuadTo({SafeNarrow(x1), SafeNarrow(y1)},
- {SafeNarrow(x2), SafeNarrow(y2)});
+ sk_path_.rQuadTo(SafeNarrow(x1), SafeNarrow(y1), SafeNarrow(x2),
+ SafeNarrow(y2));
resetVolatility();
}
@@ -86,9 +86,8 @@
double y2,
double x3,
double y3) {
- sk_path_.cubicTo({SafeNarrow(x1), SafeNarrow(y1)},
- {SafeNarrow(x2), SafeNarrow(y2)},
- {SafeNarrow(x3), SafeNarrow(y3)});
+ sk_path_.cubicTo(SafeNarrow(x1), SafeNarrow(y1), SafeNarrow(x2),
+ SafeNarrow(y2), SafeNarrow(x3), SafeNarrow(y3));
resetVolatility();
}
@@ -98,15 +97,14 @@
double y2,
double x3,
double y3) {
- sk_path_.rCubicTo({SafeNarrow(x1), SafeNarrow(y1)},
- {SafeNarrow(x2), SafeNarrow(y2)},
- {SafeNarrow(x3), SafeNarrow(y3)});
+ sk_path_.rCubicTo(SafeNarrow(x1), SafeNarrow(y1), SafeNarrow(x2),
+ SafeNarrow(y2), SafeNarrow(x3), SafeNarrow(y3));
resetVolatility();
}
void CanvasPath::conicTo(double x1, double y1, double x2, double y2, double w) {
- sk_path_.conicTo({SafeNarrow(x1), SafeNarrow(y1)},
- {SafeNarrow(x2), SafeNarrow(y2)}, SafeNarrow(w));
+ sk_path_.conicTo(SafeNarrow(x1), SafeNarrow(y1), SafeNarrow(x2),
+ SafeNarrow(y2), SafeNarrow(w));
resetVolatility();
}
@@ -115,8 +113,8 @@
double x2,
double y2,
double w) {
- sk_path_.rConicTo({SafeNarrow(x1), SafeNarrow(y1)},
- {SafeNarrow(x2), SafeNarrow(y2)}, SafeNarrow(w));
+ sk_path_.rConicTo(SafeNarrow(x1), SafeNarrow(y1), SafeNarrow(x2),
+ SafeNarrow(y2), SafeNarrow(w));
resetVolatility();
}
@@ -142,14 +140,14 @@
double xAxisRotation,
bool isLargeArc,
bool isClockwiseDirection) {
- const auto arcSize = isLargeArc ? SkPathBuilder::ArcSize::kLarge_ArcSize
- : SkPathBuilder::ArcSize::kSmall_ArcSize;
+ const auto arcSize = isLargeArc ? SkPath::ArcSize::kLarge_ArcSize
+ : SkPath::ArcSize::kSmall_ArcSize;
const auto direction =
isClockwiseDirection ? SkPathDirection::kCW : SkPathDirection::kCCW;
- sk_path_.arcTo({SafeNarrow(radiusX), SafeNarrow(radiusY)},
+ sk_path_.arcTo(SafeNarrow(radiusX), SafeNarrow(radiusY),
SafeNarrow(xAxisRotation), arcSize, direction,
- {SafeNarrow(arcEndX), SafeNarrow(arcEndY)});
+ SafeNarrow(arcEndX), SafeNarrow(arcEndY));
resetVolatility();
}
@@ -160,13 +158,13 @@
double xAxisRotation,
bool isLargeArc,
bool isClockwiseDirection) {
- const auto arcSize = isLargeArc ? SkPathBuilder::ArcSize::kLarge_ArcSize
- : SkPathBuilder::ArcSize::kSmall_ArcSize;
+ const auto arcSize = isLargeArc ? SkPath::ArcSize::kLarge_ArcSize
+ : SkPath::ArcSize::kSmall_ArcSize;
const auto direction =
isClockwiseDirection ? SkPathDirection::kCW : SkPathDirection::kCCW;
- sk_path_.rArcTo({SafeNarrow(radiusX), SafeNarrow(radiusY)},
+ sk_path_.rArcTo(SafeNarrow(radiusX), SafeNarrow(radiusY),
SafeNarrow(xAxisRotation), arcSize, direction,
- {SafeNarrow(arcEndDeltaX), SafeNarrow(arcEndDeltaY)});
+ SafeNarrow(arcEndDeltaX), SafeNarrow(arcEndDeltaY));
resetVolatility();
}
@@ -199,7 +197,7 @@
SkSpan<const SkPoint> ptsSpan = {
reinterpret_cast<const SkPoint*>(points.data()),
points.num_elements() / 2};
- sk_path_.addPolygon(ptsSpan, close);
+ sk_path_.addPoly(ptsSpan, close);
resetVolatility();
}
@@ -222,7 +220,7 @@
Dart_ThrowException(ToDart("Path.addPath called with non-genuine Path."));
return;
}
- sk_path_.addPath(path->sk_path_.snapshot(), SafeNarrow(dx), SafeNarrow(dy),
+ sk_path_.addPath(path->sk_path_, SafeNarrow(dx), SafeNarrow(dy),
SkPath::kAppend_AddPathMode);
resetVolatility();
}
@@ -244,8 +242,7 @@
matrix4.Release();
matrix.setTranslateX(matrix.getTranslateX() + SafeNarrow(dx));
matrix.setTranslateY(matrix.getTranslateY() + SafeNarrow(dy));
- sk_path_.addPath(path->sk_path_.snapshot(), matrix,
- SkPath::kAppend_AddPathMode);
+ sk_path_.addPath(path->sk_path_, matrix, SkPath::kAppend_AddPathMode);
resetVolatility();
}
@@ -255,7 +252,7 @@
ToDart("Path.extendWithPath called with non-genuine Path."));
return;
}
- sk_path_.addPath(path->sk_path_.snapshot(), SafeNarrow(dx), SafeNarrow(dy),
+ sk_path_.addPath(path->sk_path_, SafeNarrow(dx), SafeNarrow(dy),
SkPath::kExtend_AddPathMode);
resetVolatility();
}
@@ -277,8 +274,7 @@
matrix4.Release();
matrix.setTranslateX(matrix.getTranslateX() + SafeNarrow(dx));
matrix.setTranslateY(matrix.getTranslateY() + SafeNarrow(dy));
- sk_path_.addPath(path->sk_path_.snapshot(), matrix,
- SkPath::kExtend_AddPathMode);
+ sk_path_.addPath(path->sk_path_, matrix, SkPath::kExtend_AddPathMode);
resetVolatility();
}
@@ -293,14 +289,13 @@
}
bool CanvasPath::contains(double x, double y) {
- return sk_path_.contains({SafeNarrow(x), SafeNarrow(y)});
+ return sk_path_.contains(SafeNarrow(x), SafeNarrow(y));
}
void CanvasPath::shift(Dart_Handle path_handle, double dx, double dy) {
fml::RefPtr<CanvasPath> path = Create(path_handle);
auto& other_mutable_path = path->sk_path_;
- other_mutable_path =
- sk_path_.snapshot().makeOffset(SafeNarrow(dx), SafeNarrow(dy));
+ sk_path_.offset(SafeNarrow(dx), SafeNarrow(dy), &other_mutable_path);
resetVolatility();
}
@@ -311,12 +306,12 @@
matrix4.Release();
fml::RefPtr<CanvasPath> path = Create(path_handle);
auto& other_mutable_path = path->sk_path_;
- other_mutable_path = sk_path_.snapshot().makeTransform(sk_matrix);
+ sk_path_.transform(sk_matrix, &other_mutable_path);
}
tonic::Float32List CanvasPath::getBounds() {
tonic::Float32List rect(Dart_NewTypedData(Dart_TypedData_kFloat32, 4));
- const SkRect& bounds = sk_path_.computeFiniteBounds().value_or(SkRect());
+ const SkRect& bounds = sk_path_.getBounds();
rect[0] = bounds.left();
rect[1] = bounds.top();
rect[2] = bounds.right();
@@ -325,15 +320,10 @@
}
bool CanvasPath::op(CanvasPath* path1, CanvasPath* path2, int operation) {
- std::optional<SkPath> result =
- Op(path1->sk_path_.snapshot(), path2->sk_path_.snapshot(),
- static_cast<SkPathOp>(operation));
- if (result) {
- sk_path_ = result.value();
- resetVolatility();
- return true;
- }
- return false;
+ bool result = Op(path1->sk_path_, path2->sk_path_,
+ static_cast<SkPathOp>(operation), &sk_path_);
+ resetVolatility();
+ return result;
}
void CanvasPath::clone(Dart_Handle path_handle) {
@@ -345,7 +335,7 @@
const DlPath& CanvasPath::path() const {
if (!dl_path_.has_value()) {
- dl_path_.emplace(sk_path_.snapshot());
+ dl_path_.emplace(sk_path_);
}
return dl_path_.value();
}
diff --git a/engine/src/flutter/lib/ui/painting/path.h b/engine/src/flutter/lib/ui/painting/path.h
index dc82a18..c7816a5 100644
--- a/engine/src/flutter/lib/ui/painting/path.h
+++ b/engine/src/flutter/lib/ui/painting/path.h
@@ -10,7 +10,6 @@
#include "flutter/lib/ui/painting/rsuperellipse.h"
#include "flutter/lib/ui/ui_dart_state.h"
#include "third_party/skia/include/core/SkPath.h"
-#include "third_party/skia/include/core/SkPathBuilder.h"
#include "third_party/skia/include/pathops/SkPathOps.h"
#include "third_party/tonic/typed_data/typed_list.h"
@@ -121,7 +120,7 @@
private:
CanvasPath();
- SkPathBuilder sk_path_;
+ SkPath sk_path_;
mutable std::optional<const DlPath> dl_path_;
// Must be called whenever the path is created or mutated.
diff --git a/engine/src/flutter/lib/web_ui/skwasm/canvas.cpp b/engine/src/flutter/lib/web_ui/skwasm/canvas.cpp
index ab999ce..973257f 100644
--- a/engine/src/flutter/lib/web_ui/skwasm/canvas.cpp
+++ b/engine/src/flutter/lib/web_ui/skwasm/canvas.cpp
@@ -7,8 +7,6 @@
#include "text/text_types.h"
#include "wrappers.h"
-#include "third_party/skia/include/core/SkPath.h"
-#include "third_party/skia/include/core/SkPathBuilder.h"
#include "third_party/skia/modules/skparagraph/include/Paragraph.h"
#include "flutter/display_list/dl_builder.h"
@@ -193,9 +191,9 @@
}
SKWASM_EXPORT void canvas_clipPath(DisplayListBuilder* canvas,
- SkPathBuilder* path,
+ SkPath* path,
bool antialias) {
- canvas->ClipPath(DlPath(path->snapshot()), DlClipOp::kIntersect, antialias);
+ canvas->ClipPath(DlPath(*path), DlClipOp::kIntersect, antialias);
}
SKWASM_EXPORT void canvas_drawColor(DisplayListBuilder* canvas,
@@ -265,18 +263,18 @@
}
SKWASM_EXPORT void canvas_drawPath(DisplayListBuilder* canvas,
- SkPathBuilder* path,
+ SkPath* path,
DlPaint* paint) {
- canvas->DrawPath(DlPath(path->snapshot()), paint ? *paint : DlPaint());
+ canvas->DrawPath(DlPath(*path), paint ? *paint : DlPaint());
}
SKWASM_EXPORT void canvas_drawShadow(DisplayListBuilder* canvas,
- SkPathBuilder* path,
+ SkPath* path,
DlScalar elevation,
DlScalar devicePixelRatio,
uint32_t color,
bool transparentOccluder) {
- canvas->DrawShadow(DlPath(path->snapshot()), DlColor(color), elevation,
+ canvas->DrawShadow(DlPath(*path), DlColor(color), elevation,
transparentOccluder, devicePixelRatio);
}
diff --git a/engine/src/flutter/lib/web_ui/skwasm/contour_measure.cpp b/engine/src/flutter/lib/web_ui/skwasm/contour_measure.cpp
index 2726e4a..d8abb1f 100644
--- a/engine/src/flutter/lib/web_ui/skwasm/contour_measure.cpp
+++ b/engine/src/flutter/lib/web_ui/skwasm/contour_measure.cpp
@@ -8,16 +8,13 @@
#include "third_party/skia/include/core/SkContourMeasure.h"
#include "third_party/skia/include/core/SkPath.h"
-#include "third_party/skia/include/core/SkPathBuilder.h"
using namespace Skwasm;
-SKWASM_EXPORT SkContourMeasureIter* contourMeasureIter_create(
- SkPathBuilder* path,
- bool forceClosed,
- SkScalar resScale) {
+SKWASM_EXPORT SkContourMeasureIter*
+contourMeasureIter_create(SkPath* path, bool forceClosed, SkScalar resScale) {
liveCountourMeasureIterCount++;
- return new SkContourMeasureIter(path->snapshot(), forceClosed, resScale);
+ return new SkContourMeasureIter(*path, forceClosed, resScale);
}
SKWASM_EXPORT SkContourMeasure* contourMeasureIter_next(
@@ -55,12 +52,11 @@
return measure->getPosTan(distance, outPosition, outTangent);
}
-SKWASM_EXPORT SkPathBuilder* contourMeasure_getSegment(
- SkContourMeasure* measure,
- SkScalar startD,
- SkScalar stopD,
- bool startWithMoveTo) {
- SkPathBuilder* outPath = new SkPathBuilder();
+SKWASM_EXPORT SkPath* contourMeasure_getSegment(SkContourMeasure* measure,
+ SkScalar startD,
+ SkScalar stopD,
+ bool startWithMoveTo) {
+ SkPath* outPath = new SkPath();
if (!measure->getSegment(startD, stopD, outPath, startWithMoveTo)) {
delete outPath;
return nullptr;
diff --git a/engine/src/flutter/lib/web_ui/skwasm/path.cpp b/engine/src/flutter/lib/web_ui/skwasm/path.cpp
index 56de7c9..530168e 100644
--- a/engine/src/flutter/lib/web_ui/skwasm/path.cpp
+++ b/engine/src/flutter/lib/web_ui/skwasm/path.cpp
@@ -5,112 +5,107 @@
#include "export.h"
#include "helpers.h"
#include "live_objects.h"
-#include "third_party/skia/include/core/SkPathBuilder.h"
+#include "third_party/skia/include/core/SkPath.h"
#include "third_party/skia/include/core/SkString.h"
#include "third_party/skia/include/pathops/SkPathOps.h"
#include "third_party/skia/include/utils/SkParsePath.h"
using namespace Skwasm;
-SKWASM_EXPORT SkPathBuilder* path_create() {
+SKWASM_EXPORT SkPath* path_create() {
livePathCount++;
- return new SkPathBuilder();
+ return new SkPath();
}
-SKWASM_EXPORT void path_dispose(SkPathBuilder* path) {
+SKWASM_EXPORT void path_dispose(SkPath* path) {
livePathCount--;
delete path;
}
-SKWASM_EXPORT SkPathBuilder* path_copy(SkPathBuilder* path) {
+SKWASM_EXPORT SkPath* path_copy(SkPath* path) {
livePathCount++;
- return new SkPathBuilder(path->snapshot());
+ return new SkPath(*path);
}
-SKWASM_EXPORT void path_setFillType(SkPathBuilder* path,
- SkPathFillType fillType) {
+SKWASM_EXPORT void path_setFillType(SkPath* path, SkPathFillType fillType) {
path->setFillType(fillType);
}
-SKWASM_EXPORT SkPathFillType path_getFillType(SkPathBuilder* path) {
- return path->fillType();
+SKWASM_EXPORT SkPathFillType path_getFillType(SkPath* path) {
+ return path->getFillType();
}
-SKWASM_EXPORT void path_moveTo(SkPathBuilder* path, SkScalar x, SkScalar y) {
- path->moveTo({x, y});
+SKWASM_EXPORT void path_moveTo(SkPath* path, SkScalar x, SkScalar y) {
+ path->moveTo(x, y);
}
-SKWASM_EXPORT void path_relativeMoveTo(SkPathBuilder* path,
- SkScalar x,
- SkScalar y) {
- path->rMoveTo({x, y});
+SKWASM_EXPORT void path_relativeMoveTo(SkPath* path, SkScalar x, SkScalar y) {
+ path->rMoveTo(x, y);
}
-SKWASM_EXPORT void path_lineTo(SkPathBuilder* path, SkScalar x, SkScalar y) {
- path->lineTo({x, y});
+SKWASM_EXPORT void path_lineTo(SkPath* path, SkScalar x, SkScalar y) {
+ path->lineTo(x, y);
}
-SKWASM_EXPORT void path_relativeLineTo(SkPathBuilder* path,
- SkScalar x,
- SkScalar y) {
- path->rLineTo({x, y});
+SKWASM_EXPORT void path_relativeLineTo(SkPath* path, SkScalar x, SkScalar y) {
+ path->rLineTo(x, y);
}
-SKWASM_EXPORT void path_quadraticBezierTo(SkPathBuilder* path,
+SKWASM_EXPORT void path_quadraticBezierTo(SkPath* path,
SkScalar x1,
SkScalar y1,
SkScalar x2,
SkScalar y2) {
- path->quadTo({x1, y1}, {x2, y2});
+ path->quadTo(x1, y1, x2, y2);
}
-SKWASM_EXPORT void path_relativeQuadraticBezierTo(SkPathBuilder* path,
+SKWASM_EXPORT void path_relativeQuadraticBezierTo(SkPath* path,
SkScalar x1,
SkScalar y1,
SkScalar x2,
SkScalar y2) {
- path->rQuadTo({x1, y1}, {x2, y2});
+ path->rQuadTo(x1, y1, x2, y2);
}
-SKWASM_EXPORT void path_cubicTo(SkPathBuilder* path,
+SKWASM_EXPORT void path_cubicTo(SkPath* path,
SkScalar x1,
SkScalar y1,
SkScalar x2,
SkScalar y2,
SkScalar x3,
SkScalar y3) {
- path->cubicTo({x1, y1}, {x2, y2}, {x3, y3});
+ path->cubicTo(x1, y1, x2, y2, x3, y3);
}
-SKWASM_EXPORT void path_relativeCubicTo(SkPathBuilder* path,
+SKWASM_EXPORT void path_relativeCubicTo(SkPath* path,
SkScalar x1,
SkScalar y1,
SkScalar x2,
SkScalar y2,
SkScalar x3,
SkScalar y3) {
- path->rCubicTo({x1, y1}, {x2, y2}, {x3, y3});
+ path->rCubicTo(x1, y1, x2, y2, x3, y3);
}
-SKWASM_EXPORT void path_conicTo(SkPathBuilder* path,
+SKWASM_EXPORT void path_conicTo(SkPath* path,
SkScalar x1,
SkScalar y1,
SkScalar x2,
SkScalar y2,
SkScalar w) {
- path->conicTo({x1, y1}, {x2, y2}, w);
+ path->conicTo(x1, y1, x2, y2, w);
}
-SKWASM_EXPORT void path_relativeConicTo(SkPathBuilder* path,
+SKWASM_EXPORT void path_relativeConicTo(SkPath* path,
SkScalar x1,
SkScalar y1,
SkScalar x2,
SkScalar y2,
SkScalar w) {
- path->rConicTo({x1, y1}, {x2, y2}, w);
+ path->rConicTo(x1, y1, x2, y2, w);
}
-SKWASM_EXPORT void path_arcToOval(SkPathBuilder* path,
+SKWASM_EXPORT void path_arcToOval(SkPath* path,
const SkRect* rect,
SkScalar startAngle,
SkScalar sweepAngle,
@@ -118,98 +113,97 @@
path->arcTo(*rect, startAngle, sweepAngle, forceMoveTo);
}
-SKWASM_EXPORT void path_arcToRotated(SkPathBuilder* path,
+SKWASM_EXPORT void path_arcToRotated(SkPath* path,
SkScalar rx,
SkScalar ry,
SkScalar xAxisRotate,
- SkPathBuilder::ArcSize arcSize,
+ SkPath::ArcSize arcSize,
SkPathDirection pathDirection,
SkScalar x,
SkScalar y) {
- path->arcTo({rx, ry}, xAxisRotate, arcSize, pathDirection, {x, y});
+ path->arcTo(rx, ry, xAxisRotate, arcSize, pathDirection, x, y);
}
-SKWASM_EXPORT void path_relativeArcToRotated(SkPathBuilder* path,
+SKWASM_EXPORT void path_relativeArcToRotated(SkPath* path,
SkScalar rx,
SkScalar ry,
SkScalar xAxisRotate,
- SkPathBuilder::ArcSize arcSize,
+ SkPath::ArcSize arcSize,
SkPathDirection pathDirection,
SkScalar x,
SkScalar y) {
- path->rArcTo({rx, ry}, xAxisRotate, arcSize, pathDirection, {x, y});
+ path->rArcTo(rx, ry, xAxisRotate, arcSize, pathDirection, x, y);
}
-SKWASM_EXPORT void path_addRect(SkPathBuilder* path, const SkRect* rect) {
+SKWASM_EXPORT void path_addRect(SkPath* path, const SkRect* rect) {
path->addRect(*rect);
}
-SKWASM_EXPORT void path_addOval(SkPathBuilder* path, const SkRect* oval) {
+SKWASM_EXPORT void path_addOval(SkPath* path, const SkRect* oval) {
path->addOval(*oval, SkPathDirection::kCW, 1);
}
-SKWASM_EXPORT void path_addArc(SkPathBuilder* path,
+SKWASM_EXPORT void path_addArc(SkPath* path,
const SkRect* oval,
SkScalar startAngle,
SkScalar sweepAngle) {
path->addArc(*oval, startAngle, sweepAngle);
}
-SKWASM_EXPORT void path_addPolygon(SkPathBuilder* path,
+SKWASM_EXPORT void path_addPolygon(SkPath* path,
const SkPoint* points,
int count,
bool close) {
- path->addPolygon({points, count}, close);
+ path->addPoly({points, count}, close);
}
-SKWASM_EXPORT void path_addRRect(SkPathBuilder* path,
- const SkScalar* rrectValues) {
+SKWASM_EXPORT void path_addRRect(SkPath* path, const SkScalar* rrectValues) {
path->addRRect(createSkRRect(rrectValues), SkPathDirection::kCW);
}
-SKWASM_EXPORT void path_addPath(SkPathBuilder* path,
- const SkPathBuilder* other,
+SKWASM_EXPORT void path_addPath(SkPath* path,
+ const SkPath* other,
const SkScalar* matrix33,
SkPath::AddPathMode extendPath) {
- path->addPath(other->snapshot(), createSkMatrix(matrix33), extendPath);
+ path->addPath(*other, createSkMatrix(matrix33), extendPath);
}
-SKWASM_EXPORT void path_close(SkPathBuilder* path) {
+SKWASM_EXPORT void path_close(SkPath* path) {
path->close();
}
-SKWASM_EXPORT void path_reset(SkPathBuilder* path) {
+SKWASM_EXPORT void path_reset(SkPath* path) {
path->reset();
}
-SKWASM_EXPORT bool path_contains(SkPathBuilder* path, SkScalar x, SkScalar y) {
- return path->contains({x, y});
+SKWASM_EXPORT bool path_contains(SkPath* path, SkScalar x, SkScalar y) {
+ return path->contains(x, y);
}
-SKWASM_EXPORT void path_transform(SkPathBuilder* path,
- const SkScalar* matrix33) {
+SKWASM_EXPORT void path_transform(SkPath* path, const SkScalar* matrix33) {
path->transform(createSkMatrix(matrix33));
}
-SKWASM_EXPORT void path_getBounds(SkPathBuilder* path, SkRect* rect) {
- *rect = path->computeFiniteBounds().value_or(SkRect());
+SKWASM_EXPORT void path_getBounds(SkPath* path, SkRect* rect) {
+ *rect = path->getBounds();
}
-SKWASM_EXPORT SkPathBuilder* path_combine(SkPathOp operation,
- const SkPathBuilder* path1,
- const SkPathBuilder* path2) {
- if (auto result = Op(path1->snapshot(), path2->snapshot(), operation)) {
- livePathCount++;
- SkPathBuilder* output = new SkPathBuilder(result.value());
- output->setFillType(path1->fillType());
+SKWASM_EXPORT SkPath* path_combine(SkPathOp operation,
+ const SkPath* path1,
+ const SkPath* path2) {
+ livePathCount++;
+ SkPath* output = new SkPath();
+ if (Op(*path1, *path2, operation, output)) {
+ output->setFillType(path1->getFillType());
return output;
} else {
+ delete output;
return nullptr;
}
}
-SKWASM_EXPORT SkString* path_getSvgString(SkPathBuilder* path) {
+SKWASM_EXPORT SkString* path_getSvgString(SkPath* path) {
liveStringCount++;
- SkString* string = new SkString(SkParsePath::ToSVGString(path->snapshot()));
+ SkString* string = new SkString(SkParsePath::ToSVGString(*path));
return string;
}
diff --git a/engine/src/flutter/skia/flutter_defines.gni b/engine/src/flutter/skia/flutter_defines.gni
index 298ddcc..4fd1771 100644
--- a/engine/src/flutter/skia/flutter_defines.gni
+++ b/engine/src/flutter/skia/flutter_defines.gni
@@ -12,7 +12,6 @@
"SK_DISABLE_LEGACY_PNG_WRITEBUFFER",
"SK_DISABLE_LEGACY_IMAGE_READBUFFER",
- "SK_HIDE_PATH_EDIT_METHODS",
# Fast low-precision software rendering isn't a priority for Flutter.
"SK_DISABLE_LEGACY_SHADERCONTEXT",
diff --git a/engine/src/flutter/third_party/canvaskit/BUILD.gn b/engine/src/flutter/third_party/canvaskit/BUILD.gn
index 24a2bc6..5cae86f 100644
--- a/engine/src/flutter/third_party/canvaskit/BUILD.gn
+++ b/engine/src/flutter/third_party/canvaskit/BUILD.gn
@@ -85,6 +85,7 @@
skia_enable_skparagraph = false
skia_canvaskit_enable_paragraph = false
skia_enable_shaper = false
+ skia_enable_harfbuzz = false
skia_use_harfbuzz = false
skia_use_freetype = false
flutter_use_freetype_woff2 = false
diff --git a/engine/src/flutter/tools/path_ops/dart/lib/path_ops.dart b/engine/src/flutter/tools/path_ops/dart/lib/path_ops.dart
index 1c66f40..2a8661a 100644
--- a/engine/src/flutter/tools/path_ops/dart/lib/path_ops.dart
+++ b/engine/src/flutter/tools/path_ops/dart/lib/path_ops.dart
@@ -144,7 +144,7 @@
return FillType.values[_getFillTypeFn(_path!)];
}
- ffi.Pointer<_SkPathBuilder>? _path;
+ ffi.Pointer<_SkPath>? _path;
ffi.Pointer<_PathData>? _pathData;
/// The number of points used by each [PathVerb].
@@ -293,7 +293,7 @@
throw UnsupportedError('Unknown platform: ${Platform.operatingSystem}');
}();
-final class _SkPathBuilder extends ffi.Opaque {}
+final class _SkPath extends ffi.Opaque {}
final class _PathData extends ffi.Struct {
external ffi.Pointer<ffi.Uint8> verbs;
@@ -307,28 +307,28 @@
external int point_count;
}
-typedef _CreatePathType = ffi.Pointer<_SkPathBuilder> Function(int);
-typedef _create_path_type = ffi.Pointer<_SkPathBuilder> Function(ffi.Int);
+typedef _CreatePathType = ffi.Pointer<_SkPath> Function(int);
+typedef _create_path_type = ffi.Pointer<_SkPath> Function(ffi.Int);
final _CreatePathType _createPathFn = _dylib.lookupFunction<_create_path_type, _CreatePathType>(
'CreatePath',
);
-typedef _MoveToType = void Function(ffi.Pointer<_SkPathBuilder>, double, double);
-typedef _move_to_type = ffi.Void Function(ffi.Pointer<_SkPathBuilder>, ffi.Float, ffi.Float);
+typedef _MoveToType = void Function(ffi.Pointer<_SkPath>, double, double);
+typedef _move_to_type = ffi.Void Function(ffi.Pointer<_SkPath>, ffi.Float, ffi.Float);
final _MoveToType _moveToFn = _dylib.lookupFunction<_move_to_type, _MoveToType>('MoveTo');
-typedef _LineToType = void Function(ffi.Pointer<_SkPathBuilder>, double, double);
-typedef _line_to_type = ffi.Void Function(ffi.Pointer<_SkPathBuilder>, ffi.Float, ffi.Float);
+typedef _LineToType = void Function(ffi.Pointer<_SkPath>, double, double);
+typedef _line_to_type = ffi.Void Function(ffi.Pointer<_SkPath>, ffi.Float, ffi.Float);
final _LineToType _lineToFn = _dylib.lookupFunction<_line_to_type, _LineToType>('LineTo');
typedef _CubicToType =
- void Function(ffi.Pointer<_SkPathBuilder>, double, double, double, double, double, double);
+ void Function(ffi.Pointer<_SkPath>, double, double, double, double, double, double);
typedef _cubic_to_type =
ffi.Void Function(
- ffi.Pointer<_SkPathBuilder>,
+ ffi.Pointer<_SkPath>,
ffi.Float,
ffi.Float,
ffi.Float,
@@ -339,29 +339,28 @@
final _CubicToType _cubicToFn = _dylib.lookupFunction<_cubic_to_type, _CubicToType>('CubicTo');
-typedef _CloseType = void Function(ffi.Pointer<_SkPathBuilder>, bool);
-typedef _close_type = ffi.Void Function(ffi.Pointer<_SkPathBuilder>, ffi.Bool);
+typedef _CloseType = void Function(ffi.Pointer<_SkPath>, bool);
+typedef _close_type = ffi.Void Function(ffi.Pointer<_SkPath>, ffi.Bool);
final _CloseType _closeFn = _dylib.lookupFunction<_close_type, _CloseType>('Close');
-typedef _ResetType = void Function(ffi.Pointer<_SkPathBuilder>);
-typedef _reset_type = ffi.Void Function(ffi.Pointer<_SkPathBuilder>);
+typedef _ResetType = void Function(ffi.Pointer<_SkPath>);
+typedef _reset_type = ffi.Void Function(ffi.Pointer<_SkPath>);
final _ResetType _resetFn = _dylib.lookupFunction<_reset_type, _ResetType>('Reset');
-typedef _DestroyType = void Function(ffi.Pointer<_SkPathBuilder>);
-typedef _destroy_type = ffi.Void Function(ffi.Pointer<_SkPathBuilder>);
+typedef _DestroyType = void Function(ffi.Pointer<_SkPath>);
+typedef _destroy_type = ffi.Void Function(ffi.Pointer<_SkPath>);
final _DestroyType _destroyFn = _dylib.lookupFunction<_destroy_type, _DestroyType>('DestroyPath');
-typedef _OpType = void Function(ffi.Pointer<_SkPathBuilder>, ffi.Pointer<_SkPathBuilder>, int);
-typedef _op_type =
- ffi.Void Function(ffi.Pointer<_SkPathBuilder>, ffi.Pointer<_SkPathBuilder>, ffi.Int);
+typedef _OpType = void Function(ffi.Pointer<_SkPath>, ffi.Pointer<_SkPath>, int);
+typedef _op_type = ffi.Void Function(ffi.Pointer<_SkPath>, ffi.Pointer<_SkPath>, ffi.Int);
final _OpType _opFn = _dylib.lookupFunction<_op_type, _OpType>('Op');
-typedef _PathDataType = ffi.Pointer<_PathData> Function(ffi.Pointer<_SkPathBuilder>);
-typedef _path_data_type = ffi.Pointer<_PathData> Function(ffi.Pointer<_SkPathBuilder>);
+typedef _PathDataType = ffi.Pointer<_PathData> Function(ffi.Pointer<_SkPath>);
+typedef _path_data_type = ffi.Pointer<_PathData> Function(ffi.Pointer<_SkPath>);
final _PathDataType _dataFn = _dylib.lookupFunction<_path_data_type, _PathDataType>('Data');
@@ -372,8 +371,8 @@
'DestroyData',
);
-typedef _GetFillTypeType = int Function(ffi.Pointer<_SkPathBuilder>);
-typedef _get_fill_type_type = ffi.Int32 Function(ffi.Pointer<_SkPathBuilder>);
+typedef _GetFillTypeType = int Function(ffi.Pointer<_SkPath>);
+typedef _get_fill_type_type = ffi.Int32 Function(ffi.Pointer<_SkPath>);
final _GetFillTypeType _getFillTypeFn = _dylib
.lookupFunction<_get_fill_type_type, _GetFillTypeType>('GetFillType');
diff --git a/engine/src/flutter/tools/path_ops/path_ops.cc b/engine/src/flutter/tools/path_ops/path_ops.cc
index 4157f50..aa01c7b 100644
--- a/engine/src/flutter/tools/path_ops/path_ops.cc
+++ b/engine/src/flutter/tools/path_ops/path_ops.cc
@@ -4,26 +4,26 @@
#include "path_ops.h"
-#include "third_party/skia/include/core/SkPath.h"
-
namespace flutter {
-SkPathBuilder* CreatePath(SkPathFillType fill_type) {
- return new SkPathBuilder(fill_type);
+SkPath* CreatePath(SkPathFillType fill_type) {
+ auto* path = new SkPath();
+ path->setFillType(fill_type);
+ return path;
}
-void DestroyPath(SkPathBuilder* path) {
+void DestroyPath(SkPath* path) {
delete path;
}
-void MoveTo(SkPathBuilder* path, SkScalar x, SkScalar y) {
+void MoveTo(SkPath* path, SkScalar x, SkScalar y) {
path->moveTo(x, y);
}
-void LineTo(SkPathBuilder* path, SkScalar x, SkScalar y) {
+void LineTo(SkPath* path, SkScalar x, SkScalar y) {
path->lineTo(x, y);
}
-void CubicTo(SkPathBuilder* path,
+void CubicTo(SkPath* path,
SkScalar x1,
SkScalar y1,
SkScalar x2,
@@ -33,30 +33,25 @@
path->cubicTo(x1, y1, x2, y2, x3, y3);
}
-void Close(SkPathBuilder* path) {
+void Close(SkPath* path) {
path->close();
}
-void Reset(SkPathBuilder* path) {
+void Reset(SkPath* path) {
path->reset();
}
-void Op(SkPathBuilder* one, SkPathBuilder* two, SkPathOp op) {
- SkPath p1 = one->detach();
- SkPath p2 = two->snapshot();
- if (std::optional<SkPath> result = Op(p1, p2, op)) {
- one->addPath(result.value());
- }
+void Op(SkPath* one, SkPath* two, SkPathOp op) {
+ Op(*one, *two, op, one);
}
-int GetFillType(SkPathBuilder* path) {
- return static_cast<int>(path->fillType());
+int GetFillType(SkPath* path) {
+ return static_cast<int>(path->getFillType());
}
-struct PathData* Data(SkPathBuilder* pb) {
- SkPath path = pb->snapshot();
- int point_count = path.countPoints();
- int verb_count = path.countVerbs();
+struct PathData* Data(SkPath* path) {
+ int point_count = path->countPoints();
+ int verb_count = path->countVerbs();
auto data = new PathData();
data->points = new float[point_count * 2];
@@ -65,10 +60,10 @@
data->verb_count = verb_count;
SkSpan<uint8_t> outVerbs(data->verbs, verb_count);
- path.getVerbs(outVerbs);
+ path->getVerbs(outVerbs);
SkSpan<SkPoint> outPoints(reinterpret_cast<SkPoint*>(data->points),
point_count);
- path.getPoints(outPoints);
+ path->getPoints(outPoints);
return data;
}
diff --git a/engine/src/flutter/tools/path_ops/path_ops.h b/engine/src/flutter/tools/path_ops/path_ops.h
index 5dcc404..5384305 100644
--- a/engine/src/flutter/tools/path_ops/path_ops.h
+++ b/engine/src/flutter/tools/path_ops/path_ops.h
@@ -5,6 +5,7 @@
#ifndef FLUTTER_TOOLS_PATH_OPS_PATH_OPS_H_
#define FLUTTER_TOOLS_PATH_OPS_PATH_OPS_H_
+#include "third_party/skia/include/core/SkPath.h"
#include "third_party/skia/include/core/SkPathBuilder.h"
#include "third_party/skia/include/core/SkPathTypes.h"
#include "third_party/skia/include/pathops/SkPathOps.h"
@@ -19,15 +20,15 @@
namespace flutter {
-API SkPathBuilder* CreatePath(SkPathFillType fill_type);
+API SkPath* CreatePath(SkPathFillType fill_type);
-API void DestroyPath(SkPathBuilder* path);
+API void DestroyPathBuilder(SkPath* path);
-API void MoveTo(SkPathBuilder* path, SkScalar x, SkScalar y);
+API void MoveTo(SkPath* path, SkScalar x, SkScalar y);
-API void LineTo(SkPathBuilder* path, SkScalar x, SkScalar y);
+API void LineTo(SkPath* path, SkScalar x, SkScalar y);
-API void CubicTo(SkPathBuilder* path,
+API void CubicTo(SkPath* path,
SkScalar x1,
SkScalar y1,
SkScalar x2,
@@ -35,13 +36,15 @@
SkScalar x3,
SkScalar y3);
-API void Close(SkPathBuilder* path);
+API void Close(SkPath* path);
-API void Reset(SkPathBuilder* path);
+API void Reset(SkPath* path);
-API void Op(SkPathBuilder* one, SkPathBuilder* two, SkPathOp op);
+API void DestroyPath(SkPath* path);
-API int GetFillType(SkPathBuilder* path);
+API void Op(SkPath* one, SkPath* two, SkPathOp op);
+
+API int GetFillType(SkPath* path);
struct API PathData {
uint8_t* verbs;
@@ -50,7 +53,7 @@
size_t point_count;
};
-API struct PathData* Data(SkPathBuilder* path);
+API struct PathData* Data(SkPath* path);
API void DestroyData(PathData* data);