| 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(const Rect& rect, const RoundingRadii& radii) {
55 builder_.addRRect(ToSkiaType(rect, radii));
56 }
57
58 void PathBuilder::Close() {
59 builder_.close();
60 }
61
62 ScopedObject<Path> PathBuilder::TakePath(FillType fill) {
63 builder_.setFillType(ToSkiaType(fill));
64 return Create<Path>(std::move(builder_));
65 }
66
67 ScopedObject<Path> PathBuilder::CopyPath(FillType fill) {
68 builder_.setFillType(ToSkiaType(fill));
69 return Create<Path>(builder_);
70 }
71
72 } // namespace impeller::interop
impeller::interop::PathBuilder::CopyPath
ScopedObject< Path > CopyPath(FillType fill)
Definition: path_builder.cc:67
impeller::interop::PathBuilder::~PathBuilder
~PathBuilder()
impeller::interop::PathBuilder::AddArc
void AddArc(const Rect &oval_bounds, Degrees start_angle, Degrees end_angle)
Definition: path_builder.cc:41
impeller::interop::PathBuilder::MoveTo
void MoveTo(const Point &point)
Definition: path_builder.cc:15
impeller::interop::PathBuilder::LineTo
void LineTo(const Point &location)
Definition: path_builder.cc:19
impeller::interop::PathBuilder::AddOval
void AddOval(const Rect &oval_bounds)
Definition: path_builder.cc:50
impeller::interop::PathBuilder::AddRoundedRect
void AddRoundedRect(const Rect &rect, const RoundingRadii &radii)
Definition: path_builder.cc:54
impeller::interop::PathBuilder::QuadraticCurveTo
void QuadraticCurveTo(const Point &control_point, const Point &end_point)
Definition: path_builder.cc:23
impeller::interop::PathBuilder::Close
void Close()
Definition: path_builder.cc:58
impeller::interop::PathBuilder::PathBuilder
PathBuilder()
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::TakePath
ScopedObject< Path > TakePath(FillType fill)
Definition: path_builder.cc:62
impeller::interop::PathBuilder::AddRect
void AddRect(const Rect &rect)
Definition: path_builder.cc:37
impeller::interop::ScopedObject
Definition: object.h:67
impeller::interop
Definition: context_gles.cc:12
impeller::interop::ToSkiaType
constexpr std::optional< SkRect > ToSkiaType(const ImpellerRect *rect)
Definition: formats.h:30
impeller::FillType
FillType
Definition: path_source.h:13
path_builder.h
impeller::Degrees
Definition: scalar.h:76
impeller::Degrees::degrees
Scalar degrees
Definition: scalar.h:77
impeller::RoundingRadii
Definition: rounding_radii.h:14
impeller::TPoint< Scalar >
impeller::TRect< Scalar >
formats.h