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

Commit f9d9a276 authored by Evan Rosky's avatar Evan Rosky
Browse files

Remove Task Outset

Task outset has been replaced with surfaceflinger shadows,
so remove associated code.

Bug: 217560545
Test: existing tests pass. code is dead
Change-Id: I374c035e620a84925e7dc4659d93de33a1824469
parent ca4633dd
Loading
Loading
Loading
Loading
+1 −35
Original line number Diff line number Diff line
@@ -2197,10 +2197,6 @@ class Task extends TaskFragment {
            final Rect taskBounds = getBounds();
            width = taskBounds.width();
            height = taskBounds.height();

            final int outset = getTaskOutset();
            width += 2 * outset;
            height += 2 * outset;
        }
        if (width == mLastSurfaceSize.x && height == mLastSurfaceSize.y) {
            return;
@@ -2209,28 +2205,6 @@ class Task extends TaskFragment {
        mLastSurfaceSize.set(width, height);
    }

    /**
     * Calculate an amount by which to expand the task bounds in each direction.
     * Used to make room for shadows in the pinned windowing mode.
     */
    int getTaskOutset() {
        // If we are drawing shadows on the task then don't outset the root task.
        if (mWmService.mRenderShadowsInCompositor) {
            return 0;
        }
        DisplayContent displayContent = getDisplayContent();
        if (inPinnedWindowingMode() && displayContent != null) {
            final DisplayMetrics displayMetrics = displayContent.getDisplayMetrics();

            // We multiply by two to match the client logic for converting view elevation
            // to insets, as in {@link WindowManager.LayoutParams#setSurfaceInsets}
            return (int) Math.ceil(
                    mWmService.dipToPixel(PINNED_WINDOWING_MODE_ELEVATION_IN_DIP, displayMetrics)
                            * 2);
        }
        return 0;
    }

    @VisibleForTesting
    Point getLastSurfaceSize() {
        return mLastSurfaceSize;
@@ -4338,7 +4312,7 @@ class Task extends TaskFragment {
     */
    private void updateShadowsRadius(boolean taskIsFocused,
            SurfaceControl.Transaction pendingTransaction) {
        if (!mWmService.mRenderShadowsInCompositor || !isRootTask()) return;
        if (!isRootTask()) return;

        final float newShadowRadius = getShadowRadius(taskIsFocused);
        if (mShadowRadius != newShadowRadius) {
@@ -6015,14 +5989,6 @@ class Task extends TaskFragment {
        scheduleAnimation();
    }

    @Override
    void getRelativePosition(Point outPos) {
        super.getRelativePosition(outPos);
        final int outset = getTaskOutset();
        outPos.x -= outset;
        outPos.y -= outset;
    }

    private Point getRelativePosition() {
        Point position = new Point();
        getRelativePosition(position);
+0 −18
Original line number Diff line number Diff line
@@ -461,11 +461,6 @@ public class WindowManagerService extends IWindowManager.Stub
    int mVr2dDisplayId = INVALID_DISPLAY;
    boolean mVrModeEnabled = false;

    /* If true, shadows drawn around the window will be rendered by the system compositor. If
     * false, shadows will be drawn by the client by setting an elevation on the root view and
     * the contents will be inset by the shadow radius. */
    boolean mRenderShadowsInCompositor = false;

    /**
     * Tracks a map of input tokens to info that is used to decide whether to intercept
     * a key event.
@@ -795,8 +790,6 @@ public class WindowManagerService extends IWindowManager.Stub
            resolver.registerContentObserver(mForceResizableUri, false, this, UserHandle.USER_ALL);
            resolver.registerContentObserver(mDevEnableNonResizableMultiWindowUri, false, this,
                    UserHandle.USER_ALL);
            resolver.registerContentObserver(mRenderShadowsInCompositorUri, false, this,
                    UserHandle.USER_ALL);
            resolver.registerContentObserver(mDisplaySettingsPathUri, false, this,
                    UserHandle.USER_ALL);
        }
@@ -837,11 +830,6 @@ public class WindowManagerService extends IWindowManager.Stub
                return;
            }

            if (mRenderShadowsInCompositorUri.equals(uri)) {
                setShadowRenderer();
                return;
            }

            if (mDisplaySettingsPathUri.equals(uri)) {
                updateDisplaySettingsLocation();
                return;
@@ -956,11 +944,6 @@ public class WindowManagerService extends IWindowManager.Stub
        }
    }

    private void setShadowRenderer() {
        mRenderShadowsInCompositor = Settings.Global.getInt(mContext.getContentResolver(),
                DEVELOPMENT_RENDER_SHADOWS_IN_COMPOSITOR, 1) != 0;
    }

    PowerManager mPowerManager;
    PowerManagerInternal mPowerManagerInternal;

@@ -1378,7 +1361,6 @@ public class WindowManagerService extends IWindowManager.Stub
        float[] spotColor = {0.f, 0.f, 0.f, spotShadowAlpha};
        SurfaceControl.setGlobalShadowSettings(ambientColor, spotColor, lightY, lightZ,
                lightRadius);
        setShadowRenderer();
    }

    /**
+0 −11
Original line number Diff line number Diff line
@@ -5403,17 +5403,6 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
            outPoint.offset(-parentBounds.left, -parentBounds.top);
        }

        Task rootTask = getRootTask();

        // If we have root task outsets, that means the top-left
        // will be outset, and we need to inset ourselves
        // to account for it. If we actually have shadows we will
        // then un-inset ourselves by the surfaceInsets.
        if (rootTask != null) {
            final int outset = rootTask.getTaskOutset();
            outPoint.offset(outset, outset);
        }

        // The surface size is larger than the window if the window has positive surface insets.
        transformSurfaceInsetsPosition(mTmpPoint, mAttrs.surfaceInsets);
        outPoint.offset(-mTmpPoint.x, -mTmpPoint.y);
+0 −29
Original line number Diff line number Diff line
@@ -80,7 +80,6 @@ import android.app.IApplicationThread;
import android.app.WindowConfiguration;
import android.content.ComponentName;
import android.content.pm.ActivityInfo;
import android.graphics.Rect;
import android.os.Binder;
import android.os.UserHandle;
import android.platform.test.annotations.Presubmit;
@@ -230,34 +229,6 @@ public class RootTaskTests extends WindowTestsBase {
        verify(task1, times(1)).onDisplayChanged(any());
    }

    @Test
    public void testTaskOutset() {
        final Task task = createTask(mDisplayContent);
        final int taskOutset = 10;
        spyOn(task);
        doReturn(taskOutset).when(task).getTaskOutset();
        doReturn(true).when(task).inMultiWindowMode();

        // Mock the resolved override windowing mode to non-fullscreen
        final WindowConfiguration windowConfiguration =
                task.getResolvedOverrideConfiguration().windowConfiguration;
        spyOn(windowConfiguration);
        doReturn(WINDOWING_MODE_MULTI_WINDOW)
                .when(windowConfiguration).getWindowingMode();

        // Prevent adjust task dimensions
        doNothing().when(task).adjustForMinimalTaskDimensions(any(), any(), any());

        final Rect taskBounds = new Rect(200, 200, 800, 1000);
        // Update surface position and size by the given bounds.
        task.setBounds(taskBounds);

        assertEquals(taskBounds.width() + 2 * taskOutset, task.getLastSurfaceSize().x);
        assertEquals(taskBounds.height() + 2 * taskOutset, task.getLastSurfaceSize().y);
        assertEquals(taskBounds.left - taskOutset, task.getLastSurfacePosition().x);
        assertEquals(taskBounds.top - taskOutset, task.getLastSurfacePosition().y);
    }

    @Test
    public void testActivityAndTaskGetsProperType() {
        final Task task1 = new TaskBuilder(mSupervisor).build();