25 {
26 using Type = T;
27
30
31 constexpr TSize() {}
32
34
35 constexpr explicit TSize(Type dimension)
37
38 template <class U>
39 explicit constexpr TSize(const TSize<U>& other)
40 : TSize(static_cast<Type>(other.
width), static_cast<Type>(other.
height)) {
41 }
42
43 static constexpr TSize MakeWH(Type
width, Type
height) {
45 }
46
47 static constexpr TSize Infinite() {
48 return TSize{std::numeric_limits<Type>::max(),
49 std::numeric_limits<Type>::max()};
50 }
51
52 constexpr TSize
operator*(Scalar scale)
const {
54 }
55
56 template <class U, class = std::enable_if_t<std::is_arithmetic_v<U>>>
57 inline TSize operator*=(U scale) {
58 width *=
static_cast<Type
>(scale);
59 height *=
static_cast<Type
>(scale);
60 return *this;
61 }
62
63 constexpr TSize
operator/(Scalar scale)
const {
66 }
67
68 constexpr TSize
operator/(
const TSize& s)
const {
70 }
71
72 constexpr bool operator==(
const TSize& s)
const {
74 }
75
76 constexpr bool operator!=(
const TSize& s)
const {
78 }
79
80 constexpr TSize
operator+(
const TSize& s)
const {
82 }
83
84 constexpr TSize
operator-(
const TSize& s)
const {
86 }
87
89
90 constexpr TSize Min(const TSize& o) const {
91 return {
92 std::min(
width, o.width),
93 std::min(
height, o.height),
94 };
95 }
96
97 constexpr TSize Max(const TSize& o) const {
98 return {
99 std::max(
width, o.width),
100 std::max(
height, o.height),
101 };
102 }
103
104 constexpr Type MinDimension()
const {
return std::min(
width,
height); }
105
106 constexpr Type MaxDimension()
const {
return std::max(
width,
height); }
107
108 constexpr TSize Abs()
const {
return {std::fabs(
width), std::fabs(
height)}; }
109
110 constexpr TSize Floor() const {
112 }
113
114 constexpr TSize Ceil()
const {
return {std::ceil(
width), std::ceil(
height)}; }
115
116 constexpr TSize Round() const {
118 }
119
120 constexpr Type Area()
const {
return width *
height; }
121
122
123 constexpr bool IsEmpty()
const {
return !(
width > 0 &&
height > 0); }
124
126 IsFinite()
const {
return std::isfinite(
width) && std::isfinite(
height); }
127
128 constexpr bool IsSquare()
const {
return width ==
height; }
129
130 template <class U>
131 static constexpr TSize Ceil(const TSize<U>& other) {
132 return TSize{static_cast<Type>(std::ceil(other.width)),
133 static_cast<Type>(std::ceil(other.height))};
134 }
135
136
137 constexpr size_t MipCount() const {
138 constexpr size_t minimum_mip = 1u;
140 return minimum_mip;
141 }
142 size_t result = std::min(log2(
width), log2(
height));
143 return std::max(result, minimum_mip);
144 }
145};
146
147
148
149template <class T, class U, class = std::enable_if_t<std::is_arithmetic_v<U>>>
150constexpr TSize<T>
operator*(U s,
const TSize<T>& p) {
151 return p * s;
152}
153
154template <class T, class U, class = std::enable_if_t<std::is_arithmetic_v<U>>>
155constexpr TSize<T>
operator/(U s,
const TSize<T>& p) {
156 return {static_cast<T>(s) / p.width, static_cast<T>(s) / p.height};
157}
158
159using Size = TSize<Scalar>;
163
164static_assert(
sizeof(
Size) == 2 *
sizeof(Scalar));
165
166}
167
169
170template <class T>
171inline std::ostream&
operator<<(std::ostream& out,
174 return out;
175}
176
177}
178
179#endif
bool operator==(const FlutterPoint &a, const FlutterPoint &b)
#define ONLY_ON_FLOAT_M(Modifiers, Return)
bool operator!=(const T &value, const UniqueObject< T, Traits > &object)
constexpr Color operator-(T value, const Color &c)
constexpr Color operator/(T value, const Color &c)
constexpr Color operator+(T value, const Color &c)
constexpr Color operator*(T value, const Color &c)
std::ostream & operator<<(std::ostream &out, const impeller::Arc &a)