From patchwork Sun Oct 22 22:41:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 19176 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 7F9A3C327D for ; Sun, 22 Oct 2023 22:42:06 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E0FEF62985; Mon, 23 Oct 2023 00:42:03 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1698014523; bh=qAXR8TS9CNRCG9Mlbp+xkNxza2p3RXintc1ku3gVvQ0=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=XFNmw48/yQ33Nfk4mOExjphiIJrcgmRwCN39JUYYFM5DIMf5vVWQGTiD0lTrLSGRf FvdVP5Xbl85PUJIZEvEM4kPVo3wbrJ2ysfC4MkIObTIoRlsTyQFMAY3wbEi9arvazo 8Ri7zLNNkjApWc+2cXjp/zISjzww5M1ER73NXQjdh1PgyQ4Ad9ak9dQ9HlQz6wEvcv oZvhawjvlkUYW/Hk0Wh150FxIGP/+oUWbHgmhyqkMHC4DruQ3e1nYjcP59klr7l/p2 dnTT6QtiE0fhO9/t0+eRjNjpuP+i9Lr+SpNS+9Hal62yT+oDI2+S145eN9LzUSJ/8l TekAA4Jkf/GlQ== 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 00A596298D for ; Mon, 23 Oct 2023 00:42:00 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="JAfyinkf"; dkim-atps=neutral Received: from pendragon.ideasonboard.com (213-243-189-158.bb.dnainternet.fi [213.243.189.158]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 9A1B4D20; Mon, 23 Oct 2023 00:41:50 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1698014510; bh=qAXR8TS9CNRCG9Mlbp+xkNxza2p3RXintc1ku3gVvQ0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JAfyinkf8lDm1tSbfC3HYRdzeAgcI1tkEfw9rFQYKaOGNlMWQR/QBFpJ4Gfg5SJCq Udfpgn1uvlewh0HtBvY5fFxqEuVnVb0TvQIfpXwp3EKQEmvv9ZN9iB0icfpj3GYCG/ jJTUaOUMAZia6CkCoghrHjbeEciU14VojwL3h8Q0= To: libcamera-devel@lists.libcamera.org Date: Mon, 23 Oct 2023 01:41:58 +0300 Message-ID: <20231022224159.30298-8-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231019140133.32090-1-jacopo.mondi@ideasonboard.com> References: <20231019140133.32090-1-jacopo.mondi@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v6 20/12] libcamera: transform: Fold transformToOrientation() in its only caller 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: Laurent Pinchart via libcamera-devel From: Laurent Pinchart Reply-To: Laurent Pinchart Cc: Jacopo Mondi Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" The transformToOrientation() function is called from Orientation operator*(const Orientation &o, const Transform &t); only. Fold the code in the caller and drop the transformToOrientation() function to drop what can be considered as an ill-defined operation from the API. Signed-off-by: Laurent Pinchart --- include/libcamera/transform.h | 1 - src/libcamera/transform.cpp | 50 ++++++++++++++--------------------- 2 files changed, 20 insertions(+), 31 deletions(-) diff --git a/include/libcamera/transform.h b/include/libcamera/transform.h index 9eb10e156d0d..4998a6c04cb7 100644 --- a/include/libcamera/transform.h +++ b/include/libcamera/transform.h @@ -72,7 +72,6 @@ constexpr Transform operator~(Transform t) Transform transformFromRotation(int angle, bool *success = nullptr); Transform transformFromOrientation(const Orientation &orientation); -Orientation transformToOrientation(const Transform &transform); Transform operator/(const Orientation &o1, const Orientation &o2); Orientation operator*(const Orientation &o, const Transform &t); diff --git a/src/libcamera/transform.cpp b/src/libcamera/transform.cpp index 0ccdb42fa406..cd2717c28c3a 100644 --- a/src/libcamera/transform.cpp +++ b/src/libcamera/transform.cpp @@ -330,35 +330,6 @@ Transform transformFromOrientation(const Orientation &orientation) return Transform::Identity; } -/** - * \brief Return the Orientation representing \a transform - * \param[in] transform The transform to convert - * \return The Orientation corresponding to \a transform - */ -Orientation transformToOrientation(const Transform &transform) -{ - switch (transform) { - case Transform::Identity: - return Orientation::Rotate0; - case Transform::HFlip: - return Orientation::Rotate0Mirror; - case Transform::VFlip: - return Orientation::Rotate180Mirror; - case Transform::Rot180: - return Orientation::Rotate180; - case Transform::Transpose: - return Orientation::Rotate90Mirror; - case Transform::Rot270: - return Orientation::Rotate270; - case Transform::Rot90: - return Orientation::Rotate90; - case Transform::Rot180Transpose: - return Orientation::Rotate270Mirror; - } - - return Orientation::Rotate0; -} - /** * \brief Return the Transform that applied to \a o2 gives \a o1 * \param o1 The Orientation to obtain @@ -389,7 +360,26 @@ Orientation operator*(const Orientation &o, const Transform &t) * Apply a Transform corresponding to the orientation first and * then apply \a t to it. */ - return transformToOrientation(transformFromOrientation(o) * t); + switch (transformFromOrientation(o) * t) { + case Transform::Identity: + return Orientation::Rotate0; + case Transform::HFlip: + return Orientation::Rotate0Mirror; + case Transform::VFlip: + return Orientation::Rotate180Mirror; + case Transform::Rot180: + return Orientation::Rotate180; + case Transform::Transpose: + return Orientation::Rotate90Mirror; + case Transform::Rot270: + return Orientation::Rotate270; + case Transform::Rot90: + return Orientation::Rotate90; + case Transform::Rot180Transpose: + return Orientation::Rotate270Mirror; + } + + return Orientation::Rotate0; } /**