Flutter Impeller
path_builder.cc
Go to the documentation of this file.
1 // Copyright 2013 The Flutter Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
6 
8 
9 namespace impeller::interop {
10 
11 PathBuilder::PathBuilder() = default;
12 
13 PathBuilder::~PathBuilder() = default;
14 
15 void PathBuilder::MoveTo(const Point& point) {
16  builder_.moveTo(ToSkiaType(point));
17 }
18 
19 void PathBuilder::LineTo(const Point& location) {
20  builder_.lineTo(ToSkiaType(location));
21 }
22 
23 void PathBuilder::QuadraticCurveTo(const Point& control_point,
24  const Point& end_point) {
25  builder_.quadTo(ToSkiaType(control_point), ToSkiaType(end_point));
26 }
27 
28 void PathBuilder::CubicCurveTo(const Point& control_point_1,
29  const Point& control_point_2,
30  const Point& end_point) {
31  builder_.cubicTo(ToSkiaType(control_point_1), //
32  ToSkiaType(control_point_2), //
33  ToSkiaType(end_point) //
34  );
35 }
36 
37 void PathBuilder::AddRect(const Rect& rect) {
38  builder_.addRect(ToSkiaType(rect));
39 }
40 
41 void PathBuilder::AddArc(const Rect& oval_bounds,
42  Degrees start_angle,
43  Degrees end_angle) {
44  builder_.addArc(ToSkiaType(oval_bounds), //
45  start_angle.degrees, //
46  end_angle.degrees - start_angle.degrees // sweep
47  );
48 }
49 
50 void PathBuilder::AddOval(const Rect& oval_bounds) {
51  builder_.addOval(ToSkiaType(oval_bounds));
52 }
53 
54 void PathBuilder::AddRoundedRect(const Rect& rect, const RoundingRadii& radii) {
55  builder_.addRRect(ToSkiaType(rect, radii));
56 }
57 
59  builder_.close();
60 }
61 
63  builder_.setFillType(ToSkiaType(fill));
64  return Create<Path>(std::move(builder_));
65 }
66 
68  builder_.setFillType(ToSkiaType(fill));
69  return Create<Path>(builder_);
70 }
71 
72 } // namespace impeller::interop
ScopedObject< Path > CopyPath(FillType fill)
Definition: path_builder.cc:67
void AddArc(const Rect &oval_bounds, Degrees start_angle, Degrees end_angle)
Definition: path_builder.cc:41
void MoveTo(const Point &point)
Definition: path_builder.cc:15
void LineTo(const Point &location)
Definition: path_builder.cc:19
void AddOval(const Rect &oval_bounds)
Definition: path_builder.cc:50
void AddRoundedRect(const Rect &rect, const RoundingRadii &radii)
Definition: path_builder.cc:54
void QuadraticCurveTo(const Point &control_point, const Point &end_point)
Definition: path_builder.cc:23
void CubicCurveTo(const Point &control_point_1, const Point &control_point_2, const Point &end_point)
Definition: path_builder.cc:28
ScopedObject< Path > TakePath(FillType fill)
Definition: path_builder.cc:62
void AddRect(const Rect &rect)
Definition: path_builder.cc:37
constexpr std::optional< SkRect > ToSkiaType(const ImpellerRect *rect)
Definition: formats.h:30
Scalar degrees
Definition: scalar.h:77