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

Commit 7100404a authored by Oleg Blinnikov's avatar Oleg Blinnikov
Browse files

LogicalDisplay to call SC.setDisplaySize

Also performTraversalLocked is split
and renamed into configureSurfaceLocked
and configureDisplaySizeLocked

Change-Id: Idc7de9e1a215cad6acc4ec93fde01e9c28b27c46
Test: atest LogicalDisplayTest DisplayDeviceTest
Bug: 355427258
Flag: com.android.graphics.surfaceflinger.flags.synced_resolution_switch
parent c13717cd
Loading
Loading
Loading
Loading
+27 −2
Original line number Diff line number Diff line
@@ -68,6 +68,8 @@ abstract class DisplayDevice {
    private int mCurrentLayerStack = -1;
    private int mCurrentFlags = 0;
    private int mCurrentOrientation = -1;
    private int mLastDisplayWidth;
    private int mLastDisplayHeight;
    private Rect mCurrentLayerStackRect;
    private Rect mCurrentDisplayRect;
    private final Context mContext;
@@ -216,9 +218,9 @@ abstract class DisplayDevice {
    }

    /**
     * Gives the display device a chance to update its properties while in a transaction.
     * Updates the surface for the display.
     */
    public void performTraversalLocked(SurfaceControl.Transaction t) {
    public void configureSurfaceLocked(SurfaceControl.Transaction t) {
    }

    /**
@@ -373,6 +375,29 @@ abstract class DisplayDevice {
        }
    }

    /**
     * Configure transaction with the display size.
     */
    public void configureDisplaySizeLocked(SurfaceControl.Transaction t) {
        DisplayDeviceInfo info = getDisplayDeviceInfoLocked();
        boolean isInstalledRotated = info.installOrientation == ROTATION_90
                || info.installOrientation == ROTATION_270;
        int displayWidth = isInstalledRotated ? info.height : info.width;
        int displayHeight = isInstalledRotated ? info.width : info.height;
        setDisplaySizeLocked(t, displayWidth, displayHeight);
    }

    /**
     * Sets display size while in a transaction.
     */
    public final void setDisplaySizeLocked(SurfaceControl.Transaction t, int width, int height) {
        if (width != mLastDisplayWidth && height != mLastDisplayHeight) {
            mLastDisplayWidth = width;
            mLastDisplayHeight = height;
            t.setDisplaySize(mDisplayToken, width, height);
        }
    }

    /**
     * Sets the display surface while in a transaction.
     */
+0 −1
Original line number Diff line number Diff line
@@ -3110,7 +3110,6 @@ public final class DisplayManagerService extends SystemService {
                    displayTransactions.get(display.getDisplayIdLocked(), t);
            if (device != null) {
                configureDisplayLocked(displayTransaction, device);
                device.performTraversalLocked(displayTransaction);
            }
        });

+11 −2
Original line number Diff line number Diff line
@@ -228,14 +228,17 @@ final class LogicalDisplay {
     */
    private final boolean mIsAnisotropyCorrectionEnabled;

    private final boolean mSyncedResolutionSwitchEnabled;

    private boolean mCanHostTasks;

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

    LogicalDisplay(int displayId, int layerStack, DisplayDevice primaryDisplayDevice,
            boolean isAnisotropyCorrectionEnabled, boolean isAlwaysRotateDisplayDeviceEnabled) {
            boolean isAnisotropyCorrectionEnabled, boolean isAlwaysRotateDisplayDeviceEnabled,
            boolean isSyncedResolutionSwitchEnabled) {
        mDisplayId = displayId;
        mLayerStack = layerStack;
        mPrimaryDisplayDevice = primaryDisplayDevice;
@@ -248,6 +251,7 @@ final class LogicalDisplay {
        mBaseDisplayInfo.thermalBrightnessThrottlingDataId = mThermalBrightnessThrottlingDataId;
        mIsAnisotropyCorrectionEnabled = isAnisotropyCorrectionEnabled;
        mAlwaysRotateDisplayDeviceEnabled = isAlwaysRotateDisplayDeviceEnabled;
        mSyncedResolutionSwitchEnabled = isSyncedResolutionSwitchEnabled;
        mCanHostTasks = (mDisplayId == Display.DEFAULT_DISPLAY);
    }

@@ -791,7 +795,12 @@ final class LogicalDisplay {
        }

        mDisplayPosition.set(mTempDisplayRect.left, mTempDisplayRect.top);

        if (mSyncedResolutionSwitchEnabled || displayDeviceInfo.type == Display.TYPE_VIRTUAL) {
            device.configureDisplaySizeLocked(t);
        }
        device.setProjectionLocked(t, orientation, mTempLayerStackRect, mTempDisplayRect);
        device.configureSurfaceLocked(t);
    }

    /**
+2 −1
Original line number Diff line number Diff line
@@ -1248,7 +1248,8 @@ class LogicalDisplayMapper implements DisplayDeviceRepository.Listener {
        final int layerStack = assignLayerStackLocked(displayId);
        final LogicalDisplay display = new LogicalDisplay(displayId, layerStack, device,
                mFlags.isPixelAnisotropyCorrectionInLogicalDisplayEnabled(),
                mFlags.isAlwaysRotateDisplayDeviceEnabled());
                mFlags.isAlwaysRotateDisplayDeviceEnabled(),
                mFlags.isSyncedResolutionSwitchEnabled());
        display.updateLocked(mDisplayDeviceRepo, mSyntheticModeManager);

        final DisplayInfo info = display.getDisplayInfoLocked();
+1 −1
Original line number Diff line number Diff line
@@ -341,7 +341,7 @@ final class OverlayDisplayAdapter extends DisplayAdapter {
        }

        @Override
        public void performTraversalLocked(SurfaceControl.Transaction t) {
        public void configureSurfaceLocked(SurfaceControl.Transaction t) {
            if (mSurfaceTexture != null) {
                if (mSurface == null) {
                    mSurface = new Surface(mSurfaceTexture);
Loading