Flutter Impeller
path_source.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 
7 namespace impeller {
8 
10 
12  return true;
13 }
14 
16  return FillType::kNonZero;
17 }
18 
20  return rect_;
21 }
22 
23 void RectPathSource::Dispatch(PathReceiver& receiver) const {
24  receiver.MoveTo(rect_.GetLeftTop(), true);
25  receiver.LineTo(rect_.GetRightTop());
26  receiver.LineTo(rect_.GetRightBottom());
27  receiver.LineTo(rect_.GetLeftBottom());
28  receiver.LineTo(rect_.GetLeftTop());
29  receiver.Close();
30 }
31 
32 EllipsePathSource::EllipsePathSource(const Rect& bounds) : bounds_(bounds) {}
33 
35 
37  return FillType::kNonZero;
38 }
39 
41  return bounds_;
42 }
43 
45  return true;
46 }
47 
49  Scalar left = bounds_.GetLeft();
50  Scalar right = bounds_.GetRight();
51  Scalar top = bounds_.GetTop();
52  Scalar bottom = bounds_.GetBottom();
53  Point center = bounds_.GetCenter();
54 
55  receiver.MoveTo(Point(left, center.y), true);
56  receiver.ConicTo(Point(left, top), Point(center.x, top), kSqrt2Over2);
57  receiver.ConicTo(Point(right, top), Point(right, center.y), kSqrt2Over2);
58  receiver.ConicTo(Point(right, bottom), Point(center.x, bottom), kSqrt2Over2);
59  receiver.ConicTo(Point(left, bottom), Point(left, center.y), kSqrt2Over2);
60 
61  receiver.Close();
62 }
63 
64 } // namespace impeller
EllipsePathSource(const Rect &bounds)
Definition: path_source.cc:32
void Dispatch(PathReceiver &receiver) const override
Definition: path_source.cc:48
bool IsConvex() const override
Definition: path_source.cc:44
Rect GetBounds() const override
Definition: path_source.cc:40
FillType GetFillType() const override
Definition: path_source.cc:36
Collection of functions to receive path segments from the underlying path representation via the DlPa...
Definition: path_source.h:42
virtual void LineTo(const Point &p2)=0
virtual void Close()=0
virtual void MoveTo(const Point &p2, bool will_be_closed)=0
virtual bool ConicTo(const Point &cp, const Point &p2, Scalar weight)
Definition: path_source.h:48
FillType GetFillType() const override
Definition: path_source.cc:15
bool IsConvex() const override
Definition: path_source.cc:11
Rect GetBounds() const override
Definition: path_source.cc:19
void Dispatch(PathReceiver &receiver) const override
Definition: path_source.cc:23
float Scalar
Definition: scalar.h:19
constexpr float kSqrt2Over2
Definition: constants.h:51
TPoint< Scalar > Point
Definition: point.h:327
constexpr auto GetBottom() const
Definition: rect.h:361
constexpr auto GetTop() const
Definition: rect.h:357
constexpr auto GetLeft() const
Definition: rect.h:355
constexpr auto GetRight() const
Definition: rect.h:359
constexpr TPoint< T > GetLeftBottom() const
Definition: rect.h:371
constexpr TPoint< T > GetRightTop() const
Definition: rect.h:367
constexpr TPoint< T > GetRightBottom() const
Definition: rect.h:375
constexpr Point GetCenter() const
Get the center point as a |Point|.
Definition: rect.h:386
constexpr TPoint< T > GetLeftTop() const
Definition: rect.h:363