Message ID | 20250930122726.1837524-27-stefan.klug@ideasonboard.com |
---|---|
State | New |
Headers | show |
Series |
|
Related | show |
Quoting Stefan Klug (2025-09-30 13:26:47) > Add a transpose() function to size that applies the > Transformation::Transpose operation in the size. This is useful when > handling orientation adjustments. > Nice, that makes things clearer. This is simple - but these classes are well covered by the unit tests - so I think just a simple validation in there for this call would be worthwhile too to keep it consistent. Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> > Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com> > --- > include/libcamera/geometry.h | 6 ++++++ > src/libcamera/geometry.cpp | 10 ++++++++++ > 2 files changed, 16 insertions(+) > > diff --git a/include/libcamera/geometry.h b/include/libcamera/geometry.h > index d9378efeca8c..572a07e2cf92 100644 > --- a/include/libcamera/geometry.h > +++ b/include/libcamera/geometry.h > @@ -108,6 +108,12 @@ public: > return *this; > } > > + Size &transpose() > + { > + std::swap(width, height); > + return *this; > + } > + > [[nodiscard]] constexpr Size alignedDownTo(unsigned int hAlignment, > unsigned int vAlignment) const > { > diff --git a/src/libcamera/geometry.cpp b/src/libcamera/geometry.cpp > index de76d0c12a8c..2763967a6e57 100644 > --- a/src/libcamera/geometry.cpp > +++ b/src/libcamera/geometry.cpp > @@ -209,6 +209,16 @@ std::string Size::toString() const > * \return A reference to this object > */ > > +/** > + * \fn Size::transpose() > + * \brief Transpose the size in place > + * > + * This function swaps width and height of this size. This effectively applies > + * the \a Transform::Transpose transformation on this size. > + * > + * \return A reference to this object > + */ > + > /** > * \fn Size::alignedDownTo(unsigned int hAlignment, unsigned int vAlignment) > * \brief Align the size down horizontally and vertically > -- > 2.48.1 >
diff --git a/include/libcamera/geometry.h b/include/libcamera/geometry.h index d9378efeca8c..572a07e2cf92 100644 --- a/include/libcamera/geometry.h +++ b/include/libcamera/geometry.h @@ -108,6 +108,12 @@ public: return *this; } + Size &transpose() + { + std::swap(width, height); + return *this; + } + [[nodiscard]] constexpr Size alignedDownTo(unsigned int hAlignment, unsigned int vAlignment) const { diff --git a/src/libcamera/geometry.cpp b/src/libcamera/geometry.cpp index de76d0c12a8c..2763967a6e57 100644 --- a/src/libcamera/geometry.cpp +++ b/src/libcamera/geometry.cpp @@ -209,6 +209,16 @@ std::string Size::toString() const * \return A reference to this object */ +/** + * \fn Size::transpose() + * \brief Transpose the size in place + * + * This function swaps width and height of this size. This effectively applies + * the \a Transform::Transpose transformation on this size. + * + * \return A reference to this object + */ + /** * \fn Size::alignedDownTo(unsigned int hAlignment, unsigned int vAlignment) * \brief Align the size down horizontally and vertically
Add a transpose() function to size that applies the Transformation::Transpose operation in the size. This is useful when handling orientation adjustments. Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com> --- include/libcamera/geometry.h | 6 ++++++ src/libcamera/geometry.cpp | 10 ++++++++++ 2 files changed, 16 insertions(+)