From b54c935dd764ac3348bcedb9ff67d53a26cfaceb Mon Sep 17 00:00:00 2001 From: Jacopo Mondi Date: Thu, 19 Oct 2023 16:01:27 +0200 Subject: libcamera: transform: Invert operator*() operands The current definition of operator*(Transform t1, Transform t0) follows the function composition notion, where t0 is applied first then t1 is applied last. In order to introduce operator*(Orientation, Transform) where a Transform is applied on top of an Orientation, invert the operand order of operator*(Transform, Transform) so that usage of operator* with both Orientation and Transform can be made associative. For example: Orientation o; Transform t = t1 * t2 Orientation o1 = o * t = o * (t1 * t2) = (o * t1) * t2 = o * t1 * t2 Signed-off-by: Jacopo Mondi Reviewed-by: David Plowman Signed-off-by: Laurent Pinchart --- src/libcamera/camera_sensor.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/libcamera/camera_sensor.cpp') diff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp index 8ff72b42..521a1997 100644 --- a/src/libcamera/camera_sensor.cpp +++ b/src/libcamera/camera_sensor.cpp @@ -1136,7 +1136,7 @@ Transform CameraSensor::validateTransform(Transform *transform) const * Combine the requested transform to compensate the sensor mounting * rotation. */ - Transform combined = *transform * rotationTransform_; + Transform combined = rotationTransform_ * *transform; /* * We combine the platform and user transform, but must "adjust away" @@ -1165,7 +1165,7 @@ Transform CameraSensor::validateTransform(Transform *transform) const * If the sensor can do no transforms, then combined must be * changed to the identity. The only user transform that gives * rise to this is the inverse of the rotation. (Recall that - * combined = transform * rotationTransform.) + * combined = rotationTransform * transform.) */ *transform = -rotationTransform_; combined = Transform::Identity; -- cgit v1.2.1