From 5698d4461a260dbf208484383f692b03c6473e74 Mon Sep 17 00:00:00 2001 From: Ruben Brunk Date: Wed, 18 Jun 2014 10:39:40 -0700 Subject: camera2: Set orientation flags for hardware composer. Bug: 15116722 Change-Id: I3fcc9aea38afcbd665f86c511a9929fe9a6a3a8f --- .../libcameraservice/api2/CameraDeviceClient.cpp | 86 +--------------------- 1 file changed, 2 insertions(+), 84 deletions(-) (limited to 'services') diff --git a/services/camera/libcameraservice/api2/CameraDeviceClient.cpp b/services/camera/libcameraservice/api2/CameraDeviceClient.cpp index de42cee..b8611f8 100644 --- a/services/camera/libcameraservice/api2/CameraDeviceClient.cpp +++ b/services/camera/libcameraservice/api2/CameraDeviceClient.cpp @@ -23,6 +23,7 @@ #include #include #include +#include #include "common/CameraDeviceBase.h" #include "api2/CameraDeviceClient.h" @@ -656,91 +657,8 @@ bool CameraDeviceClient::enforceRequestPermissions(CameraMetadata& metadata) { status_t CameraDeviceClient::getRotationTransformLocked(int32_t* transform) { ALOGV("%s: begin", __FUNCTION__); - if (transform == NULL) { - ALOGW("%s: null transform", __FUNCTION__); - return BAD_VALUE; - } - - *transform = 0; - const CameraMetadata& staticInfo = mDevice->info(); - camera_metadata_ro_entry_t entry = staticInfo.find(ANDROID_SENSOR_ORIENTATION); - if (entry.count == 0) { - ALOGE("%s: Camera %d: Can't find android.sensor.orientation in " - "static metadata!", __FUNCTION__, mCameraId); - return INVALID_OPERATION; - } - - camera_metadata_ro_entry_t entryFacing = staticInfo.find(ANDROID_LENS_FACING); - if (entry.count == 0) { - ALOGE("%s: Camera %d: Can't find android.lens.facing in " - "static metadata!", __FUNCTION__, mCameraId); - return INVALID_OPERATION; - } - - int32_t& flags = *transform; - - bool mirror = (entryFacing.data.u8[0] == ANDROID_LENS_FACING_FRONT); - int orientation = entry.data.i32[0]; - if (!mirror) { - switch (orientation) { - case 0: - flags = 0; - break; - case 90: - flags = NATIVE_WINDOW_TRANSFORM_ROT_90; - break; - case 180: - flags = NATIVE_WINDOW_TRANSFORM_ROT_180; - break; - case 270: - flags = NATIVE_WINDOW_TRANSFORM_ROT_270; - break; - default: - ALOGE("%s: Invalid HAL android.sensor.orientation value: %d", - __FUNCTION__, orientation); - return INVALID_OPERATION; - } - } else { - switch (orientation) { - case 0: - flags = HAL_TRANSFORM_FLIP_H; - break; - case 90: - flags = HAL_TRANSFORM_FLIP_H | HAL_TRANSFORM_ROT_90; - break; - case 180: - flags = HAL_TRANSFORM_FLIP_V; - break; - case 270: - flags = HAL_TRANSFORM_FLIP_V | HAL_TRANSFORM_ROT_90; - break; - default: - ALOGE("%s: Invalid HAL android.sensor.orientation value: %d", - __FUNCTION__, orientation); - return INVALID_OPERATION; - } - - } - - /** - * This magic flag makes surfaceflinger un-rotate the buffers - * to counter the extra global device UI rotation whenever the user - * physically rotates the device. - * - * By doing this, the camera buffer always ends up aligned - * with the physical camera for a "see through" effect. - * - * In essence, the buffer only gets rotated during preview use-cases. - * The user is still responsible to re-create streams of the proper - * aspect ratio, or the preview will end up looking non-uniformly - * stretched. - */ - flags |= NATIVE_WINDOW_TRANSFORM_INVERSE_DISPLAY; - - ALOGV("%s: final transform = 0x%x", __FUNCTION__, flags); - - return OK; + return CameraUtils::getRotationTransform(staticInfo, transform); } } // namespace android -- cgit v1.1