14#include <libcamera/base/compiler.h>
28 constexpr Point(
int xpos,
int ypos)
44bool operator==(
const Point &lhs,
const Point &rhs);
45static inline bool operator!=(
const Point &lhs,
const Point &rhs)
50std::ostream &
operator<<(std::ostream &out,
const Point &p);
60 constexpr Size(
unsigned int w,
unsigned int h)
80 width = (
width + hAlignment - 1) / hAlignment * hAlignment;
81 height = (
height + vAlignment - 1) / vAlignment * vAlignment;
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
175bool operator==(
const Size &lhs,
const Size &rhs);
176bool operator<(
const Size &lhs,
const Size &rhs);
178static inline bool operator!=(
const Size &lhs,
const Size &rhs)
180 return !(lhs == rhs);
183static inline bool operator<=(
const Size &lhs,
const Size &rhs)
185 return lhs < rhs || lhs == rhs;
188static inline bool operator>(
const Size &lhs,
const Size &rhs)
190 return !(lhs <= rhs);
193static inline bool operator>=(
const Size &lhs,
const Size &rhs)
198std::ostream &
operator<<(std::ostream &out,
const Size &s);
219 unsigned int hstep,
unsigned int vstep)
237 return !(lhs == rhs);
240std::ostream &
operator<<(std::ostream &out,
const SizeRange &sr);
255 constexpr Rectangle(
int xpos,
int ypos,
unsigned int w,
unsigned int h)
291 const Size &denominator)
const;
295bool operator==(
const Rectangle &lhs,
const Rectangle &rhs);
296static inline bool operator!=(
const Rectangle &lhs,
const Rectangle &rhs)
298 return !(lhs == rhs);
301std::ostream &
operator<<(std::ostream &out,
const Rectangle &r);
Describe a point in two-dimensional space.
Definition: geometry.h:21
int y
The y-coordinate of the Point.
Definition: geometry.h:34
constexpr Point()
Construct a Point with x and y set to 0.
Definition: geometry.h:23
constexpr Point operator-() const
Negate a Point by negating both its x and y coordinates.
Definition: geometry.h:38
int x
The x-coordinate of the Point.
Definition: geometry.h:33
constexpr Point(int xpos, int ypos)
Construct a Point at given xpos and ypos values.
Definition: geometry.h:28
const std::string toString() const
Assemble and return a string describing the point.
Definition: geometry.cpp:56
Describe a rectangle's position and dimensions.
Definition: geometry.h:243
Rectangle & scaleBy(const Size &numerator, const Size &denominator)
Apply a non-uniform rational scaling in place to this Rectangle.
Definition: geometry.cpp:702
int y
The vertical coordinate of the rectangle's top-left corner.
Definition: geometry.h:266
Point center() const
Retrieve the center point of this rectangle.
Definition: geometry.cpp:674
__nodiscard Rectangle translatedBy(const Point &point) const
Translate a Rectangle by the given amounts.
Definition: geometry.cpp:815
unsigned int height
The distance between the top and bottom sides.
Definition: geometry.h:268
constexpr Rectangle(const Size &size)
Construct a Rectangle of size with its top left corner located at (0,0)
Definition: geometry.h:260
constexpr Rectangle(int xpos, int ypos, const Size &size)
Construct a Rectangle with the given position and size.
Definition: geometry.h:250
const std::string toString() const
Assemble and return a string describing the rectangle.
Definition: geometry.cpp:662
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
Point topLeft() const
Retrieve the coordinates of the top left corner of this Rectangle.
Definition: geometry.h:280
__nodiscard Rectangle enclosedIn(const Rectangle &boundary) const
Enclose a Rectangle so as not to exceed another Rectangle.
Definition: geometry.cpp:772
bool isNull() const
Check if the rectangle is null.
Definition: geometry.h:270
unsigned int width
The distance between the left and right sides.
Definition: geometry.h:267
Rectangle & translateBy(const Point &point)
Translate this Rectangle in place by the given Point.
Definition: geometry.cpp:721
Size size() const
Retrieve the size of this rectangle.
Definition: geometry.h:275
constexpr Rectangle()
Construct a Rectangle with all coordinates set to 0.
Definition: geometry.h:245
int x
The horizontal coordinate of the rectangle's top-left corner.
Definition: geometry.h:265
__nodiscard Rectangle boundedTo(const Rectangle &bound) const
Calculate the intersection of this Rectangle with another.
Definition: geometry.cpp:741
__nodiscard Rectangle scaledBy(const Size &numerator, const Size &denominator) const
Apply a non-uniform rational scaling to this Rectangle.
Definition: geometry.cpp:796
Describe a range of sizes.
Definition: geometry.h:201
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
SizeRange(const Size &minSize, const Size &maxSize)
Construct a size range with specified min and max, and steps of 1.
Definition: geometry.h:213
unsigned int vStep
The vertical step.
Definition: geometry.h:231
SizeRange(const Size &size)
Construct a size range representing a single size.
Definition: geometry.h:208
Size max
The maximum size.
Definition: geometry.h:229
unsigned int hStep
The horizontal step.
Definition: geometry.h:230
SizeRange()
Construct a size range initialized to 0.
Definition: geometry.h:203
Size min
The minimum size.
Definition: geometry.h:228
bool contains(const Size &size) const
Test if a size is contained in the range.
Definition: geometry.cpp:539
std::string toString() const
Assemble and return a string describing the size range.
Definition: geometry.cpp:554
Describe a two-dimensional size.
Definition: geometry.h:53
Size & operator/=(float factor)
Scale this size down by the given factor in place.
Definition: geometry.cpp:372
constexpr __nodiscard Size shrunkBy(const Size &margins) const
Shrink the size by margins.
Definition: geometry.h:155
Size & alignUpTo(unsigned int hAlignment, unsigned int vAlignment)
Align the size up horizontally and vertically in place.
Definition: geometry.h:78
Size & shrinkBy(const Size &margins)
Shrink the size by margins in place.
Definition: geometry.h:106
const std::string toString() const
Assemble and return a string describing the size.
Definition: geometry.cpp:136
Size operator/(float factor) const
Scale size down by the given factor.
Definition: geometry.cpp:350
constexpr __nodiscard Size expandedTo(const Size &expand) const
Expand the size to expand.
Definition: geometry.h:139
constexpr Size()
Construct a Size with width and height set to 0.
Definition: geometry.h:55
constexpr __nodiscard Size alignedDownTo(unsigned int hAlignment, unsigned int vAlignment) const
Align the size down horizontally and vertically.
Definition: geometry.h:113
Size & boundTo(const Size &bound)
Bound the size to bound in place.
Definition: geometry.h:85
constexpr __nodiscard Size grownBy(const Size &margins) const
Grow the size by margins.
Definition: geometry.h:147
unsigned int width
The Size width.
Definition: geometry.h:65
Size & alignDownTo(unsigned int hAlignment, unsigned int vAlignment)
Align the size down horizontally and vertically in place.
Definition: geometry.h:71
__nodiscard Rectangle centeredTo(const Point ¢er) const
Center a rectangle of this size at a given Point.
Definition: geometry.cpp:327
constexpr Size(unsigned int w, unsigned int h)
Construct a Size with given width and height.
Definition: geometry.h:60
bool isNull() const
Check if the size is null.
Definition: geometry.h:68
Size & expandTo(const Size &expand)
Expand the size to expand.
Definition: geometry.h:92
constexpr __nodiscard Size boundedTo(const Size &bound) const
Bound the size to bound.
Definition: geometry.h:131
__nodiscard Size boundedToAspectRatio(const Size &ratio) const
Bound the size down to match the aspect ratio given by ratio.
Definition: geometry.cpp:278
__nodiscard Size expandedToAspectRatio(const Size &ratio) const
Expand the size to match the aspect ratio given by ratio.
Definition: geometry.cpp:303
Size operator*(float factor) const
Scale size up by the given factor.
Definition: geometry.cpp:340
constexpr __nodiscard Size alignedUpTo(unsigned int hAlignment, unsigned int vAlignment) const
Align the size up horizontally and vertically.
Definition: geometry.h:122
unsigned int height
The Size height.
Definition: geometry.h:66
Size & growBy(const Size &margins)
Grow the size by margins in place.
Definition: geometry.h:99
Size & operator*=(float factor)
Scale this size up by the given factor in place.
Definition: geometry.cpp:360
Top-level libcamera namespace.
Definition: backtrace.h:17
std::ostream & operator<<(std::ostream &out, const Point &p)
Insert a text representation of a Point into an output stream.
Definition: geometry.cpp:91
bool operator==(const ColorSpace &lhs, const ColorSpace &rhs)
Compare color spaces for equality.
Definition: color_space.cpp:506
bool operator<(const Size &lhs, const Size &rhs)
Compare sizes for smaller than order.
Definition: geometry.cpp:399