From 22e0005fdd4c1431ee412af7f80c2edfb323125e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niklas=20S=C3=B6derlund?= Date: Wed, 12 Jun 2019 01:07:52 +0200 Subject: libcamera: geometry: SizeRange: Add contains() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Laurent Pinchart --- src/libcamera/geometry.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/libcamera/geometry.cpp') diff --git a/src/libcamera/geometry.cpp b/src/libcamera/geometry.cpp index e598f6ad..32b0faea 100644 --- a/src/libcamera/geometry.cpp +++ b/src/libcamera/geometry.cpp @@ -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 -- cgit v1.2.1