From e229b35edff5aeb2dbe819ec7b4cf9816f90460a Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Wed, 13 Oct 2021 04:11:18 +0300 Subject: libcamera: geometry: Add Size members to grown or shrink by a margin Add four new member functions to the Size class (two in-place and two const) to grow and shrink a Size by given margins. Signed-off-by: Laurent Pinchart Reviewed-by: Jacopo Mondi --- src/libcamera/geometry.cpp | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'src') diff --git a/src/libcamera/geometry.cpp b/src/libcamera/geometry.cpp index b014180e..cb3c2de1 100644 --- a/src/libcamera/geometry.cpp +++ b/src/libcamera/geometry.cpp @@ -173,6 +173,28 @@ const std::string Size::toString() const * \return A reference to this object */ +/** + * \fn Size::growBy(const Size &margins) + * \brief Grow the size by \a margins in place + * \param[in] margins The margins to add to the size + * + * This function adds the width and height of the \a margin size to this size. + * + * \return A reference to this object + */ + +/** + * \fn Size::shrinkBy(const Size &margins) + * \brief Shrink the size by \a margins in place + * \param[in] margins The margins to subtract to the size + * + * This function subtracts the width and height of the \a margin size from this + * size. If the width or height of the size are smaller than those of \a + * margins, the result is clamped to 0. + * + * \return A reference to this object + */ + /** * \fn Size::alignedDownTo(unsigned int hAlignment, unsigned int vAlignment) * \brief Align the size down horizontally and vertically @@ -209,6 +231,26 @@ const std::string Size::toString() const * height of this size and the \a expand size */ +/** + * \fn Size::grownBy(const Size &margins) + * \brief Grow the size by \a margins + * \param[in] margins The margins to add to the size + * \return A Size whose width and height are the sum of the width and height of + * this size and the \a margins size + */ + +/** + * \fn Size::shrunkBy(const Size &margins) + * \brief Shrink the size by \a margins + * \param[in] margins The margins to subtract to the size + * + * If the width or height of the size are smaller than those of \a margins, the + * resulting size has its width or height clamped to 0. + * + * \return A Size whose width and height are the difference of the width and + * height of this size and the \a margins size, clamped to 0 + */ + /** * \brief Bound the size down to match the aspect ratio given by \a ratio * \param[in] ratio The size whose aspect ratio must be matched -- cgit v1.2.1