[libcamera-devel] [PATCH v6 20/12] libcamera: transform: Fold transformToOrientation() in its only caller

Laurent Pinchart laurent.pinchart at ideasonboard.com
Mon Oct 23 00:41:58 CEST 2023


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 <laurent.pinchart at ideasonboard.com>
---
 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;
 }
 
 /**
-- 
Regards,

Laurent Pinchart



More information about the libcamera-devel mailing list