From 85d4b228a98982c8beb9eb8b1787f38fdf06a02b Mon Sep 17 00:00:00 2001 From: Leon Scroggins III Date: Tue, 9 May 2023 13:58:18 -0400 Subject: Move rotation flags to SF The rotation flags are typically only used for a camera preview, which wants to avoid changing its orientation and flicker during rotation. Prior to this CL, the rotation flags were tied to the primary display, meaning that if the camera preview was on another display, the rotation flags may not be up to date. For example, if the primary display is off, its flags will not be updated on rotation. Ideally, the flags should be based on the display where the preview will be shown, but this is a much larger architectural change, tracked in b/259407931. As a temporary workaround, associate the flags with the active display. Store the flags in SurfaceFlinger, which knows when the active display changes. Update when the active display switches to a different display or when the active display rotates, matching the behavior of mActiveDisplayTransformHint, which seems similar but is different. Store the flags as a static variable so that LayerFE can access it. LayerFE does not have a way to access the actual SurfaceFlinger object, and it should not. Access to the new flags is safe because it is only read or written from the main thread. Bug: 269685949 Bug: 259407931 Test: ActiveDisplayRotationFlagsTest Change-Id: I5532e140a603be222cb3ea1ae563638317c1d745 --- services/surfaceflinger/DisplayDevice.cpp | 10 ---------- 1 file changed, 10 deletions(-) (limited to 'services/surfaceflinger/DisplayDevice.cpp') diff --git a/services/surfaceflinger/DisplayDevice.cpp b/services/surfaceflinger/DisplayDevice.cpp index 20f4de1d67..f6ca9e2856 100644 --- a/services/surfaceflinger/DisplayDevice.cpp +++ b/services/surfaceflinger/DisplayDevice.cpp @@ -50,8 +50,6 @@ namespace android { namespace hal = hardware::graphics::composer::hal; -ui::Transform::RotationFlags DisplayDevice::sPrimaryDisplayRotationFlags = ui::Transform::ROT_0; - DisplayDeviceCreationArgs::DisplayDeviceCreationArgs( const sp& flinger, HWComposer& hwComposer, const wp& displayToken, std::shared_ptr compositionDisplay) @@ -282,10 +280,6 @@ void DisplayDevice::setProjection(ui::Rotation orientation, Rect layerStackSpace Rect orientedDisplaySpaceRect) { mOrientation = orientation; - if (isPrimary()) { - sPrimaryDisplayRotationFlags = ui::Transform::toRotationFlags(orientation); - } - // We need to take care of display rotation for globalTransform for case if the panel is not // installed aligned with device orientation. const auto transformOrientation = orientation + mPhysicalOrientation; @@ -326,10 +320,6 @@ std::optional DisplayDevice::getStagedBrightness() const { return mStagedBrightness; } -ui::Transform::RotationFlags DisplayDevice::getPrimaryDisplayRotationFlags() { - return sPrimaryDisplayRotationFlags; -} - void DisplayDevice::dump(utils::Dumper& dumper) const { using namespace std::string_view_literals; -- cgit v1.2.3-59-g8ed1b