Flutter Engine
 
Loading...
Searching...
No Matches
flutter::DlPath Class Reference

#include <dl_path.h>

Inheritance diagram for flutter::DlPath:
impeller::PathSource

Public Member Functions

 DlPath ()
 
 DlPath (const SkPath &path)
 
 DlPath (const DlPath &path)=default
 
 DlPath (DlPath &&path)=default
 
DlPathoperator= (const DlPath &)=default
 
 ~DlPath () override=default
 
const SkPath & GetSkPath () const
 
void Dispatch (DlPathReceiver &receiver) const override
 
void WillRenderSkPath () const
 
DlPath WithOffset (const DlPoint offset) const
 
DlPath WithFillType (DlPathFillType type) const
 
bool IsEmpty () const
 
bool IsRect (DlRect *rect=nullptr, bool *is_closed=nullptr) const
 
bool IsOval (DlRect *bounds=nullptr) const
 
bool IsLine (DlPoint *start=nullptr, DlPoint *end=nullptr) const
 
bool IsRoundRect (DlRoundRect *rrect=nullptr) const
 
bool Contains (const DlPoint point) const
 
DlRect GetBounds () const override
 
DlPathFillType GetFillType () const override
 
bool operator== (const DlPath &other) const
 
bool IsVolatile () const
 
bool IsConvex () const override
 
DlPath operator+ (const DlPath &other) const
 
- Public Member Functions inherited from impeller::PathSource
virtual ~PathSource ()=default
 

Static Public Member Functions

static DlPath MakeRect (const DlRect &rect)
 
static DlPath MakeRectLTRB (DlScalar left, DlScalar top, DlScalar right, DlScalar bottom)
 
static DlPath MakeRectXYWH (DlScalar x, DlScalar y, DlScalar width, DlScalar height)
 
static DlPath MakeOval (const DlRect &bounds)
 
static DlPath MakeOvalLTRB (DlScalar left, DlScalar top, DlScalar right, DlScalar bottom)
 
static DlPath MakeCircle (const DlPoint center, DlScalar radius)
 
static DlPath MakeRoundRect (const DlRoundRect &rrect)
 
static DlPath MakeRoundRectXY (const DlRect &rect, DlScalar x_radius, DlScalar y_radius, bool counter_clock_wise=false)
 
static DlPath MakeRoundSuperellipse (const DlRoundSuperellipse &rse)
 
static DlPath MakeLine (const DlPoint a, const DlPoint b)
 
static DlPath MakePoly (const DlPoint pts[], int count, bool close, DlPathFillType fill_type=DlPathFillType::kNonZero)
 
static DlPath MakeArc (const DlRect &bounds, DlDegrees start, DlDegrees sweep, bool use_center)
 

Static Public Attributes

static constexpr uint32_t kMaxVolatileUses = 2
 

Detailed Description

Definition at line 19 of file dl_path.h.

Constructor & Destructor Documentation

◆ DlPath() [1/4]

flutter::DlPath::DlPath ( )
inline

Definition at line 59 of file dl_path.h.

59: data_(std::make_shared<Data>(SkPath())) {}

References flutter::Data().

Referenced by MakeArc(), MakeCircle(), MakeLine(), MakeOval(), MakeOvalLTRB(), MakePoly(), MakeRect(), MakeRectLTRB(), MakeRectXYWH(), MakeRoundRect(), MakeRoundRectXY(), operator+(), WithFillType(), and WithOffset().

◆ DlPath() [2/4]

flutter::DlPath::DlPath ( const SkPath &  path)
inlineexplicit

Definition at line 60 of file dl_path.h.

60: data_(std::make_shared<Data>(path)) {}
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
Definition switch_defs.h:52

References flutter::Data().

◆ DlPath() [3/4]

flutter::DlPath::DlPath ( const DlPath path)
default

◆ DlPath() [4/4]

flutter::DlPath::DlPath ( DlPath &&  path)
default

◆ ~DlPath()

flutter::DlPath::~DlPath ( )
overridedefault

References flutter::Data().

Member Function Documentation

◆ Contains()

bool flutter::DlPath::Contains ( const DlPoint  point) const

Definition at line 237 of file dl_path.cc.

237 {
238 return GetSkPath().contains(point.x, point.y);
239}
const SkPath & GetSkPath() const
Definition dl_path.cc:116

References GetSkPath(), impeller::TPoint< T >::x, and impeller::TPoint< T >::y.

◆ Dispatch()

void flutter::DlPath::Dispatch ( DlPathReceiver receiver) const
overridevirtual

Implements impeller::PathSource.

Definition at line 120 of file dl_path.cc.

120 {
121 const SkPath& path = data_->sk_path;
122 if (path.isEmpty()) {
123 return;
124 }
125
126 auto iterator = SkPath::Iter(path, false);
127
128 struct PathData {
129 union {
130 SkPoint points[4];
131 };
132 };
133
134 PathData data;
135
136 auto verb = SkPath::Verb::kDone_Verb;
137 do {
138 verb = iterator.next(data.points);
139 switch (verb) {
140 case SkPath::kMove_Verb:
141 receiver.MoveTo(ToDlPoint(data.points[0]), iterator.isClosedContour());
142 break;
143 case SkPath::kLine_Verb:
144 receiver.LineTo(ToDlPoint(data.points[1]));
145 break;
146 case SkPath::kQuad_Verb:
147 receiver.QuadTo(ToDlPoint(data.points[1]), ToDlPoint(data.points[2]));
148 break;
149 case SkPath::kConic_Verb:
150 if (!receiver.ConicTo(ToDlPoint(data.points[1]),
151 ToDlPoint(data.points[2]),
152 iterator.conicWeight())) {
153 ReduceConic(receiver, //
154 ToDlPoint(data.points[0]), //
155 ToDlPoint(data.points[1]), //
156 ToDlPoint(data.points[2]), //
157 iterator.conicWeight());
158 }
159 break;
160 case SkPath::kCubic_Verb:
161 receiver.CubicTo(ToDlPoint(data.points[1]), //
162 ToDlPoint(data.points[2]), //
163 ToDlPoint(data.points[3]));
164 break;
165 case SkPath::kClose_Verb:
166 receiver.Close();
167 break;
168 case SkPath::kDone_Verb:
169 break;
170 }
171 } while (verb != SkPath::Verb::kDone_Verb);
172}
const DlPoint & ToDlPoint(const SkPoint &point)
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot data
Definition switch_defs.h:36
std::vector< Point > points

References impeller::PathReceiver::Close(), impeller::PathReceiver::ConicTo(), impeller::PathReceiver::CubicTo(), flutter::data, impeller::PathReceiver::LineTo(), impeller::PathReceiver::MoveTo(), flutter::path, points, impeller::PathReceiver::QuadTo(), and flutter::ToDlPoint().

Referenced by flutter::ComplexityCalculatorHelper::CalculatePathComplexity().

◆ GetBounds()

◆ GetFillType()

DlPathFillType flutter::DlPath::GetFillType ( ) const
overridevirtual

Implements impeller::PathSource.

Definition at line 241 of file dl_path.cc.

241 {
242 return ToDlFillType(GetSkPath().getFillType());
243}

References GetSkPath().

Referenced by flutter::testing::TEST(), flutter::testing::TEST(), and flutter::testing::TEST().

◆ GetSkPath()

◆ IsConvex()

bool flutter::DlPath::IsConvex ( ) const
overridevirtual

Implements impeller::PathSource.

Definition at line 257 of file dl_path.cc.

257 {
258 return data_->sk_path.isConvex();
259}

Referenced by flutter::testing::TEST().

◆ IsEmpty()

bool flutter::DlPath::IsEmpty ( ) const

Definition at line 206 of file dl_path.cc.

206 {
207 return GetSkPath().isEmpty();
208}

References GetSkPath().

Referenced by flutter::testing::TEST(), and flutter::testing::TEST().

◆ IsLine()

bool flutter::DlPath::IsLine ( DlPoint start = nullptr,
DlPoint end = nullptr 
) const

Definition at line 218 of file dl_path.cc.

218 {
219 SkPoint sk_points[2];
220 if (GetSkPath().isLine(sk_points)) {
221 *start = ToDlPoint(sk_points[0]);
222 *end = ToDlPoint(sk_points[1]);
223 return true;
224 }
225 return false;
226}
const size_t start
const size_t end

References end, GetSkPath(), start, and flutter::ToDlPoint().

◆ IsOval()

bool flutter::DlPath::IsOval ( DlRect bounds = nullptr) const

Definition at line 214 of file dl_path.cc.

214 {
215 return GetSkPath().isOval(ToSkRect(bounds));
216}
const SkRect & ToSkRect(const DlRect &rect)

References GetSkPath(), and flutter::ToSkRect().

Referenced by flutter::testing::TEST(), and flutter::testing::TEST_F().

◆ IsRect()

bool flutter::DlPath::IsRect ( DlRect rect = nullptr,
bool *  is_closed = nullptr 
) const

Definition at line 210 of file dl_path.cc.

210 {
211 return GetSkPath().isRect(ToSkRect(rect), is_closed);
212}

References GetSkPath(), and flutter::ToSkRect().

Referenced by flutter::testing::TEST(), and flutter::testing::TEST_F().

◆ IsRoundRect()

bool flutter::DlPath::IsRoundRect ( DlRoundRect rrect = nullptr) const

Definition at line 228 of file dl_path.cc.

228 {
229 SkRRect sk_rrect;
230 bool ret = GetSkPath().isRRect(rrect ? &sk_rrect : nullptr);
231 if (rrect) {
232 *rrect = ToDlRoundRect(sk_rrect);
233 }
234 return ret;
235}
const DlRoundRect ToDlRoundRect(const SkRRect &rrect)

References GetSkPath(), and flutter::ToDlRoundRect().

Referenced by flutter::testing::TEST(), flutter::testing::TEST_F(), and flutter::testing::TEST_F().

◆ IsVolatile()

bool flutter::DlPath::IsVolatile ( ) const

Definition at line 253 of file dl_path.cc.

253 {
254 return GetSkPath().isVolatile();
255}

References GetSkPath().

Referenced by flutter::testing::TEST(), and flutter::testing::TEST_F().

◆ MakeArc()

DlPath flutter::DlPath::MakeArc ( const DlRect bounds,
DlDegrees  start,
DlDegrees  sweep,
bool  use_center 
)
static

Definition at line 101 of file dl_path.cc.

104 {
105 SkPath path;
106 if (use_center) {
107 path.moveTo(ToSkPoint(bounds.GetCenter()));
108 }
109 path.arcTo(ToSkRect(bounds), start.degrees, sweep.degrees, !use_center);
110 if (use_center) {
111 path.close();
112 }
113 return DlPath(path);
114}
const SkPoint & ToSkPoint(const DlPoint &point)

References impeller::Degrees::degrees, DlPath(), impeller::TRect< T >::GetCenter(), flutter::path, start, flutter::ToSkPoint(), flutter::ToSkRect(), and use_center.

Referenced by impeller::testing::MaskBlurVariantTest(), impeller::testing::TEST_P(), and impeller::testing::TEST_P().

◆ MakeCircle()

◆ MakeLine()

◆ MakeOval()

◆ MakeOvalLTRB()

DlPath flutter::DlPath::MakeOvalLTRB ( DlScalar  left,
DlScalar  top,
DlScalar  right,
DlScalar  bottom 
)
static

Definition at line 61 of file dl_path.cc.

64 {
65 return DlPath(SkPath::Oval(SkRect::MakeLTRB(left, top, right, bottom)));
66}

References DlPath().

Referenced by flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), and flutter::testing::TEST_F().

◆ MakePoly()

DlPath flutter::DlPath::MakePoly ( const DlPoint  pts[],
int  count,
bool  close,
DlPathFillType  fill_type = DlPathFillType::kNonZero 
)
static

Definition at line 93 of file dl_path.cc.

96 {
97 return DlPath(SkPath::Polygon({ToSkPoints(pts), count}, close,
98 ToSkFillType(fill_type)));
99}
const SkPoint * ToSkPoints(const DlPoint *points)

References DlPath(), and flutter::ToSkPoints().

Referenced by impeller::testing::TEST_P().

◆ MakeRect()

DlPath flutter::DlPath::MakeRect ( const DlRect rect)
static

Definition at line 39 of file dl_path.cc.

39 {
40 return DlPath(SkPath::Rect(ToSkRect(rect)));
41}

References DlPath(), and flutter::ToSkRect().

Referenced by flutter::testing::ReadbackResult(), flutter::testing::TEST(), impeller::testing::TEST(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), impeller::testing::TEST_P(), impeller::testing::TEST_P(), impeller::testing::TEST_P(), impeller::testing::TEST_P(), impeller::testing::TEST_P(), impeller::testing::TEST_P(), impeller::testing::TEST_P(), impeller::testing::TEST_P(), impeller::testing::TEST_P(), impeller::testing::TEST_P(), impeller::testing::TEST_P(), impeller::testing::TEST_P(), impeller::testing::TEST_P(), impeller::testing::TEST_P(), impeller::testing::TEST_P(), impeller::testing::TEST_P(), impeller::testing::TEST_P(), impeller::testing::TEST_P(), impeller::testing::TEST_P(), impeller::testing::TEST_P(), and impeller::testing::TEST_P().

◆ MakeRectLTRB()

◆ MakeRectXYWH()

DlPath flutter::DlPath::MakeRectXYWH ( DlScalar  x,
DlScalar  y,
DlScalar  width,
DlScalar  height 
)
static

Definition at line 50 of file dl_path.cc.

53 {
54 return DlPath(SkPath().addRect(SkRect::MakeXYWH(x, y, width, height)));
55}
int32_t x
double y
int32_t height
int32_t width

References DlPath(), height, width, x, and y.

Referenced by flutter::testing::MockRasterCache::AddMockPicture(), flutter::testing::TEST_F(), and impeller::testing::TEST_P().

◆ MakeRoundRect()

DlPath flutter::DlPath::MakeRoundRect ( const DlRoundRect rrect)
static

◆ MakeRoundRectXY()

DlPath flutter::DlPath::MakeRoundRectXY ( const DlRect rect,
DlScalar  x_radius,
DlScalar  y_radius,
bool  counter_clock_wise = false 
)
static

Definition at line 76 of file dl_path.cc.

79 {
80 return DlPath(SkPath::RRect(
81 ToSkRect(rect), x_radius, y_radius,
82 counter_clock_wise ? SkPathDirection::kCCW : SkPathDirection::kCW));
83}

References DlPath(), and flutter::ToSkRect().

Referenced by flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), impeller::testing::TEST_P(), and impeller::testing::TEST_P().

◆ MakeRoundSuperellipse()

DlPath flutter::DlPath::MakeRoundSuperellipse ( const DlRoundSuperellipse rse)
static

Definition at line 85 of file dl_path.cc.

85 {
86 return DlPathBuilder{}.AddRoundSuperellipse(rse).TakePath();
87}

References flutter::DlPathBuilder::AddRoundSuperellipse(), and flutter::DlPathBuilder::TakePath().

Referenced by impeller::testing::TEST_P().

◆ operator+()

DlPath flutter::DlPath::operator+ ( const DlPath other) const

Definition at line 261 of file dl_path.cc.

261 {
262 SkPath path = GetSkPath();
263 path.addPath(other.GetSkPath());
264 return DlPath(path);
265}

References DlPath(), GetSkPath(), and flutter::path.

◆ operator=()

DlPath & flutter::DlPath::operator= ( const DlPath )
default

◆ operator==()

bool flutter::DlPath::operator== ( const DlPath other) const

Definition at line 249 of file dl_path.cc.

249 {
250 return GetSkPath() == other.GetSkPath();
251}

References GetSkPath().

◆ WillRenderSkPath()

void flutter::DlPath::WillRenderSkPath ( ) const

Intent to render an SkPath multiple times will make the path non-volatile to enable caching in Skia. Calling this method before every rendering call that uses the SkPath will count down the uses and eventually reset the volatile flag.

See also
|kMaxVolatileUses|

Definition at line 174 of file dl_path.cc.

174 {
175 uint32_t count = data_->render_count;
176 if (count <= kMaxVolatileUses) {
177 if (count == kMaxVolatileUses) {
178 data_->sk_path.setIsVolatile(false);
179 }
180 data_->render_count = ++count;
181 }
182}
static constexpr uint32_t kMaxVolatileUses
Definition dl_path.h:21

References kMaxVolatileUses.

Referenced by flutter::ClipPathLayer::ApplyClip(), and flutter::testing::TEST().

◆ WithFillType()

DlPath flutter::DlPath::WithFillType ( DlPathFillType  type) const

Definition at line 196 of file dl_path.cc.

196 {
197 SkPathFillType sk_type = ToSkFillType(type);
198 if (data_->sk_path.getFillType() == sk_type) {
199 return *this;
200 }
201 SkPath path = data_->sk_path;
202 path.setFillType(sk_type);
203 return DlPath(path);
204}
GLenum type

References DlPath(), flutter::path, and type.

Referenced by flutter::testing::TEST_F().

◆ WithOffset()

DlPath flutter::DlPath::WithOffset ( const DlPoint  offset) const

Definition at line 184 of file dl_path.cc.

184 {
185 if (offset.IsZero()) {
186 return *this;
187 }
188 if (!offset.IsFinite()) {
189 return DlPath();
190 }
191 SkPath path = data_->sk_path;
192 path = path.offset(offset.x, offset.y);
193 return DlPath(path);
194}

References DlPath(), impeller::TPoint< T >::IsFinite(), impeller::TPoint< T >::IsZero(), flutter::path, impeller::TPoint< T >::x, and impeller::TPoint< T >::y.

Member Data Documentation

◆ kMaxVolatileUses

constexpr uint32_t flutter::DlPath::kMaxVolatileUses = 2
staticconstexpr

The documentation for this class was generated from the following files: