From patchwork Tue Jul 14 23:40:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 8802 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 64678BD792 for ; Tue, 14 Jul 2020 23:40:24 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 5F57960930; Wed, 15 Jul 2020 01:40:23 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="EXrnZLsq"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 09EAA60905 for ; Wed, 15 Jul 2020 01:40:21 +0200 (CEST) Received: from pendragon.bb.dnainternet.fi (81-175-216-236.bb.dnainternet.fi [81.175.216.236]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id A7AFB71D for ; Wed, 15 Jul 2020 01:40:20 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1594770020; bh=SqpJejNoNnCvoQwIv19jm7magFhcAcEfgNRiVJF4qcI=; h=From:To:Subject:Date:In-Reply-To:References:From; b=EXrnZLsqHXF+Fuo0xF+NdYl98ssrHZcoKRZXSM3U4ATGfcIm9WRUfbLJArKufpBr5 aYvD+2nThgHw4nv6PY2AqxpuNJ1NTMrSMvBRUn4n/ioaxPpjmiLNheTTb8kMFBy04m Qkic3JXCL8YwCn8WLdfGEGhQPzm/IcE5mPvcxDrE= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Wed, 15 Jul 2020 02:40:06 +0300 Message-Id: <20200714234009.16596-3-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200714234009.16596-1-laurent.pinchart@ideasonboard.com> References: <20200714234009.16596-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 2/5] libcamera: geometry: Define Rectangle after Size X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" 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 Reviewed-by: Niklas Söderlund --- 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 */