| 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
5 #include "impeller/toolkit/interop/path_builder.h"
6
7 #include "impeller/toolkit/interop/formats.h"
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(
55 const Rect& rect,
56 const impeller::PathBuilder::RoundingRadii& radii) {
57 builder_.addRRect(ToSkiaType(rect, radii));
58 }
59
60 void PathBuilder::Close() {
61 builder_.close();
62 }
63
64 ScopedObject<Path> PathBuilder::TakePath(FillType fill) {
65 builder_.setFillType(ToSkiaType(fill));
66 return Create<Path>(std::move(builder_));
67 }
68
69 ScopedObject<Path> PathBuilder::CopyPath(FillType fill) {
70 builder_.setFillType(ToSkiaType(fill));
71 return Create<Path>(builder_);
72 }
73
74 } // namespace impeller::interop
impeller::interop::PathBuilder::MoveTo
void MoveTo(const Point &point)
Definition: path_builder.cc:15
impeller::Degrees::degrees
Scalar degrees
Definition: scalar.h:52
impeller::interop::ScopedObject
Definition: object.h:67
impeller::interop::PathBuilder::Close
void Close()
Definition: path_builder.cc:60
impeller::interop::PathBuilder::~PathBuilder
~PathBuilder()
impeller::interop
Definition: color_filter.cc:7
impeller::interop::PathBuilder::AddRoundedRect
void AddRoundedRect(const Rect &rect, const impeller::PathBuilder::RoundingRadii &radii)
Definition: path_builder.cc:54
impeller::PathBuilder::RoundingRadii
Definition: path_builder.h:105
impeller::interop::PathBuilder::TakePath
ScopedObject< Path > TakePath(FillType fill)
Definition: path_builder.cc:64
impeller::interop::PathBuilder::AddRect
void AddRect(const Rect &rect)
Definition: path_builder.cc:37
impeller::interop::ToSkiaType
constexpr std::optional< SkRect > ToSkiaType(const ImpellerRect *rect)
Definition: formats.h:26
formats.h
impeller::interop::PathBuilder::AddArc
void AddArc(const Rect &oval_bounds, Degrees start_angle, Degrees end_angle)
Definition: path_builder.cc:41
impeller::FillType
FillType
Definition: path.h:30
impeller::interop::PathBuilder::LineTo
void LineTo(const Point &location)
Definition: path_builder.cc:19
impeller::interop::PathBuilder::CubicCurveTo
void CubicCurveTo(const Point &control_point_1, const Point &control_point_2, const Point &end_point)
Definition: path_builder.cc:28
impeller::interop::PathBuilder::PathBuilder
PathBuilder()
impeller::interop::PathBuilder::CopyPath
ScopedObject< Path > CopyPath(FillType fill)
Definition: path_builder.cc:69
path_builder.h
impeller::interop::PathBuilder::AddOval
void AddOval(const Rect &oval_bounds)
Definition: path_builder.cc:50
impeller::interop::PathBuilder::QuadraticCurveTo
void QuadraticCurveTo(const Point &control_point, const Point &end_point)
Definition: path_builder.cc:23
impeller::TPoint< Scalar >
impeller::Degrees
Definition: scalar.h:51
impeller::TRect< Scalar >