| 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
5 #include "flutter/impeller/geometry/path_source.h"
6
7 namespace impeller {
8
9 RectPathSource::~RectPathSource() = default;
10
11 bool RectPathSource::IsConvex() const {
12 return true;
13 }
14
15 FillType RectPathSource::GetFillType() const {
16 return FillType::kNonZero;
17 }
18
19 Rect RectPathSource::GetBounds() const {
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
34 EllipsePathSource::~EllipsePathSource() = default;
35
36 FillType EllipsePathSource::GetFillType() const {
37 return FillType::kNonZero;
38 }
39
40 Rect EllipsePathSource::GetBounds() const {
41 return bounds_;
42 }
43
44 bool EllipsePathSource::IsConvex() const {
45 return true;
46 }
47
48 void EllipsePathSource::Dispatch(PathReceiver& receiver) const {
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
impeller::EllipsePathSource::EllipsePathSource
EllipsePathSource(const Rect &bounds)
Definition: path_source.cc:32
impeller::EllipsePathSource::Dispatch
void Dispatch(PathReceiver &receiver) const override
Definition: path_source.cc:48
impeller::EllipsePathSource::IsConvex
bool IsConvex() const override
Definition: path_source.cc:44
impeller::EllipsePathSource::~EllipsePathSource
~EllipsePathSource()
impeller::EllipsePathSource::GetBounds
Rect GetBounds() const override
Definition: path_source.cc:40
impeller::EllipsePathSource::GetFillType
FillType GetFillType() const override
Definition: path_source.cc:36
impeller::PathReceiver
Collection of functions to receive path segments from the underlying path representation via the DlPa...
Definition: path_source.h:42
impeller::PathReceiver::LineTo
virtual void LineTo(const Point &p2)=0
impeller::PathReceiver::Close
virtual void Close()=0
impeller::PathReceiver::MoveTo
virtual void MoveTo(const Point &p2, bool will_be_closed)=0
impeller::PathReceiver::ConicTo
virtual bool ConicTo(const Point &cp, const Point &p2, Scalar weight)
Definition: path_source.h:48
impeller::RectPathSource::GetFillType
FillType GetFillType() const override
Definition: path_source.cc:15
impeller::RectPathSource::IsConvex
bool IsConvex() const override
Definition: path_source.cc:11
impeller::RectPathSource::GetBounds
Rect GetBounds() const override
Definition: path_source.cc:19
impeller::RectPathSource::~RectPathSource
~RectPathSource()
impeller::RectPathSource::Dispatch
void Dispatch(PathReceiver &receiver) const override
Definition: path_source.cc:23
impeller
Definition: allocation.cc:12
impeller::Scalar
float Scalar
Definition: scalar.h:19
impeller::kSqrt2Over2
constexpr float kSqrt2Over2
Definition: constants.h:51
impeller::FillType
FillType
Definition: path_source.h:13
impeller::FillType::kNonZero
@ kNonZero
impeller::Point
TPoint< Scalar > Point
Definition: point.h:425
path_source.h
impeller::TPoint< Scalar >
impeller::TPoint::y
Type y
Definition: point.h:32
impeller::TPoint::x
Type x
Definition: point.h:31
impeller::TRect< Scalar >
impeller::TRect::GetBottom
constexpr auto GetBottom() const
Definition: rect.h:357
impeller::TRect::GetTop
constexpr auto GetTop() const
Definition: rect.h:353
impeller::TRect::GetLeft
constexpr auto GetLeft() const
Definition: rect.h:351
impeller::TRect::GetRight
constexpr auto GetRight() const
Definition: rect.h:355
impeller::TRect::GetLeftBottom
constexpr TPoint< T > GetLeftBottom() const
Definition: rect.h:367
impeller::TRect::GetRightTop
constexpr TPoint< T > GetRightTop() const
Definition: rect.h:363
impeller::TRect::GetRightBottom
constexpr TPoint< T > GetRightBottom() const
Definition: rect.h:371
impeller::TRect::GetCenter
constexpr Point GetCenter() const
Get the center point as a |Point|.
Definition: rect.h:382
impeller::TRect::GetLeftTop
constexpr TPoint< T > GetLeftTop() const
Definition: rect.h:359