From d5446e9f327ab4eaef38249b0907f11fbf52be45 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Wed, 15 Jul 2020 12:55:17 +0300 Subject: libcamera: geometry: Provide in-place versions of the Size helpers Add alignDownTo(), alignUpTo(), boundTo() and expandTo() helper functions to the Size class. These are in-place versions of the existing alignedDownTo(), alignedUpTo(), boundedTo() and expandedTo() functions. The new helpers return a reference to the size, to allow chaining the functions. One can thus write size.alignDownTo(16, 16).alignUpTo(32, 32) .boundTo({ 40, 80 }).expandTo({ 16, 80 }); instead of size.alignDownTo(16, 16); size.alignUpTo(32, 32); size.boundTo({ 40, 80 }); size.expandTo({ 16, 80 }); Signed-off-by: Laurent Pinchart Reviewed-by: Jacopo Mondi Reviewed-by: Kieran Bingham --- src/libcamera/geometry.cpp | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) (limited to 'src') diff --git a/src/libcamera/geometry.cpp b/src/libcamera/geometry.cpp index 3a3784df..23181bde 100644 --- a/src/libcamera/geometry.cpp +++ b/src/libcamera/geometry.cpp @@ -61,6 +61,52 @@ const std::string Size::toString() const return std::to_string(width) + "x" + std::to_string(height); } +/** + * \fn Size::alignDownTo(unsigned int hAlignment, unsigned int vAlignment) + * \brief Align the size down horizontally and vertically in place + * \param[in] hAlignment Horizontal alignment + * \param[in] vAlignment Vertical alignment + * + * This functions rounds the width and height down to the nearest multiple of + * \a hAlignment and \a vAlignment respectively. + * + * \return A reference to this object + */ + +/** + * \fn Size::alignUpTo(unsigned int hAlignment, unsigned int vAlignment) + * \brief Align the size up horizontally and vertically in place + * \param[in] hAlignment Horizontal alignment + * \param[in] vAlignment Vertical alignment + * + * This functions rounds the width and height up to the nearest multiple of + * \a hAlignment and \a vAlignment respectively. + * + * \return A reference to this object + */ + +/** + * \fn Size::boundTo(const Size &bound) + * \brief Bound the size to \a bound in place + * \param[in] bound The maximum size + * + * This function sets the width and height to the minimum of this size and the + * \a bound size. + * + * \return A reference to this object + */ + +/** + * \fn Size::expandTo(const Size &expand) + * \brief Expand the size to \a expand + * \param[in] expand The minimum size + * + * This function sets the width and height to the maximum of this size and the + * \a expand size. + * + * \return A reference to this object + */ + /** * \fn Size::alignedDownTo(unsigned int hAlignment, unsigned int vAlignment) * \brief Align the size down horizontally and vertically -- cgit v1.2.1