Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
geometry.h
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#ifndef FLUTTER_SHELL_PLATFORM_COMMON_GEOMETRY_H_
6#define FLUTTER_SHELL_PLATFORM_COMMON_GEOMETRY_H_
7
8#include <cmath>
9
10namespace flutter {
11
12// A point in Cartesian space relative to a separately-maintained origin.
13class Point {
14 public:
15 Point() = default;
16 Point(double x, double y) : x_(x), y_(y) {}
17 Point(const Point& point) = default;
18 Point& operator=(const Point& other) = default;
19
20 double x() const { return x_; }
21 double y() const { return y_; }
22
23 bool operator==(const Point& other) const {
24 return x_ == other.x_ && y_ == other.y_;
25 }
26
27 private:
28 double x_ = 0.0;
29 double y_ = 0.0;
30};
31
32// A 2D floating-point size with non-negative dimensions.
33class Size {
34 public:
35 Size() = default;
36 Size(double width, double height)
37 : width_(std::fmax(0.0, width)), height_(std::fmax(0.0, height)) {}
38
39 Size(const Size& size) = default;
40 Size& operator=(const Size& other) = default;
41
42 double width() const { return width_; }
43 double height() const { return height_; }
44
45 bool operator==(const Size& other) const {
46 return width_ == other.width_ && height_ == other.height_;
47 }
48
49 private:
50 double width_ = 0.0;
51 double height_ = 0.0;
52};
53
54// A rectangle with position in Cartesian space specified relative to a
55// separately-maintained origin.
56class Rect {
57 public:
58 Rect() = default;
59 Rect(const Point& origin, const Size& size) : origin_(origin), size_(size) {}
60 Rect(const Rect& rect) = default;
61 Rect& operator=(const Rect& other) = default;
62
63 double left() const { return origin_.x(); }
64 double top() const { return origin_.y(); }
65 double right() const { return origin_.x() + size_.width(); }
66 double bottom() const { return origin_.y() + size_.height(); }
67 double width() const { return size_.width(); }
68 double height() const { return size_.height(); }
69 Point origin() const { return origin_; }
70 Size size() const { return size_; }
71
72 bool operator==(const Rect& other) const {
73 return origin_ == other.origin_ && size_ == other.size_;
74 }
75
76 private:
77 Point origin_;
78 Size size_;
79};
80
81} // namespace flutter
82
83#endif // FLUTTER_SHELL_PLATFORM_COMMON_GEOMETRY_H_
Point()=default
bool operator==(const Point &other) const
Definition geometry.h:23
Point & operator=(const Point &other)=default
Point(double x, double y)
Definition geometry.h:16
double x() const
Definition geometry.h:20
double y() const
Definition geometry.h:21
Point(const Point &point)=default
double bottom() const
Definition geometry.h:66
double right() const
Definition geometry.h:65
double top() const
Definition geometry.h:64
Rect & operator=(const Rect &other)=default
Size size() const
Definition geometry.h:70
double height() const
Definition geometry.h:68
double left() const
Definition geometry.h:63
Rect(const Point &origin, const Size &size)
Definition geometry.h:59
Point origin() const
Definition geometry.h:69
Rect(const Rect &rect)=default
double width() const
Definition geometry.h:67
Rect()=default
bool operator==(const Rect &other) const
Definition geometry.h:72
Size(const Size &size)=default
Size()=default
Size(double width, double height)
Definition geometry.h:36
double height() const
Definition geometry.h:43
bool operator==(const Size &other) const
Definition geometry.h:45
Size & operator=(const Size &other)=default
double width() const
Definition geometry.h:42
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
Definition switches.h:259
TPoint< Scalar > Point
Definition point.h:316
Definition ref_ptr.h:256