14 #include <libcamera/base/compiler.h> 28 constexpr
Point(
int xpos,
int ypos)
45 static inline bool operator!=(
const Point &lhs,
const Point &rhs)
60 constexpr
Size(
unsigned int w,
unsigned int h)
68 bool isNull()
const {
return !width && !height; }
73 width = width / hAlignment * hAlignment;
74 height = height / vAlignment * vAlignment;
80 width = (width + hAlignment - 1) / hAlignment * hAlignment;
81 height = (height + vAlignment - 1) / vAlignment * vAlignment;
87 width = std::min(width, bound.
width);
88 height = std::min(height, bound.
height);
94 width = std::max(width, expand.
width);
95 height = std::max(height, expand.
height);
101 width += margins.
width;
108 width = width > margins.
width ? width - margins.
width : 0;
109 height = height > margins.
height ? height - margins.
height : 0;
114 unsigned int vAlignment)
const 117 width / hAlignment * hAlignment,
118 height / vAlignment * vAlignment
123 unsigned int vAlignment)
const 126 (width + hAlignment - 1) / hAlignment * hAlignment,
127 (height + vAlignment - 1) / vAlignment * vAlignment
134 std::min(width, bound.
width),
135 std::min(height, bound.
height)
142 std::max(width, expand.
width),
143 std::max(height, expand.
height)
150 width + margins.
width,
158 width > margins.
width ? width - margins.
width : 0,
163 __nodiscard
Size boundedToAspectRatio(
const Size &ratio)
const;
164 __nodiscard
Size expandedToAspectRatio(
const Size &ratio)
const;
171 Size &operator*=(
float factor);
172 Size &operator/=(
float factor);
175 bool operator==(
const Size &lhs,
const Size &rhs);
178 static inline bool operator!=(
const Size &lhs,
const Size &rhs)
180 return !(lhs == rhs);
183 static inline bool operator<=(
const Size &lhs,
const Size &rhs)
185 return lhs < rhs || lhs == rhs;
188 static inline bool operator>(
const Size &lhs,
const Size &rhs)
190 return !(lhs <= rhs);
193 static inline bool operator>=(
const Size &lhs,
const Size &rhs)
209 : min(size), max(size), hStep(1), vStep(1)
214 : min(minSize), max(maxSize), hStep(1), vStep(1)
219 unsigned int hstep,
unsigned int vstep)
220 : min(minSize), max(maxSize), hStep(hstep), vStep(vstep)
224 bool contains(
const Size &size)
const;
237 return !(lhs == rhs);
246 : Rectangle(0, 0, 0, 0)
251 :
x(xpos),
y(ypos), width(size.width), height(size.height)
255 constexpr
Rectangle(
int xpos,
int ypos,
unsigned int w,
unsigned int h)
256 :
x(xpos),
y(ypos), width(w), height(h)
261 :
x(0),
y(0), width(size.width), height(size.height)
266 : Rectangle(std::min(point1.
x, point2.
x), std::min(point1.
y, point2.
y),
267 static_cast<unsigned int>(std::max(point1.
x, point2.
x)) -
268 static_cast<unsigned int>(std::min(point1.
x, point2.
x)),
269 static_cast<unsigned int>(std::max(point1.
y, point2.
y)) -
270 static_cast<unsigned int>(std::min(point1.
y, point2.
y)))
279 bool isNull()
const {
return !width && !height; }
282 Point center()
const;
286 return { width, height };
300 const Size &denominator)
const;
307 return !(lhs == rhs);
__nodiscard constexpr Size expandedTo(const Size &expand) const
Expand the size to expand.
Definition: geometry.h:139
constexpr Point operator-() const
Negate a Point by negating both its x and y coordinates.
Definition: geometry.h:38
bool operator==(const ColorSpace &lhs, const ColorSpace &rhs)
Compare color spaces for equality.
Definition: color_space.cpp:506
Point topLeft() const
Retrieve the coordinates of the top left corner of this Rectangle.
Definition: geometry.h:289
constexpr Rectangle(const Size &size)
Construct a Rectangle of size with its top left corner located at (0,0)
Definition: geometry.h:260
unsigned int vStep
The vertical step.
Definition: geometry.h:231
__nodiscard constexpr Size alignedUpTo(unsigned int hAlignment, unsigned int vAlignment) const
Align the size up horizontally and vertically.
Definition: geometry.h:122
Size & alignUpTo(unsigned int hAlignment, unsigned int vAlignment)
Align the size up horizontally and vertically in place.
Definition: geometry.h:78
Size & expandTo(const Size &expand)
Expand the size to expand.
Definition: geometry.h:92
SizeRange(const Size &size)
Construct a size range representing a single size.
Definition: geometry.h:208
Top-level libcamera namespace.
Definition: bound_method.h:15
unsigned int hStep
The horizontal step.
Definition: geometry.h:230
int y
The vertical coordinate of the rectangle's top-left corner.
Definition: geometry.h:275
SizeRange(const Size &minSize, const Size &maxSize, unsigned int hstep, unsigned int vstep)
Construct a size range with specified min, max and step.
Definition: geometry.h:218
constexpr Rectangle(int xpos, int ypos, unsigned int w, unsigned int h)
Construct a Rectangle with the given position and size.
Definition: geometry.h:255
Describe a point in two-dimensional space.
Definition: geometry.h:20
Describe a two-dimensional size.
Definition: geometry.h:52
SizeRange()
Construct a size range initialized to 0.
Definition: geometry.h:203
Transform operator/(const Orientation &o1, const Orientation &o2)
Return the Transform that applied to o2 gives o1.
Definition: transform.cpp:347
bool isNull() const
Check if the rectangle is null.
Definition: geometry.h:279
__nodiscard constexpr Size boundedTo(const Size &bound) const
Bound the size to bound.
Definition: geometry.h:131
int x
The horizontal coordinate of the rectangle's top-left corner.
Definition: geometry.h:274
Size & alignDownTo(unsigned int hAlignment, unsigned int vAlignment)
Align the size down horizontally and vertically in place.
Definition: geometry.h:71
bool isNull() const
Check if the size is null.
Definition: geometry.h:68
int x
The x-coordinate of the Point.
Definition: geometry.h:33
constexpr Rectangle()
Construct a Rectangle with all coordinates set to 0.
Definition: geometry.h:245
Size size() const
Retrieve the size of this rectangle.
Definition: geometry.h:284
bool operator<(const Size &lhs, const Size &rhs)
Compare sizes for smaller than order.
Definition: geometry.cpp:399
Describe a rectangle's position and dimensions.
Definition: geometry.h:242
constexpr Point(int xpos, int ypos)
Construct a Point at given xpos and ypos values.
Definition: geometry.h:28
Transform operator*(Transform t0, Transform t1)
Compose two transforms by applying t0 first then t1.
Definition: transform.cpp:209
Size & growBy(const Size &margins)
Grow the size by margins in place.
Definition: geometry.h:99
Size & shrinkBy(const Size &margins)
Shrink the size by margins in place.
Definition: geometry.h:106
unsigned int width
The Size width.
Definition: geometry.h:65
__nodiscard constexpr Size grownBy(const Size &margins) const
Grow the size by margins.
Definition: geometry.h:147
constexpr Size()
Construct a Size with width and height set to 0.
Definition: geometry.h:55
Size & boundTo(const Size &bound)
Bound the size to bound in place.
Definition: geometry.h:85
Size min
The minimum size.
Definition: geometry.h:228
unsigned int height
The Size height.
Definition: geometry.h:66
constexpr Size(unsigned int w, unsigned int h)
Construct a Size with given width and height.
Definition: geometry.h:60
std::ostream & operator<<(std::ostream &out, const Point &p)
Insert a text representation of a Point into an output stream.
Definition: geometry.cpp:91
SizeRange(const Size &minSize, const Size &maxSize)
Construct a size range with specified min and max, and steps of 1.
Definition: geometry.h:213
Describe a range of sizes.
Definition: geometry.h:200
const std::string toString() const
Assemble and return a string describing the point.
Definition: geometry.cpp:56
unsigned int width
The distance between the left and right sides.
Definition: geometry.h:276
constexpr Rectangle(const Point &point1, const Point &point2)
Construct a Rectangle from two opposite corners.
Definition: geometry.h:265
constexpr Point()
Construct a Point with x and y set to 0.
Definition: geometry.h:23
constexpr Rectangle(int xpos, int ypos, const Size &size)
Construct a Rectangle with the given position and size.
Definition: geometry.h:250
unsigned int height
The distance between the top and bottom sides.
Definition: geometry.h:277
__nodiscard constexpr Size alignedDownTo(unsigned int hAlignment, unsigned int vAlignment) const
Align the size down horizontally and vertically.
Definition: geometry.h:113
__nodiscard constexpr Size shrunkBy(const Size &margins) const
Shrink the size by margins.
Definition: geometry.h:155
int y
The y-coordinate of the Point.
Definition: geometry.h:34
Size max
The maximum size.
Definition: geometry.h:229