[libcamera-devel] [PATCH 2/5] libcamera: geometry: Define Rectangle after Size
Niklas Söderlund
niklas.soderlund at ragnatech.se
Wed Jul 15 08:21:40 CEST 2020
Hi Laurent,
Thanks for your work.
On 2020-07-15 02:40:06 +0300, Laurent Pinchart wrote:
> A subsequent change to the Rectangle will require the definition of the
> Size to be available. Define Rectangle after Size to ease review of that
> change. No code change is included.
>
> Signed-off-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
I like moving code around in their own commits :-)
Reviewed-by: Niklas Söderlund <niklas.soderlund at ragnatech.se>
> ---
> include/libcamera/geometry.h | 30 ++++-----
> src/libcamera/geometry.cpp | 122 +++++++++++++++++------------------
> 2 files changed, 76 insertions(+), 76 deletions(-)
>
> diff --git a/include/libcamera/geometry.h b/include/libcamera/geometry.h
> index d217cfd50c86..f3088d33fa2c 100644
> --- a/include/libcamera/geometry.h
> +++ b/include/libcamera/geometry.h
> @@ -13,21 +13,6 @@
>
> namespace libcamera {
>
> -struct Rectangle {
> - int x;
> - int y;
> - unsigned int width;
> - unsigned int height;
> -
> - const std::string toString() const;
> -};
> -
> -bool operator==(const Rectangle &lhs, const Rectangle &rhs);
> -static inline bool operator!=(const Rectangle &lhs, const Rectangle &rhs)
> -{
> - return !(lhs == rhs);
> -}
> -
> struct Size {
> Size()
> : Size(0, 0)
> @@ -141,6 +126,21 @@ static inline bool operator!=(const SizeRange &lhs, const SizeRange &rhs)
> return !(lhs == rhs);
> }
>
> +struct Rectangle {
> + int x;
> + int y;
> + unsigned int width;
> + unsigned int height;
> +
> + const std::string toString() const;
> +};
> +
> +bool operator==(const Rectangle &lhs, const Rectangle &rhs);
> +static inline bool operator!=(const Rectangle &lhs, const Rectangle &rhs)
> +{
> + return !(lhs == rhs);
> +}
> +
> } /* namespace libcamera */
>
> #endif /* __LIBCAMERA_GEOMETRY_H__ */
> diff --git a/src/libcamera/geometry.cpp b/src/libcamera/geometry.cpp
> index 4594f9ff435f..5a0bcf7c1e12 100644
> --- a/src/libcamera/geometry.cpp
> +++ b/src/libcamera/geometry.cpp
> @@ -17,67 +17,6 @@
>
> namespace libcamera {
>
> -/**
> - * \struct Rectangle
> - * \brief Describe a rectangle's position and dimensions
> - *
> - * Rectangles are used to identify an area of an image. They are specified by
> - * the coordinates of top-left corner and their horizontal and vertical size.
> - *
> - * The measure unit of the rectangle coordinates and size, as well as the
> - * reference point from which the Rectangle::x and Rectangle::y displacements
> - * refers to, are defined by the context were rectangle is used.
> - */
> -
> -/**
> - * \var Rectangle::x
> - * \brief The horizontal coordinate of the rectangle's top-left corner
> - */
> -
> -/**
> - * \var Rectangle::y
> - * \brief The vertical coordinate of the rectangle's top-left corner
> - */
> -
> -/**
> - * \var Rectangle::width
> - * \brief The distance between the left and right sides
> - */
> -
> -/**
> - * \var Rectangle::height
> - * \brief The distance between the top and bottom sides
> - */
> -
> -/**
> - * \brief Assemble and return a string describing the rectangle
> - * \return A string describing the Rectangle
> - */
> -const std::string Rectangle::toString() const
> -{
> - std::stringstream ss;
> -
> - ss << "(" << x << "x" << y << ")/" << width << "x" << height;
> -
> - return ss.str();
> -}
> -
> -/**
> - * \brief Compare rectangles for equality
> - * \return True if the two rectangles are equal, false otherwise
> - */
> -bool operator==(const Rectangle &lhs, const Rectangle &rhs)
> -{
> - return lhs.x == rhs.x && lhs.y == rhs.y &&
> - lhs.width == rhs.width && lhs.height == rhs.height;
> -}
> -
> -/**
> - * \fn bool operator!=(const Rectangle &lhs, const Rectangle &rhs)
> - * \brief Compare rectangles for inequality
> - * \return True if the two rectangles are not equal, false otherwise
> - */
> -
> /**
> * \struct Size
> * \brief Describe a two-dimensional size
> @@ -346,4 +285,65 @@ bool operator==(const SizeRange &lhs, const SizeRange &rhs)
> * \return True if the two size ranges are not equal, false otherwise
> */
>
> +/**
> + * \struct Rectangle
> + * \brief Describe a rectangle's position and dimensions
> + *
> + * Rectangles are used to identify an area of an image. They are specified by
> + * the coordinates of top-left corner and their horizontal and vertical size.
> + *
> + * The measure unit of the rectangle coordinates and size, as well as the
> + * reference point from which the Rectangle::x and Rectangle::y displacements
> + * refers to, are defined by the context were rectangle is used.
> + */
> +
> +/**
> + * \var Rectangle::x
> + * \brief The horizontal coordinate of the rectangle's top-left corner
> + */
> +
> +/**
> + * \var Rectangle::y
> + * \brief The vertical coordinate of the rectangle's top-left corner
> + */
> +
> +/**
> + * \var Rectangle::width
> + * \brief The distance between the left and right sides
> + */
> +
> +/**
> + * \var Rectangle::height
> + * \brief The distance between the top and bottom sides
> + */
> +
> +/**
> + * \brief Assemble and return a string describing the rectangle
> + * \return A string describing the Rectangle
> + */
> +const std::string Rectangle::toString() const
> +{
> + std::stringstream ss;
> +
> + ss << "(" << x << "x" << y << ")/" << width << "x" << height;
> +
> + return ss.str();
> +}
> +
> +/**
> + * \brief Compare rectangles for equality
> + * \return True if the two rectangles are equal, false otherwise
> + */
> +bool operator==(const Rectangle &lhs, const Rectangle &rhs)
> +{
> + return lhs.x == rhs.x && lhs.y == rhs.y &&
> + lhs.width == rhs.width && lhs.height == rhs.height;
> +}
> +
> +/**
> + * \fn bool operator!=(const Rectangle &lhs, const Rectangle &rhs)
> + * \brief Compare rectangles for inequality
> + * \return True if the two rectangles are not equal, false otherwise
> + */
> +
> } /* namespace libcamera */
> --
> Regards,
>
> Laurent Pinchart
>
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel at lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel
--
Regards,
Niklas Söderlund
More information about the libcamera-devel
mailing list