From patchwork Tue Apr 19 12:42:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hanlin Chen X-Patchwork-Id: 15684 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 2D2D9C0F1B for ; Tue, 19 Apr 2022 12:42:29 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 7A91265642; Tue, 19 Apr 2022 14:42:28 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1650372148; bh=FtZApUuuaGBA1nv/G4tob3dmLouKS6gzFFhI4YzbMiI=; h=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=Wo/Jw+W4FkkEUQehPA2GxrIQ8OX1Z7y7PwJYqwjgVm8FwT+kSgwHhgjHAgRfWZbB0 yMWXpMCKEo8imqXmLWN+g920Xk84seKxkmXIAbsSR9dAdqguCQfFWQ0jhIgb0RdIqh M0+ldOpLlbUkqaHT9SxIBNbkGO9quDIRsRro074AGx1qgrzFzAemT1oWL5CoIKdcf/ o+YBSbiL0EwKzAavaiQBkmY+OqFf4631UMaITYjFCqL+XkuQww3szqihLe6T3woEzi F/Ls1Z7KWzHLWUHr5HUgD5uHW7QRjpLYeMxnD9B3FCJkMo00Huc9GxlGIcIN40GHfh q5pZp/ZLoFLRg== Received: from mail-pg1-x536.google.com (mail-pg1-x536.google.com [IPv6:2607:f8b0:4864:20::536]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 798176563C for ; Tue, 19 Apr 2022 14:42:27 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="KmaAvhAj"; dkim-atps=neutral Received: by mail-pg1-x536.google.com with SMTP id h5so23478372pgc.7 for ; Tue, 19 Apr 2022 05:42:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=1PyDkodJrR+yZb5khfd49jr5/l6XJ9CiLBElYg2JRGM=; b=KmaAvhAjk5pzyiPLvyprg4R6AjIKptti/tXQ40Af+3KK9O4YfQ6FpFeh2GfXTrh3yF PZFe3eCgetBbJYf3tPYsDY77CUezg4MO+wOqpl9SQ2dsgaMHnWs2PzXy5KHuTQ0seLWm WXNYx5bbM2G5OorsZW3f6kaCTQbfwJe1qTqs0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=1PyDkodJrR+yZb5khfd49jr5/l6XJ9CiLBElYg2JRGM=; b=wpAzoaRhui+vTeQ1W7VBZcduTrS44rT+/fDrP8hIUvfaA1AGUyLUv99dVfHnkcemmW HTOuMUiNAVFvRFtEGTx/9rcp/EfhmDZ4anUjsWtwVVcsuF/By2zo6i1czCaCwHLvllI6 2hsGrsyDG9hFg88oP/z/m3ShzCUSz46jrgngcFzIPFV0OQwqvm12Tf/bGOKn6j+l6F1l s+3Leco0lexSuR0QE1088VW1yTplFZ5bMqbuKq36FW99eFa0gK2rEST2payGI6eG6BT3 WMSlKuQdhtHA5TBKu5oPp6ZM0VXc6UyplgPOlLu90Ws5Ljs4K2IHQDfvrK2HSDytg6f7 +dYA== X-Gm-Message-State: AOAM531/gQxiVkXkQ7/X3g50VcKPVlw0IILM9xHucha+F/e6rE4RV2fi n2Jy3kGk9KpFuaOiWxmaqqIqawzLKkwlSA== X-Google-Smtp-Source: ABdhPJy1kLvunGW2kHFahqXkvZyBihZSq/oF+OT9mfpfyIIRwN8d9Kg0ywwvejT8T6pyxpKL30FVKQ== X-Received: by 2002:a05:6a00:1702:b0:50a:8181:fed3 with SMTP id h2-20020a056a00170200b0050a8181fed3mr7567635pfc.60.1650372145575; Tue, 19 Apr 2022 05:42:25 -0700 (PDT) Received: from localhost ([2401:fa00:1:17:4ede:fa5e:4144:1dec]) by smtp.gmail.com with UTF8SMTPSA id h18-20020a63c012000000b0039cc3c323f7sm16379511pgg.33.2022.04.19.05.42.24 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 19 Apr 2022 05:42:25 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Tue, 19 Apr 2022 20:42:19 +0800 Message-Id: <20220419124220.1877877-1-hanlinchen@chromium.org> X-Mailer: git-send-email 2.36.0.rc0.470.gd361397f0d-goog MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 1/2] libcamera: Add operator<< for classes in geometry 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: , X-Patchwork-Original-From: Han-Lin Chen via libcamera-devel From: Hanlin Chen Reply-To: Han-Lin Chen Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add operator<< for geometry classes for easier logging. Signed-off-by: Han-Lin Chen Reviewed-by: Kieran Bingham Reviewed-by: Laurent Pinchart Reviewed-by: Paul Elder --- include/libcamera/geometry.h | 8 +++++ src/libcamera/geometry.cpp | 65 +++++++++++++++++++++++++++++++----- 2 files changed, 65 insertions(+), 8 deletions(-) diff --git a/include/libcamera/geometry.h b/include/libcamera/geometry.h index 7838b679..d4a144bc 100644 --- a/include/libcamera/geometry.h +++ b/include/libcamera/geometry.h @@ -46,6 +46,8 @@ static inline bool operator!=(const Point &lhs, const Point &rhs) return !(lhs == rhs); } +std::ostream &operator<<(std::ostream &out, const Point &p); + class Size { public: @@ -192,6 +194,8 @@ static inline bool operator>=(const Size &lhs, const Size &rhs) return !(lhs < rhs); } +std::ostream &operator<<(std::ostream &out, const Size &s); + class SizeRange { public: @@ -232,6 +236,8 @@ static inline bool operator!=(const SizeRange &lhs, const SizeRange &rhs) return !(lhs == rhs); } +std::ostream &operator<<(std::ostream &out, const SizeRange &sr); + class Rectangle { public: @@ -291,4 +297,6 @@ static inline bool operator!=(const Rectangle &lhs, const Rectangle &rhs) return !(lhs == rhs); } +std::ostream &operator<<(std::ostream &out, const Rectangle &r); + } /* namespace libcamera */ diff --git a/src/libcamera/geometry.cpp b/src/libcamera/geometry.cpp index cb3c2de1..da08045e 100644 --- a/src/libcamera/geometry.cpp +++ b/src/libcamera/geometry.cpp @@ -56,8 +56,7 @@ namespace libcamera { const std::string Point::toString() const { std::stringstream ss; - - ss << "(" << x << "," << y << ")"; + ss << *this; return ss.str(); } @@ -83,6 +82,18 @@ bool operator==(const Point &lhs, const Point &rhs) * \return True if the two points are not equal, false otherwise */ +/** + * \brief Insert a text representation of a Point into an output stream + * \param[in] out The output stream + * \param[in] p The point + * \return The output stream \a out + */ +std::ostream &operator<<(std::ostream &out, const Point &p) +{ + out << "(" << p.x << ", " << p.y << ")"; + return out; +} + /** * \struct Size * \brief Describe a two-dimensional size @@ -124,7 +135,10 @@ bool operator==(const Point &lhs, const Point &rhs) */ const std::string Size::toString() const { - return std::to_string(width) + "x" + std::to_string(height); + std::stringstream ss; + ss << *this; + + return ss.str(); } /** @@ -428,6 +442,18 @@ bool operator<(const Size &lhs, const Size &rhs) * \sa bool operator<(const Size &lhs, const Size &rhs) */ +/** + * \brief Insert a text representation of a Size into an output stream + * \param[in] out The output stream + * \param[in] sr The size + * \return The output stream \a out + */ +std::ostream &operator<<(std::ostream &out, const Size &s) +{ + out << s.width << "x" << s.height; + return out; +} + /** * \struct SizeRange * \brief Describe a range of sizes @@ -528,9 +554,7 @@ bool SizeRange::contains(const Size &size) const std::string SizeRange::toString() const { std::stringstream ss; - - ss << "(" << min.toString() << ")-(" << max.toString() << ")/(+" - << hStep << ",+" << vStep << ")"; + ss << *this; return ss.str(); } @@ -550,6 +574,20 @@ bool operator==(const SizeRange &lhs, const SizeRange &rhs) * \return True if the two size ranges are not equal, false otherwise */ +/** + * \brief Insert a text representation of a SizeRange into an output stream + * \param[in] out The output stream + * \param[in] sr The size range + * \return The output stream \a out + */ +std::ostream &operator<<(std::ostream &out, const SizeRange &sr) +{ + out << "(" << sr.min << ")-(" << sr.max << ")/(+" + << sr.hStep << ",+" << sr.vStep << ")"; + + return out; +} + /** * \struct Rectangle * \brief Describe a rectangle's position and dimensions @@ -624,8 +662,7 @@ bool operator==(const SizeRange &lhs, const SizeRange &rhs) const std::string Rectangle::toString() const { std::stringstream ss; - - ss << "(" << x << "x" << y << ")/" << width << "x" << height; + ss << *this; return ss.str(); } @@ -796,4 +833,16 @@ bool operator==(const Rectangle &lhs, const Rectangle &rhs) * \return True if the two rectangles are not equal, false otherwise */ +/** + * \brief Insert a text representation of a Rectangle into an output stream + * \param[in] out The output stream + * \param[in] r The rectangle + * \return The output stream \a out + */ +std::ostream &operator<<(std::ostream &out, const Rectangle &r) +{ + out << "(" << r.x << "x" << r.y << ")/" << r.width << "x" << r.height; + return out; +} + } /* namespace libcamera */ From patchwork Tue Apr 19 12:42:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hanlin Chen X-Patchwork-Id: 15685 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 54704C0F1B for ; Tue, 19 Apr 2022 12:42:31 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 196576563D; Tue, 19 Apr 2022 14:42:31 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1650372151; bh=GnUToFRsalgnIk2d8jhuDJHVeRd9SCZtB/4535fLoBo=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=4PdRq36lFsMbrUewSRaud/eESPHC13n5mqs1Qadhq7wEbHEU/y46EyyLEuN7db3Dv u9nADuLsyFPr+qaJhVCpeKwwd9vXC1IkEl4Sku5n5ilCUx4zIie2aqVxpVthZWOaAm F6rm1k713/LZnHU0keVNHoj7CzBQ8ZbccYItYXKib37Pkt83zdy7lCfPBqlVmRevjS UkmygvSa6c7ASokZJ4zQIPzhqiKIbc5L1h8bTnnkiUEU5Gxx+pqp1q02WA+bs31XY8 w4c3vH7pAMdofsxB8px4OW0Xaxxar7+rQZtFeLPljFJYm/XxZwRc2b++8kyEm7Ef69 fYsIdxtvNSK1Q== Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 6B3776563D for ; Tue, 19 Apr 2022 14:42:29 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="GKwFwWaY"; dkim-atps=neutral Received: by mail-pl1-x636.google.com with SMTP id n18so15631641plg.5 for ; Tue, 19 Apr 2022 05:42:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=scw51YVqi4jrkxHTgyXesQdq6yqpX+vW3fLLFA/09WE=; b=GKwFwWaYi1qEr6Eled4ysieuUTvNUbKBRIl9KUS1AWuHLSDcooUtP4RIEMgXytvwuq DhD04EfiV63jncU4jAP5tAIYzi+zsl+sNNUyrcf2ng5Hzp9Qn6UZftYDfgjvTF6L4NKd SpyhjE4WdGwlFdG9Q1j68OdpW+LI3N0czx9l0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=scw51YVqi4jrkxHTgyXesQdq6yqpX+vW3fLLFA/09WE=; b=HZNJFIi5CZM0NwxmP9tzQj8n1n35FG7kKUJM9IP7JWUupnFzhOWV1TyP/U1dNRMjkZ 7qBSrLRC8tcCFM+YOd639XRqwxgpygfAuIG6UzD1ioMTxgw7Y9Oew2MJnJ8czJmUYSs4 DOfI8VDjv1Kqtbq1wrW73Rimb+iDyJ8I96dY3/4NYqYljZuVeNec2YP2610/CHuqG7ap So3/9z0CMVPt3hyZ3vlp7jidt/pnuy0I+hebr1SryR4O56frniH3a26ieFH3y9TKtUZd 1be7ICjhtaPnY4O4frS86h4xnxGzjlAqoSPbRu/xV6ZiR9ol+31H9yuw6/UIJg7AAITm F0cw== X-Gm-Message-State: AOAM5314N1kvFSiUiDvP7o940eFuR5vGKqTjR5X9igAVWmWH8/TXo/zx lyJh+INR7a7tCn1fRv5renOg/UZHrMBk6g== X-Google-Smtp-Source: ABdhPJxLY8UO057yudhsSexYDgfUN4Xmpv4L25qrvd0AUpIwwL2aDABHlRFp48UyIgmKpQbURkX63Q== X-Received: by 2002:a17:902:778a:b0:158:da0f:f299 with SMTP id o10-20020a170902778a00b00158da0ff299mr15253542pll.29.1650372147886; Tue, 19 Apr 2022 05:42:27 -0700 (PDT) Received: from localhost ([2401:fa00:1:17:4ede:fa5e:4144:1dec]) by smtp.gmail.com with UTF8SMTPSA id 96-20020a17090a09e900b001cb62ee05besm19682789pjo.55.2022.04.19.05.42.26 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 19 Apr 2022 05:42:27 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Tue, 19 Apr 2022 20:42:20 +0800 Message-Id: <20220419124220.1877877-2-hanlinchen@chromium.org> X-Mailer: git-send-email 2.36.0.rc0.470.gd361397f0d-goog In-Reply-To: <20220419124220.1877877-1-hanlinchen@chromium.org> References: <20220419124220.1877877-1-hanlinchen@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 2/2] libcamera: correct the string representation of Rectangle 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: , X-Patchwork-Original-From: Han-Lin Chen via libcamera-devel From: Hanlin Chen Reply-To: Han-Lin Chen Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Change the string representation of class Rectangle from "(top x left)/width x height" to "(top, left)/width x height". Signed-off-by: Han-Lin Chen Reviewed-by: Laurent Pinchart Reviewed-by: Kieran Bingham Reviewed-by: Paul Elder --- src/libcamera/geometry.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libcamera/geometry.cpp b/src/libcamera/geometry.cpp index da08045e..e00333cf 100644 --- a/src/libcamera/geometry.cpp +++ b/src/libcamera/geometry.cpp @@ -841,7 +841,7 @@ bool operator==(const Rectangle &lhs, const Rectangle &rhs) */ std::ostream &operator<<(std::ostream &out, const Rectangle &r) { - out << "(" << r.x << "x" << r.y << ")/" << r.width << "x" << r.height; + out << "(" << r.x << ", " << r.y << ")/" << r.width << "x" << r.height; return out; }