From 0ccba97ebec0e0c5a20f8859ebac03d5fd14c97f Mon Sep 17 00:00:00 2001 From: Eino-Ville Talvala Date: Tue, 29 Jul 2014 11:16:17 -0700 Subject: Camera2: Fix transforms for front-facing cameras Mirror, mirror on the wall, who is the best rotated of them all? Also, use consistent enum names. Bug: 16637957 Change-Id: Ie211d3b57b9e7d01122192ad03b73ceba5bf1bd3 --- camera/CameraUtils.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'camera') diff --git a/camera/CameraUtils.cpp b/camera/CameraUtils.cpp index 3ff181d..1ff63ab 100644 --- a/camera/CameraUtils.cpp +++ b/camera/CameraUtils.cpp @@ -73,18 +73,25 @@ status_t CameraUtils::getRotationTransform(const CameraMetadata& staticInfo, return INVALID_OPERATION; } } else { + // Front camera needs to be horizontally flipped for + // mirror-like behavior. + // Note: Flips are applied before rotates. switch (orientation) { case 0: - flags = HAL_TRANSFORM_FLIP_H; + flags = NATIVE_WINDOW_TRANSFORM_FLIP_H; break; case 90: - flags = HAL_TRANSFORM_FLIP_H | HAL_TRANSFORM_ROT_90; + flags = NATIVE_WINDOW_TRANSFORM_FLIP_H | + NATIVE_WINDOW_TRANSFORM_ROT_270; break; case 180: - flags = HAL_TRANSFORM_FLIP_V; + flags = NATIVE_WINDOW_TRANSFORM_FLIP_H | + NATIVE_WINDOW_TRANSFORM_ROT_180; break; case 270: - flags = HAL_TRANSFORM_FLIP_V | HAL_TRANSFORM_ROT_90; + flags = NATIVE_WINDOW_TRANSFORM_FLIP_H | + NATIVE_WINDOW_TRANSFORM_ROT_90; + break; default: ALOGE("%s: Invalid HAL android.sensor.orientation value: %d", -- cgit v1.1