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

Commit 7794c359 authored by Wale Ogunwale's avatar Wale Ogunwale Committed by Android (Google) Code Review
Browse files

Merge "Fixed issue with stack size when rotating screen."

parents 58a32f31 9474421a
Loading
Loading
Loading
Loading
+31 −1
Original line number Diff line number Diff line
@@ -100,7 +100,8 @@ class DisplayContent {
    Region mTouchExcludeRegion = new Region();

    /** Save allocating when calculating rects */
    Rect mTmpRect = new Rect();
    private Rect mTmpRect = new Rect();
    private Rect mTmpRect2 = new Rect();

    /** For gathering Task objects in order. */
    final ArrayList<Task> mTmpTaskHistory = new ArrayList<Task>();
@@ -442,6 +443,35 @@ class DisplayContent {
        }
    }

    void rotateBounds(int oldRotation, int newRotation, Rect bounds) {
        final int rotationDelta = DisplayContent.deltaRotation(oldRotation, newRotation);
        getLogicalDisplayRect(mTmpRect);
        switch (rotationDelta) {
            case Surface.ROTATION_0:
                mTmpRect2.set(bounds);
                break;
            case Surface.ROTATION_90:
                mTmpRect2.top = mTmpRect.bottom - bounds.right;
                mTmpRect2.left = bounds.top;
                mTmpRect2.right = mTmpRect2.left + bounds.height();
                mTmpRect2.bottom = mTmpRect2.top + bounds.width();
                break;
            case Surface.ROTATION_180:
                mTmpRect2.top = mTmpRect.bottom - bounds.bottom;
                mTmpRect2.left = mTmpRect.right - bounds.right;
                mTmpRect2.right = mTmpRect2.left + bounds.width();
                mTmpRect2.bottom = mTmpRect2.top + bounds.height();
                break;
            case Surface.ROTATION_270:
                mTmpRect2.top = bounds.left;
                mTmpRect2.left = mTmpRect.right - bounds.bottom;
                mTmpRect2.right = mTmpRect2.left + bounds.height();
                mTmpRect2.bottom = mTmpRect2.top + bounds.width();
                break;
        }
        bounds.set(mTmpRect2);
    }

    static int deltaRotation(int oldRotation, int newRotation) {
        int delta = newRotation - oldRotation;
        if (delta < 0) delta += 4;
+2 −25
Original line number Diff line number Diff line
@@ -271,31 +271,8 @@ class Task implements DimLayer.DimLayerUser {

        // Device rotation changed. We don't want the task to move around on the screen when
        // this happens, so update the task bounds so it stays in the same place.
        final int rotationDelta = DisplayContent.deltaRotation(mRotation, newRotation);
        displayContent.getLogicalDisplayRect(mTmpRect);
        switch (rotationDelta) {
            case Surface.ROTATION_0:
        mTmpRect2.set(mBounds);
                break;
            case Surface.ROTATION_90:
                mTmpRect2.top = mTmpRect.bottom - mBounds.right;
                mTmpRect2.left = mBounds.top;
                mTmpRect2.right = mTmpRect2.left + mBounds.height();
                mTmpRect2.bottom = mTmpRect2.top + mBounds.width();
                break;
            case Surface.ROTATION_180:
                mTmpRect2.top = mTmpRect.bottom - mBounds.bottom;
                mTmpRect2.left = mTmpRect.right - mBounds.right;
                mTmpRect2.right = mTmpRect2.left + mBounds.width();
                mTmpRect2.bottom = mTmpRect2.top + mBounds.height();
                break;
            case Surface.ROTATION_270:
                mTmpRect2.top = mBounds.left;
                mTmpRect2.left = mTmpRect.right - mBounds.bottom;
                mTmpRect2.right = mTmpRect2.left + mBounds.height();
                mTmpRect2.bottom = mTmpRect2.top + mBounds.width();
                break;
        }
        displayContent.rotateBounds(mRotation, newRotation, mTmpRect2);
        setBounds(mTmpRect2, mOverrideConfig);
    }

+15 −2
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ import android.util.Slog;
import android.util.SparseArray;
import android.view.DisplayInfo;

import android.view.Surface;
import com.android.server.EventLogTags;

import java.io.PrintWriter;
@@ -57,6 +58,7 @@ public class TaskStack implements DimLayer.DimLayerUser {

    /** For comparison with DisplayContent bounds. */
    private Rect mTmpRect = new Rect();
    private Rect TmpRect2 = new Rect();

    /** Content limits relative to the DisplayContent this sits in. */
    private Rect mBounds = new Rect();
@@ -64,6 +66,9 @@ public class TaskStack implements DimLayer.DimLayerUser {
    /** Whether mBounds is fullscreen */
    private boolean mFullscreen = true;

    // Device rotation as of the last time {@link #mBounds} was set.
    int mRotation;

    /** Support for non-zero {@link android.view.animation.Animation#getBackgroundColor()} */
    DimLayer mAnimationBackgroundSurface;

@@ -144,8 +149,10 @@ public class TaskStack implements DimLayer.DimLayerUser {

    private boolean setBounds(Rect bounds) {
        boolean oldFullscreen = mFullscreen;
        int rotation = Surface.ROTATION_0;
        if (mDisplayContent != null) {
            mDisplayContent.getLogicalDisplayRect(mTmpRect);
            rotation = mDisplayContent.getDisplayInfo().rotation;
            if (bounds == null) {
                bounds = mTmpRect;
                mFullscreen = true;
@@ -163,12 +170,13 @@ public class TaskStack implements DimLayer.DimLayerUser {
            // Can't set to fullscreen if we don't have a display to get bounds from...
            return false;
        }
        if (mBounds.equals(bounds) && oldFullscreen == mFullscreen) {
        if (mBounds.equals(bounds) && oldFullscreen == mFullscreen && mRotation == rotation) {
            return false;
        }

        mAnimationBackgroundSurface.setBounds(bounds);
        mBounds.set(bounds);
        mRotation = rotation;
        return true;
    }

@@ -180,8 +188,13 @@ public class TaskStack implements DimLayer.DimLayerUser {
        if (mDisplayContent != null) {
            if (bounds != null) {
                setBounds(bounds);
            } else if (mFullscreen) {
                setBounds(null);
            } else {
                setBounds(mFullscreen ? null : mBounds);
                TmpRect2.set(mBounds);
                mDisplayContent.rotateBounds(
                        mRotation, mDisplayContent.getDisplayInfo().rotation, TmpRect2);
                setBounds(TmpRect2);
            }
            for (int taskNdx = mTasks.size() - 1; taskNdx >= 0; --taskNdx) {
                mTasks.get(taskNdx).updateDisplayInfo(mDisplayContent);