geometry.h
Go to the documentation of this file.
/* SPDX-License-Identifier: LGPL-2.1-or-later */
/*
* Copyright (C) 2019, Google Inc.
*
* geometry.h - Geometry-related structure
*/
#ifndef __LIBCAMERA_GEOMETRY_H__
#define __LIBCAMERA_GEOMETRY_H__
#include <string>
namespace libcamera {
struct Rectangle {
int x;
int y;
unsigned int width;
unsigned int height;
const std::string toString() const;
};
bool operator==(const Rectangle &lhs, const Rectangle &rhs);
static inline bool operator!=(const Rectangle &lhs, const Rectangle &rhs)
{
return !(lhs == rhs);
}
struct Size {
Size()
: Size(0, 0)
{
}
Size(unsigned int w, unsigned int h)
: width(w), height(h)
{
}
unsigned int width;
unsigned int height;
bool isNull() const { return !width && !height; }
const std::string toString() const;
};
bool operator==(const Size &lhs, const Size &rhs);
bool operator<(const Size &lhs, const Size &rhs);
static inline bool operator!=(const Size &lhs, const Size &rhs)
{
return !(lhs == rhs);
}
static inline bool operator<=(const Size &lhs, const Size &rhs)
{
return lhs < rhs || lhs == rhs;
}
static inline bool operator>(const Size &lhs, const Size &rhs)
{
return !(lhs <= rhs);
}
static inline bool operator>=(const Size &lhs, const Size &rhs)
{
return !(lhs < rhs);
}
class SizeRange
{
public:
SizeRange()
: hStep(0), vStep(0)
{
}
SizeRange(const Size &size)
: min(size), max(size), hStep(1), vStep(1)
{
}
SizeRange(const Size &minSize, const Size &maxSize)
: min(minSize), max(maxSize), hStep(1), vStep(1)
{
}
SizeRange(const Size &minSize, const Size &maxSize,
unsigned int hstep, unsigned int vstep)
: min(minSize), max(maxSize), hStep(hstep), vStep(vstep)
{
}
bool contains(const Size &size) const;
std::string toString() const;
Size min;
Size max;
unsigned int hStep;
unsigned int vStep;
};
bool operator==(const SizeRange &lhs, const SizeRange &rhs);
static inline bool operator!=(const SizeRange &lhs, const SizeRange &rhs)
{
return !(lhs == rhs);
}
} /* namespace libcamera */
#endif /* __LIBCAMERA_GEOMETRY_H__ */
libcamera::SizeRange
Describe a range of sizes.
Definition: geometry.h:72
libcamera::SizeRange::SizeRange
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:89
libcamera::SizeRange::SizeRange
SizeRange(const Size &minSize, const Size &maxSize)
Construct a size range with specified min and max, and steps of 1.
Definition: geometry.h:84
libcamera::SizeRange::vStep
unsigned int vStep
The vertical step.
Definition: geometry.h:102
libcamera::SizeRange::SizeRange
SizeRange(const Size &size)
Construct a size range representing a single size.
Definition: geometry.h:79
libcamera::SizeRange::max
Size max
The maximum size.
Definition: geometry.h:100
libcamera::SizeRange::hStep
unsigned int hStep
The horizontal step.
Definition: geometry.h:101
libcamera::SizeRange::SizeRange
SizeRange()
Construct a size range initialized to 0.
Definition: geometry.h:74
libcamera::SizeRange::min
Size min
The minimum size.
Definition: geometry.h:99
libcamera::SizeRange::contains
bool contains(const Size &size) const
Test if a size is contained in the range.
Definition: geometry.cpp:273
libcamera::SizeRange::toString
std::string toString() const
Assemble and return a string describing the size range.
Definition: geometry.cpp:288
libcamera::operator==
bool operator==(const Rectangle &lhs, const Rectangle &rhs)
Compare rectangles for equality.
Definition: geometry.cpp:69
libcamera::Rectangle
Describe a rectangle's position and dimensions.
Definition: geometry.h:15
libcamera::Rectangle::y
int y
The vertical coordinate of the rectangle's top-left corner.
Definition: geometry.h:17
libcamera::Rectangle::height
unsigned int height
The distance between the top and bottom sides.
Definition: geometry.h:19
libcamera::Rectangle::toString
const std::string toString() const
Assemble and return a string describing the rectangle.
Definition: geometry.cpp:56
libcamera::Rectangle::width
unsigned int width
The distance between the left and right sides.
Definition: geometry.h:18
libcamera::Rectangle::x
int x
The horizontal coordinate of the rectangle's top-left corner.
Definition: geometry.h:16
libcamera::Size
Describe a two-dimensional size.
Definition: geometry.h:30
libcamera::Size::toString
const std::string toString() const
Assemble and return a string describing the size.
Definition: geometry.cpp:120
libcamera::Size::Size
Size()
Construct a Size with width and height set to 0.
Definition: geometry.h:31
libcamera::Size::width
unsigned int width
The Size width.
Definition: geometry.h:41
libcamera::Size::Size
Size(unsigned int w, unsigned int h)
Construct a Size with given width and height.
Definition: geometry.h:36
libcamera::Size::isNull
bool isNull() const
Check if the size is null.
Definition: geometry.h:44
libcamera::Size::height
unsigned int height
The Size height.
Definition: geometry.h:42