libcamera: geometry: SizeRange: Add contains()
Add a method to check if a Size can fit inside a SizeRange. When determining if a size is containable take step values into account if they are not set to 0. Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This commit is contained in:
@@ -92,6 +92,8 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
bool contains(const Size &size) const;
|
||||
|
||||
std::string toString() const;
|
||||
|
||||
Size min;
|
||||
|
||||
@@ -266,6 +266,22 @@ bool operator<(const Size &lhs, const Size &rhs)
|
||||
* \brief The vertical step
|
||||
*/
|
||||
|
||||
/**
|
||||
* \brief Test if a size is contained in the range
|
||||
* \param[in] size Size to check
|
||||
* \returns True if \a size is contained in the range
|
||||
*/
|
||||
bool SizeRange::contains(const Size &size) const
|
||||
{
|
||||
if (size.width < min.width || size.width > max.width ||
|
||||
size.height < min.height || size.height > max.height ||
|
||||
(hStep && (size.width - min.width) % hStep) ||
|
||||
(vStep && (size.height - min.height) % vStep))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Assemble and return a string describing the size range
|
||||
* \return A string describing the SizeRange
|
||||
|
||||
Reference in New Issue
Block a user