libcamera: geometry: Give constructors to Rectangle

Rectangle, unlike Size, has no constructor, requiring the users to
explicitly initialize the instances. This is error-prone, add
constructors.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
This commit is contained in:
Laurent Pinchart
2020-07-15 01:41:07 +03:00
parent 935aec66ae
commit 4f509caa8e
6 changed files with 41 additions and 19 deletions

View File

@@ -127,6 +127,21 @@ static inline bool operator!=(const SizeRange &lhs, const SizeRange &rhs)
}
struct Rectangle {
Rectangle()
: Rectangle(0, 0, 0, 0)
{
}
Rectangle(int xpos, int ypos, const Size &size)
: x(xpos), y(ypos), width(size.width), height(size.height)
{
}
Rectangle(int xpos, int ypos, unsigned int w, unsigned int h)
: x(xpos), y(ypos), width(w), height(h)
{
}
int x;
int y;
unsigned int width;