Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 77ddf5f0 authored by Oleg Blinnikov's avatar Oleg Blinnikov Committed by Android (Google) Code Review
Browse files

Merge "Remove AlwaysRotateDisplayDevice feature flag" into main

parents 2219f18c 3dce64c9
Loading
Loading
Loading
Loading
+4 −21
Original line number Diff line number Diff line
@@ -205,13 +205,6 @@ final class LogicalDisplay {
    private SparseArray<SurfaceControl.RefreshRateRange> mThermalRefreshRateThrottling =
            new SparseArray<>();

    /**
     * If enabled, will not check for {@link Display#FLAG_ROTATES_WITH_CONTENT} in LogicalDisplay
     * and simply use the {@link DisplayInfo#rotation} supplied by WindowManager via
     * {@link #setDisplayInfoOverrideFromWindowManagerLocked}
     */
    private boolean mAlwaysRotateDisplayDeviceEnabled;

    /**
     * If the aspect ratio of the resolution of the display does not match the physical aspect
     * ratio of the display, then without this feature enabled, picture would appear stretched to
@@ -233,11 +226,11 @@ final class LogicalDisplay {
    private boolean mCanHostTasks;

    LogicalDisplay(int displayId, int layerStack, DisplayDevice primaryDisplayDevice) {
        this(displayId, layerStack, primaryDisplayDevice, false, false, false);
        this(displayId, layerStack, primaryDisplayDevice, false, false);
    }

    LogicalDisplay(int displayId, int layerStack, DisplayDevice primaryDisplayDevice,
            boolean isAnisotropyCorrectionEnabled, boolean isAlwaysRotateDisplayDeviceEnabled,
            boolean isAnisotropyCorrectionEnabled,
            boolean isSyncedResolutionSwitchEnabled) {
        mDisplayId = displayId;
        mLayerStack = layerStack;
@@ -250,7 +243,6 @@ final class LogicalDisplay {
        mPowerThrottlingDataId = DisplayDeviceConfig.DEFAULT_ID;
        mBaseDisplayInfo.thermalBrightnessThrottlingDataId = mThermalBrightnessThrottlingDataId;
        mIsAnisotropyCorrectionEnabled = isAnisotropyCorrectionEnabled;
        mAlwaysRotateDisplayDeviceEnabled = isAlwaysRotateDisplayDeviceEnabled;
        mSyncedResolutionSwitchEnabled = isSyncedResolutionSwitchEnabled;

        // No need to initialize mCanHostTasks here; it's handled in
@@ -708,18 +700,9 @@ final class LogicalDisplay {
        // Set the orientation.
        // The orientation specifies how the physical coordinate system of the display
        // is rotated when the contents of the logical display are rendered.
        int orientation = Surface.ROTATION_0;

        // FLAG_ROTATES_WITH_CONTENT is now handled in DisplayContent. When the flag
        // mAlwaysRotateDisplayDeviceEnabled is removed, we should also remove this check for
        // ROTATES_WITH_CONTENT here and always set the orientation.
        if ((displayDeviceInfo.flags & DisplayDeviceInfo.FLAG_ROTATES_WITH_CONTENT) != 0
                    || mAlwaysRotateDisplayDeviceEnabled) {
            orientation = displayInfo.rotation;
        }

        // FLAG_ROTATES_WITH_CONTENT is now handled in DisplayContent.
        // Apply the physical rotation of the display device itself.
        orientation = (orientation + displayDeviceInfo.rotation) % 4;
        final int orientation = (displayInfo.rotation + displayDeviceInfo.rotation) % 4;

        // Set the frame.
        // The frame specifies the rotated physical coordinates into which the viewport
+0 −1
Original line number Diff line number Diff line
@@ -1315,7 +1315,6 @@ class LogicalDisplayMapper implements DisplayDeviceRepository.Listener {
        final int layerStack = assignLayerStackLocked(displayId);
        final LogicalDisplay display = new LogicalDisplay(displayId, layerStack, device,
                mFlags.isPixelAnisotropyCorrectionInLogicalDisplayEnabled(),
                mFlags.isAlwaysRotateDisplayDeviceEnabled(),
                mFlags.isSyncedResolutionSwitchEnabled());
        display.updateLocked(mDisplayDeviceRepo, mSyntheticModeManager);

+0 −9
Original line number Diff line number Diff line
@@ -121,10 +121,6 @@ public class DisplayManagerFlags {
            Flags.FLAG_FAST_HDR_TRANSITIONS,
            Flags::fastHdrTransitions);

    private final FlagState mAlwaysRotateDisplayDevice = new FlagState(
            Flags.FLAG_ALWAYS_ROTATE_DISPLAY_DEVICE,
            Flags::alwaysRotateDisplayDevice);

    private final FlagState mPixelAnisotropyCorrectionEnabled = new FlagState(
            Flags.FLAG_ENABLE_PIXEL_ANISOTROPY_CORRECTION,
            Flags::enablePixelAnisotropyCorrection
@@ -415,10 +411,6 @@ public class DisplayManagerFlags {
        return mFastHdrTransitions.isEnabled();
    }

    public boolean isAlwaysRotateDisplayDeviceEnabled() {
        return mAlwaysRotateDisplayDevice.isEnabled();
    }

    public boolean isPixelAnisotropyCorrectionInLogicalDisplayEnabled() {
        return mPixelAnisotropyCorrectionEnabled.isEnabled();
    }
@@ -645,7 +637,6 @@ public class DisplayManagerFlags {
        pw.println(" " + mBrightnessWearBedtimeModeClamperFlagState);
        pw.println(" " + mAutoBrightnessModesFlagState);
        pw.println(" " + mFastHdrTransitions);
        pw.println(" " + mAlwaysRotateDisplayDevice);
        pw.println(" " + mPixelAnisotropyCorrectionEnabled);
        pw.println(" " + mSensorBasedBrightnessThrottling);
        pw.println(" " + mRefactorDisplayPowerController);
+0 −11
Original line number Diff line number Diff line
@@ -171,17 +171,6 @@ flag {
    is_fixed_read_only: true
}

flag {
    name: "always_rotate_display_device"
    namespace: "display_manager"
    description: "Use rotation from WindowManager no matter whether FLAG_ROTATES_WITH_CONTENT is set or not"
    bug: "302326003"
    is_fixed_read_only: true
    metadata {
      purpose: PURPOSE_BUGFIX
    }
}

flag {
    name: "enable_pixel_anisotropy_correction"
    namespace: "display_manager"
+8 −51
Original line number Diff line number Diff line
@@ -159,7 +159,6 @@ public class LogicalDisplayTest {
        mDisplayDeviceInfo.type = Display.TYPE_INTERNAL;
        mLogicalDisplay = new LogicalDisplay(DISPLAY_ID, LAYER_STACK, mDisplayDevice,
                /*isAnisotropyCorrectionEnabled=*/ true,
                /*isAlwaysRotateDisplayDeviceEnabled=*/ true,
                /*isSyncedResolutionSwitchEnabled=*/ true);

        // In case of Anisotropy of pixels, then the content should be rescaled so it would adjust
@@ -189,7 +188,6 @@ public class LogicalDisplayTest {
        mDisplayDeviceInfo.type = Display.TYPE_EXTERNAL;
        mLogicalDisplay = new LogicalDisplay(DISPLAY_ID, LAYER_STACK, mDisplayDevice,
                /*isAnisotropyCorrectionEnabled=*/ true,
                /*isAlwaysRotateDisplayDeviceEnabled=*/ true,
                /*isSyncedResolutionSwitchEnabled=*/ true);

        // In case of Anisotropy of pixels, then the content should be rescaled so it would adjust
@@ -219,7 +217,6 @@ public class LogicalDisplayTest {
        mDisplayDeviceInfo.type = Display.TYPE_EXTERNAL;
        mLogicalDisplay = new LogicalDisplay(DISPLAY_ID, LAYER_STACK, mDisplayDevice,
                /*isAnisotropyCorrectionEnabled=*/ true,
                /*isAlwaysRotateDisplayDeviceEnabled=*/ true,
                /*isSyncedResolutionSwitchEnabled=*/ true);

        DisplayInfo displayInfo = new DisplayInfo();
@@ -278,7 +275,6 @@ public class LogicalDisplayTest {
        mDisplayDeviceInfo.type = Display.TYPE_EXTERNAL;
        mLogicalDisplay = new LogicalDisplay(DISPLAY_ID, LAYER_STACK, mDisplayDevice,
                /*isAnisotropyCorrectionEnabled=*/ true,
                /*isAlwaysRotateDisplayDeviceEnabled=*/ true,
                /*isSyncedResolutionSwitchEnabled=*/ true);

        DisplayInfo displayInfo = new DisplayInfo();
@@ -308,7 +304,6 @@ public class LogicalDisplayTest {
        mDisplayDeviceInfo.type = Display.TYPE_EXTERNAL;
        mLogicalDisplay = new LogicalDisplay(DISPLAY_ID, LAYER_STACK, mDisplayDevice,
                /*isAnisotropyCorrectionEnabled=*/ true,
                /*isAlwaysRotateDisplayDeviceEnabled=*/ true,
                /*isSyncedResolutionSwitchEnabled=*/ true);

        // In case of Anisotropy of pixels, then the content should be rescaled so it would adjust
@@ -352,7 +347,9 @@ public class LogicalDisplayTest {

    @Test
    public void testGetDisplayPosition() {
        Point expectedPosition = new Point(0, 0);
        mDisplayDeviceInfo.type = Display.TYPE_EXTERNAL;
        mLogicalDisplay.updateLocked(mDeviceRepo, mSyntheticModeManager);
        Point expectedPosition = new Point();

        SurfaceControl.Transaction t = mock(SurfaceControl.Transaction.class);
        mLogicalDisplay.configureDisplayLocked(t, mDisplayDevice, false);
@@ -366,7 +363,11 @@ public class LogicalDisplayTest {
        DisplayInfo displayInfo = new DisplayInfo();
        displayInfo.logicalWidth = DISPLAY_WIDTH;
        displayInfo.logicalHeight = DISPLAY_HEIGHT;
        // Rotation doesn't matter when the FLAG_ROTATES_WITH_CONTENT is absent.
        // Rotation sent from WindowManager is always taken into account by LogicalDisplay
        // not matter whether FLAG_ROTATES_WITH_CONTENT is set or not.
        // This is because WindowManager takes care of rotation and expects that LogicalDisplay
        // will follow the rotation supplied by WindowManager
        expectedPosition.set(115, -20);
        displayInfo.rotation = Surface.ROTATION_90;
        mLogicalDisplay.setDisplayInfoOverrideFromWindowManagerLocked(displayInfo);
        mLogicalDisplay.configureDisplayLocked(t, mDisplayDevice, false);
@@ -387,7 +388,6 @@ public class LogicalDisplayTest {
    public void testSetDisplaySizeIsCalledDuringConfigureDisplayLocked() {
        mLogicalDisplay = new LogicalDisplay(DISPLAY_ID, LAYER_STACK, mDisplayDevice,
                /*isAnisotropyCorrectionEnabled=*/ true,
                /*isAlwaysRotateDisplayDeviceEnabled=*/ true,
                /*isSyncedResolutionSwitchEnabled=*/ true);
        mLogicalDisplay.updateLocked(mDeviceRepo, mSyntheticModeManager);
        SurfaceControl.Transaction t = mock(SurfaceControl.Transaction.class);
@@ -395,49 +395,6 @@ public class LogicalDisplayTest {
        verify(mDisplayDevice).configureDisplaySizeLocked(eq(t));
    }

    @Test
    public void testGetDisplayPositionAlwaysRotateDisplayEnabled() {
        mDisplayDeviceInfo.type = Display.TYPE_EXTERNAL;
        mLogicalDisplay = new LogicalDisplay(DISPLAY_ID, LAYER_STACK, mDisplayDevice,
                /*isAnisotropyCorrectionEnabled=*/ true,
                /*isAlwaysRotateDisplayDeviceEnabled=*/ true,
                /*isSyncedResolutionSwitchEnabled=*/ true);
        mLogicalDisplay.updateLocked(mDeviceRepo, mSyntheticModeManager);
        Point expectedPosition = new Point();

        SurfaceControl.Transaction t = mock(SurfaceControl.Transaction.class);
        mLogicalDisplay.configureDisplayLocked(t, mDisplayDevice, false);
        assertEquals(expectedPosition, mLogicalDisplay.getDisplayPosition());

        expectedPosition.set(20, 40);
        mLogicalDisplay.setDisplayOffsetsLocked(20, 40);
        mLogicalDisplay.configureDisplayLocked(t, mDisplayDevice, false);
        assertEquals(expectedPosition, mLogicalDisplay.getDisplayPosition());

        DisplayInfo displayInfo = new DisplayInfo();
        displayInfo.logicalWidth = DISPLAY_WIDTH;
        displayInfo.logicalHeight = DISPLAY_HEIGHT;
        // Rotation sent from WindowManager is always taken into account by LogicalDisplay
        // not matter whether FLAG_ROTATES_WITH_CONTENT is set or not.
        // This is because WindowManager takes care of rotation and expects that LogicalDisplay
        // will follow the rotation supplied by WindowManager
        expectedPosition.set(115, -20);
        displayInfo.rotation = Surface.ROTATION_90;
        mLogicalDisplay.setDisplayInfoOverrideFromWindowManagerLocked(displayInfo);
        mLogicalDisplay.configureDisplayLocked(t, mDisplayDevice, false);
        assertEquals(expectedPosition, mLogicalDisplay.getDisplayPosition());

        expectedPosition.set(40, -20);
        mDisplayDeviceInfo.flags = DisplayDeviceInfo.FLAG_ROTATES_WITH_CONTENT;
        mLogicalDisplay.updateLocked(mDeviceRepo, mSyntheticModeManager);
        displayInfo.logicalWidth = DISPLAY_HEIGHT;
        displayInfo.logicalHeight = DISPLAY_WIDTH;
        displayInfo.rotation = Surface.ROTATION_90;
        mLogicalDisplay.setDisplayInfoOverrideFromWindowManagerLocked(displayInfo);
        mLogicalDisplay.configureDisplayLocked(t, mDisplayDevice, false);
        assertEquals(expectedPosition, mLogicalDisplay.getDisplayPosition());
    }

    @Test
    public void testDisplayInputFlags() {
        DisplayDevice displayDevice = new DisplayDevice(mDisplayAdapter, mDisplayToken,