Merge "camera: Let SurfaceView transform preview only when rotation override isn't rotation only" into main
diff --git a/camera/CameraUtils.cpp b/camera/CameraUtils.cpp
index 3473780..ebb3305 100644
--- a/camera/CameraUtils.cpp
+++ b/camera/CameraUtils.cpp
@@ -32,7 +32,7 @@
const char *kCameraServiceDisabledProperty = "config.disable_cameraservice";
status_t CameraUtils::getRotationTransform(const CameraMetadata& staticInfo,
- int mirrorMode, /*out*/int32_t* transform) {
+ int mirrorMode, bool enableTransformInverseDisplay, /*out*/int32_t* transform) {
ALOGV("%s", __FUNCTION__);
if (transform == NULL) {
@@ -128,7 +128,9 @@
* aspect ratio, or the preview will end up looking non-uniformly
* stretched.
*/
- flags |= NATIVE_WINDOW_TRANSFORM_INVERSE_DISPLAY;
+ if (enableTransformInverseDisplay) {
+ flags |= NATIVE_WINDOW_TRANSFORM_INVERSE_DISPLAY;
+ }
ALOGV("%s: final transform = 0x%x", __FUNCTION__, flags);
diff --git a/camera/include/camera/CameraUtils.h b/camera/include/camera/CameraUtils.h
index d358407..766cac1 100644
--- a/camera/include/camera/CameraUtils.h
+++ b/camera/include/camera/CameraUtils.h
@@ -46,7 +46,7 @@
* Returns OK on success, or a negative error code.
*/
static status_t getRotationTransform(const CameraMetadata& staticInfo,
- int mirrorMode, /*out*/int32_t* transform);
+ int mirrorMode, bool enableTransformInverseDisplay, /*out*/int32_t* transform);
/**
* Check if the image data is VideoNativeHandleMetadata, that contains a native handle.
diff --git a/camera/tests/fuzzer/camera_utils_fuzzer.cpp b/camera/tests/fuzzer/camera_utils_fuzzer.cpp
index c816f82..ca0a06f 100644
--- a/camera/tests/fuzzer/camera_utils_fuzzer.cpp
+++ b/camera/tests/fuzzer/camera_utils_fuzzer.cpp
@@ -75,6 +75,7 @@
CameraUtils::getRotationTransform(
staticMetadata, mFDP->ConsumeIntegral<int32_t>() /* mirrorMode */,
+ true /*enableTransformInverseDisplay*/,
&transform /*out*/);
},
[&]() { CameraUtils::isCameraServiceDisabled(); },
diff --git a/services/camera/libcameraservice/api1/Camera2Client.cpp b/services/camera/libcameraservice/api1/Camera2Client.cpp
index 45b7c3b..6bcc935 100644
--- a/services/camera/libcameraservice/api1/Camera2Client.cpp
+++ b/services/camera/libcameraservice/api1/Camera2Client.cpp
@@ -28,6 +28,7 @@
#include <camera/CameraUtils.h>
#include <camera/StringUtils.h>
#include <com_android_internal_camera_flags.h>
+#include <com_android_window_flags.h>
#include <cutils/properties.h>
#include <gui/Surface.h>
#include <gui/view/Surface.h>
@@ -53,6 +54,7 @@
using namespace camera2;
namespace flags = com::android::internal::camera::flags;
+namespace wm_flags = com::android::window::flags;
// Interface used by CameraService
@@ -134,8 +136,13 @@
// The 'mRotateAndCropMode' value only accounts for the necessary adjustment
// when the display rotates. The sensor orientation still needs to be calculated
// and applied similar to the Camera2 path.
+ using hardware::BnCameraService::ROTATION_OVERRIDE_ROTATION_ONLY;
+ bool enableTransformInverseDisplay = true;
+ if (wm_flags::enable_camera_compat_for_desktop_windowing()) {
+ enableTransformInverseDisplay = (mRotationOverride != ROTATION_OVERRIDE_ROTATION_ONLY);
+ }
CameraUtils::getRotationTransform(staticInfo, OutputConfiguration::MIRROR_MODE_AUTO,
- &mRotateAndCropPreviewTransform);
+ enableTransformInverseDisplay, &mRotateAndCropPreviewTransform);
mStreamingProcessor = new StreamingProcessor(this);
diff --git a/services/camera/libcameraservice/device3/Camera3Device.cpp b/services/camera/libcameraservice/device3/Camera3Device.cpp
index 35a192f..c6434a5 100644
--- a/services/camera/libcameraservice/device3/Camera3Device.cpp
+++ b/services/camera/libcameraservice/device3/Camera3Device.cpp
@@ -58,6 +58,7 @@
#include <android/hardware/camera/device/3.7/ICameraInjectionSession.h>
#include <android/hardware/camera2/ICameraDeviceUser.h>
#include <com_android_internal_camera_flags.h>
+#include <com_android_window_flags.h>
#include "CameraService.h"
#include "aidl/android/hardware/graphics/common/Dataspace.h"
@@ -83,6 +84,8 @@
using namespace android::hardware::cameraservice::utils::conversion::aidl;
namespace flags = com::android::internal::camera::flags;
+namespace wm_flags = com::android::window::flags;
+
namespace android {
Camera3Device::Camera3Device(std::shared_ptr<CameraServiceProxyWrapper>& cameraServiceProxyWrapper,
@@ -5820,7 +5823,13 @@
status_t Camera3Device::deriveAndSetTransformLocked(
Camera3OutputStreamInterface& stream, int mirrorMode, int surfaceId) {
int transform = -1;
- int res = CameraUtils::getRotationTransform(mDeviceInfo, mirrorMode, &transform);
+ bool enableTransformInverseDisplay = true;
+ using hardware::ICameraService::ROTATION_OVERRIDE_ROTATION_ONLY;
+ if (wm_flags::enable_camera_compat_for_desktop_windowing()) {
+ enableTransformInverseDisplay = (mRotationOverride != ROTATION_OVERRIDE_ROTATION_ONLY);
+ }
+ int res = CameraUtils::getRotationTransform(mDeviceInfo, mirrorMode,
+ enableTransformInverseDisplay, &transform);
if (res != OK) {
return res;
}
diff --git a/services/camera/libcameraservice/device3/Camera3OutputUtils.cpp b/services/camera/libcameraservice/device3/Camera3OutputUtils.cpp
index 66ffc98..78f1698 100644
--- a/services/camera/libcameraservice/device3/Camera3OutputUtils.cpp
+++ b/services/camera/libcameraservice/device3/Camera3OutputUtils.cpp
@@ -687,7 +687,8 @@
if (orientation.count > 0) {
int32_t transform;
ret = CameraUtils::getRotationTransform(deviceInfo->second,
- OutputConfiguration::MIRROR_MODE_AUTO, &transform);
+ OutputConfiguration::MIRROR_MODE_AUTO,
+ /*transformInverseDisplay*/true, &transform);
if (ret == OK) {
// It is possible for camera providers to return the capture
// results after the processed frames. In such scenario, we will