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

Commit a91f9e29 authored by Craig Mautner's avatar Craig Mautner
Browse files

Make more items per-Display.

Moving DimSurfaces, DimBackgrounds and Rotation surfaces into
per-display class.

Fixes bug 7167028.

Change-Id: I7408b3a27b5a7a8d0d59e9d6109c002fc627e536
parent d65afc65
Loading
Loading
Loading
Loading
+7 −4
Original line number Diff line number Diff line
@@ -4,6 +4,7 @@ package com.android.server.wm;

import android.graphics.Matrix;
import android.util.Slog;
import android.view.Display;
import android.view.Surface;
import android.view.WindowManagerPolicy;
import android.view.animation.Animation;
@@ -134,11 +135,13 @@ public class AppWindowAnimator {
        thumbnailTransformation.clear();
        thumbnailAnimation.getTransformation(currentTime, thumbnailTransformation);
        thumbnailTransformation.getMatrix().preTranslate(thumbnailX, thumbnailY);
        final boolean screenAnimation = mAnimator.mScreenRotationAnimation != null
                && mAnimator.mScreenRotationAnimation.isAnimating();

        ScreenRotationAnimation screenRotationAnimation =
                mAnimator.getScreenRotationAnimationLocked(Display.DEFAULT_DISPLAY);
        final boolean screenAnimation = screenRotationAnimation != null
                && screenRotationAnimation.isAnimating();
        if (screenAnimation) {
            thumbnailTransformation.postCompose(
                    mAnimator.mScreenRotationAnimation.getEnterTransformation());
            thumbnailTransformation.postCompose(screenRotationAnimation.getEnterTransformation());
        }
        // cache often used attributes locally
        final float tmpFloats[] = mService.mTmpFloats;
+8 −0
Original line number Diff line number Diff line
@@ -219,5 +219,13 @@ class DimAnimator {
            mDimHeight = o.mDimHeight;
            mDimTarget = o.mDimTarget;
        }

        public void printTo(String prefix, PrintWriter pw) {
            pw.print(prefix);
            pw.print("mDimWinAnimator="); pw.print(mDimWinAnimator.mWin.mAttrs.getTitle());
                    pw.print(" "); pw.print(mDimWidth); pw.print(" x ");
                    pw.print(mDimHeight);
            pw.print(" mDimTarget="); pw.println(mDimTarget);
        }
    }
}
+25 −24
Original line number Diff line number Diff line
@@ -101,9 +101,10 @@ class DisplayContent {
        mDisplay.getDisplayInfo(mDisplayInfo);
    }

    public void dump(PrintWriter pw) {
        pw.print("  Display: mDisplayId="); pw.println(mDisplayId);
        pw.print("  init="); pw.print(mInitialDisplayWidth); pw.print("x");
    public void dump(String prefix, PrintWriter pw) {
        pw.print(prefix); pw.print("Display: mDisplayId="); pw.println(mDisplayId);
        final String subPrefix = "  " + prefix;
        pw.print(subPrefix); pw.print("init="); pw.print(mInitialDisplayWidth); pw.print("x");
            pw.print(mInitialDisplayHeight); pw.print(" "); pw.print(mInitialDisplayDensity);
            pw.print("dpi");
            if (mInitialDisplayWidth != mBaseDisplayWidth
@@ -123,9 +124,9 @@ class DisplayContent {
            pw.print("x"); pw.print(mDisplayInfo.smallestNominalAppHeight);
            pw.print("-"); pw.print(mDisplayInfo.largestNominalAppWidth);
            pw.print("x"); pw.println(mDisplayInfo.largestNominalAppHeight);
        pw.print("  layoutNeeded="); pw.println(layoutNeeded);
        pw.print(subPrefix); pw.print("layoutNeeded="); pw.print(layoutNeeded);
        if (mMagnificationSpec != null) {
            pw.print("  mMagnificationSpec="); pw.println(mMagnificationSpec);
            pw.print(" mMagnificationSpec="); pw.print(mMagnificationSpec);
        }
        pw.println();
    }
+158 −78
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@ import android.content.Context;
import android.os.SystemClock;
import android.util.Log;
import android.util.Slog;
import android.util.SparseArray;
import android.util.SparseIntArray;
import android.view.Display;
import android.view.Surface;
@@ -39,8 +40,6 @@ public class WindowAnimator {
    final Context mContext;
    final WindowManagerPolicy mPolicy;

    ArrayList<WinAnimatorList> mWinAnimatorLists = new ArrayList<WinAnimatorList>();

    boolean mAnimating;

    final Runnable mAnimationRunnable;
@@ -64,24 +63,19 @@ public class WindowAnimator {
     * is a long initialized to Long.MIN_VALUE so that it doesn't match this value on startup. */
    private int mAnimTransactionSequence;

    /** The one and only screen rotation if one is happening */
    ScreenRotationAnimation mScreenRotationAnimation = null;

    // Window currently running an animation that has requested it be detached
    // from the wallpaper.  This means we need to ensure the wallpaper is
    // visible behind it in case it animates in a way that would allow it to be
    // seen. If multiple windows satisfy this, use the lowest window.
    WindowState mWindowDetachedWallpaper = null;

    DimSurface mWindowAnimationBackgroundSurface = null;

    WindowStateAnimator mUniverseBackground = null;
    int mAboveUniverseLayer = 0;

    int mBulkUpdateParams = 0;

    DimAnimator mDimAnimator = null;
    DimAnimator.Parameters mDimParams = null;
    SparseArray<DisplayContentsAnimator> mDisplayContentsAnimators =
            new SparseArray<WindowAnimator.DisplayContentsAnimator>();

    static final int WALLPAPER_ACTION_PENDING = 1;
    int mPendingActions;
@@ -127,12 +121,19 @@ public class WindowAnimator {
        };
    }

    void initializeLocked(final int layerStack) {
        mWindowAnimationBackgroundSurface =
                new DimSurface(mService.mFxSession, layerStack);
        mDimAnimator = new DimAnimator(mService.mFxSession, layerStack);
    void addDisplayLocked(final int displayId) {
        DisplayContentsAnimator displayAnimator = getDisplayContentsAnimatorLocked(displayId);
        displayAnimator.mWindowAnimationBackgroundSurface =
                new DimSurface(mService.mFxSession, displayId);
        displayAnimator.mDimAnimator = new DimAnimator(mService.mFxSession, displayId);
        if (displayId == Display.DEFAULT_DISPLAY) {
            mInitialized = true;
        }
    }

    void removeDisplayLocked(final int displayId) {
        mDisplayContentsAnimators.delete(displayId);
    }

    /** Locked on mAnimToLayout */
    void updateAnimToLayoutLocked() {
@@ -165,8 +166,6 @@ public class WindowAnimator {
                mWallpaperTokens = new ArrayList<WindowToken>(layoutToAnim.mWallpaperTokens);
            }

            mWinAnimatorLists =
                    new ArrayList<WinAnimatorList>(layoutToAnim.mWinAnimatorLists);
            mWallpaperTarget = layoutToAnim.mWallpaperTarget;
            mWpAppAnimator = mWallpaperTarget == null
                    ? null : mWallpaperTarget.mAppToken == null
@@ -175,20 +174,34 @@ public class WindowAnimator {
            mUpperWallpaperTarget = layoutToAnim.mUpperWallpaperTarget;

            // Set the new DimAnimator params.
            DimAnimator.Parameters dimParams = layoutToAnim.mDimParams;
            final int numDisplays = mDisplayContentsAnimators.size();
            for (int i = 0; i < numDisplays; i++) {
                final int displayId = mDisplayContentsAnimators.keyAt(i);
                DisplayContentsAnimator displayAnimator = mDisplayContentsAnimators.valueAt(i);

                displayAnimator.mWinAnimators.clear();
                final WinAnimatorList winAnimators = layoutToAnim.mWinAnimatorLists.get(displayId);
                if (winAnimators != null) {
                    displayAnimator.mWinAnimators.addAll(winAnimators);
                }

                DimAnimator.Parameters dimParams = layoutToAnim.mDimParams.get(displayId);
                if (dimParams == null) {
                mDimParams = null;
                    displayAnimator.mDimParams = null;
                } else {
                    final WindowStateAnimator newWinAnimator = dimParams.mDimWinAnimator;

                    // Only set dim params on the highest dimmed layer.
                final WindowStateAnimator existingDimWinAnimator = mDimParams == null
                        ? null : mDimParams.mDimWinAnimator;
                // Don't turn on for an unshown surface, or for any layer but the highest dimmed one.
                if (newWinAnimator.mSurfaceShown &&
                        (existingDimWinAnimator == null || !existingDimWinAnimator.mSurfaceShown
                    final WindowStateAnimator existingDimWinAnimator =
                            displayAnimator.mDimParams == null ?
                                    null : displayAnimator.mDimParams.mDimWinAnimator;
                    // Don't turn on for an unshown surface, or for any layer but the highest
                    // dimmed layer.
                    if (newWinAnimator.mSurfaceShown && (existingDimWinAnimator == null
                            || !existingDimWinAnimator.mSurfaceShown
                            || existingDimWinAnimator.mAnimLayer < newWinAnimator.mAnimLayer)) {
                    mDimParams = new DimAnimator.Parameters(dimParams);
                        displayAnimator.mDimParams = new DimAnimator.Parameters(dimParams);
                    }
                }
            }

@@ -225,7 +238,7 @@ public class WindowAnimator {
        }
    }

    private void updateWindowsAppsAndRotationAnimationsLocked() {
    private void updateAppWindowsLocked() {
        int i;
        final int NAT = mAppAnimators.size();
        for (i=0; i<NAT; i++) {
@@ -258,21 +271,13 @@ public class WindowAnimator {
                        "updateWindowsApps...: done animating exiting " + appAnimator.mAppToken);
            }
        }

        if (mScreenRotationAnimation != null && mScreenRotationAnimation.isAnimating()) {
            if (mScreenRotationAnimation.stepAnimationLocked(mCurrentTime)) {
                mAnimating = true;
            } else {
                mBulkUpdateParams |= SET_UPDATE_ROTATION;
                mScreenRotationAnimation.kill();
                mScreenRotationAnimation = null;
            }
        }
    }

    private void updateWindowsLocked(final WinAnimatorList winAnimatorList) {
    private void updateWindowsLocked(final int displayId) {
        ++mAnimTransactionSequence;

        final WinAnimatorList winAnimatorList =
                getDisplayContentsAnimatorLocked(displayId).mWinAnimators;
        ArrayList<WindowStateAnimator> unForceHiding = null;
        boolean wallpaperInUnForceHiding = false;

@@ -313,7 +318,6 @@ public class WindowAnimator {
                                WindowManagerService.DEBUG_VISIBILITY) Slog.v(TAG,
                                "Animation started that could impact force hide: " + win);
                        mBulkUpdateParams |= SET_FORCE_HIDING_CHANGED;
                        final int displayId = win.mDisplayContent.getDisplayId();
                        setPendingLayoutChanges(displayId,
                                WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER);
                        if (WindowManagerService.DEBUG_LAYOUT_REPEATS) {
@@ -391,7 +395,6 @@ public class WindowAnimator {
            if (winAnimator.mDrawState == WindowStateAnimator.READY_TO_SHOW) {
                if (atoken == null || atoken.allDrawn) {
                    if (winAnimator.performShowLocked()) {
                        final int displayId = win.mDisplayContent.getDisplayId();
                        mPendingLayoutChanges.put(displayId,
                                WindowManagerPolicy.FINISH_LAYOUT_REDO_ANIM);
                        if (WindowManagerService.DEBUG_LAYOUT_REPEATS) {
@@ -427,10 +430,15 @@ public class WindowAnimator {
        }
    }

    private void updateWallpaperLocked(final WinAnimatorList winAnimatorList) {
    private void updateWallpaperLocked(int displayId) {
        final DisplayContentsAnimator displayAnimator =
                getDisplayContentsAnimatorLocked(displayId);
        final WinAnimatorList winAnimatorList = displayAnimator.mWinAnimators;
        WindowStateAnimator windowAnimationBackground = null;
        int windowAnimationBackgroundColor = 0;
        WindowState detachedWallpaper = null;
        final DimSurface windowAnimationBackgroundSurface =
                displayAnimator.mWindowAnimationBackgroundSurface;

        for (int i = winAnimatorList.size() - 1; i >= 0; i--) {
            WindowStateAnimator winAnimator = winAnimatorList.get(i);
@@ -510,11 +518,11 @@ public class WindowAnimator {
                }
            }

            mWindowAnimationBackgroundSurface.show(mDw, mDh,
            windowAnimationBackgroundSurface.show(mDw, mDh,
                    animLayer - WindowManagerService.LAYER_OFFSET_DIM,
                    windowAnimationBackgroundColor);
        } else {
            mWindowAnimationBackgroundSurface.hide();
            windowAnimationBackgroundSurface.hide();
        }
    }

@@ -557,9 +565,9 @@ public class WindowAnimator {
        }
    }

    private void performAnimationsLocked(final WinAnimatorList winAnimatorList) {
        updateWindowsLocked(winAnimatorList);
        updateWallpaperLocked(winAnimatorList);
    private void performAnimationsLocked(final int displayId) {
        updateWindowsLocked(displayId);
        updateWallpaperLocked(displayId);
    }

    // TODO(cmautner): Change the following comment when no longer locked on mWindowMap */
@@ -582,15 +590,30 @@ public class WindowAnimator {
                TAG, ">>> OPEN TRANSACTION animateLocked");
        Surface.openTransaction();
        try {
            updateWindowsAppsAndRotationAnimationsLocked();
            updateAppWindowsLocked();

            for (int i = mWinAnimatorLists.size() - 1; i >= 0; i--) {
                final WinAnimatorList winAnimatorList = mWinAnimatorLists.get(i);
            final int numDisplays = mDisplayContentsAnimators.size();
            for (int i = 0; i < numDisplays; i++) {
                final int displayId = mDisplayContentsAnimators.keyAt(i);
                DisplayContentsAnimator displayAnimator = mDisplayContentsAnimators.valueAt(i);

                final ScreenRotationAnimation screenRotationAnimation =
                        displayAnimator.mScreenRotationAnimation;
                if (screenRotationAnimation != null && screenRotationAnimation.isAnimating()) {
                    if (screenRotationAnimation.stepAnimationLocked(mCurrentTime)) {
                        mAnimating = true;
                    } else {
                        mBulkUpdateParams |= SET_UPDATE_ROTATION;
                        screenRotationAnimation.kill();
                        displayAnimator.mScreenRotationAnimation = null;
                    }
                }

                // Update animations of all applications, including those
                // associated with exiting/removed apps
                performAnimationsLocked(winAnimatorList);
                performAnimationsLocked(displayId);

                final WinAnimatorList winAnimatorList = displayAnimator.mWinAnimators;
                final int N = winAnimatorList.size();
                for (int j = 0; j < N; j++) {
                    winAnimatorList.get(j).prepareSurfaceLocked(true);
@@ -599,16 +622,26 @@ public class WindowAnimator {

            testTokenMayBeDrawnLocked();

            if (mScreenRotationAnimation != null) {
                mScreenRotationAnimation.updateSurfacesInTransaction();
            for (int i = 0; i < numDisplays; i++) {
                final int displayId = mDisplayContentsAnimators.keyAt(i);
                DisplayContentsAnimator displayAnimator = mDisplayContentsAnimators.valueAt(i);

                final ScreenRotationAnimation screenRotationAnimation =
                        displayAnimator.mScreenRotationAnimation;
                if (screenRotationAnimation != null) {
                    screenRotationAnimation.updateSurfacesInTransaction();
                }

            if (mDimParams != null) {
                mDimAnimator.updateParameters(mContext.getResources(), mDimParams, mCurrentTime);
                final DimAnimator.Parameters dimParams = displayAnimator.mDimParams;
                final DimAnimator dimAnimator = displayAnimator.mDimAnimator;
                if (dimParams != null) {
                    dimAnimator.updateParameters(
                            mContext.getResources(), dimParams, mCurrentTime);
                }
                if (dimAnimator != null && dimAnimator.mDimShown) {
                    mAnimating |= dimAnimator.updateSurface(isDimmingLocked(displayId),
                            mCurrentTime, !mService.okToDisplay());
                }
            if (mDimAnimator != null && mDimAnimator.mDimShown) {
                mAnimating |= mDimAnimator.updateSurface(isDimming(), mCurrentTime,
                        !mService.okToDisplay());
            }

            if (mService.mWatermark != null) {
@@ -661,15 +694,17 @@ public class WindowAnimator {
        mInnerDh = appHeight;
    }

    boolean isDimming() {
        return mDimParams != null;
    boolean isDimmingLocked(int displayId) {
        return getDisplayContentsAnimatorLocked(displayId).mDimParams != null;
    }

    boolean isDimming(final WindowStateAnimator winAnimator) {
        return mDimParams != null && mDimParams.mDimWinAnimator == winAnimator;
    boolean isDimmingLocked(final WindowStateAnimator winAnimator) {
        DimAnimator.Parameters dimParams =
                getDisplayContentsAnimatorLocked(winAnimator.mWin.getDisplayId()).mDimParams;
        return dimParams != null && dimParams.mDimWinAnimator == winAnimator;
    }

    public void dump(PrintWriter pw, String prefix, boolean dumpAll) {
    public void dumpLocked(PrintWriter pw, String prefix, boolean dumpAll) {
        if (dumpAll) {
            if (mWindowDetachedWallpaper != null) {
                pw.print(prefix); pw.print("mWindowDetachedWallpaper=");
@@ -677,16 +712,36 @@ public class WindowAnimator {
            }
            pw.print(prefix); pw.print("mAnimTransactionSequence=");
                    pw.println(mAnimTransactionSequence);
            if (mWindowAnimationBackgroundSurface != null) {
                pw.print(prefix); pw.print("mWindowAnimationBackgroundSurface:");
                        mWindowAnimationBackgroundSurface.printTo(prefix + "  ", pw);
            for (int i = 0; i < mDisplayContentsAnimators.size(); i++) {
                pw.print(prefix); pw.print("DisplayContentsAnimator #");
                    pw.println(mDisplayContentsAnimators.keyAt(i));
                DisplayContentsAnimator displayAnimator = mDisplayContentsAnimators.valueAt(i);
                final String subPrefix = "  " + prefix;
                final String subSubPrefix = "  " + subPrefix;
                if (displayAnimator.mWindowAnimationBackgroundSurface != null) {
                    pw.println(subPrefix + "mWindowAnimationBackgroundSurface:");
                    displayAnimator.mWindowAnimationBackgroundSurface.printTo(subSubPrefix, pw);
                }
                if (displayAnimator.mDimAnimator != null) {
                    pw.println(subPrefix + "mDimAnimator:");
                    displayAnimator.mDimAnimator.printTo(subSubPrefix, pw);
                } else {
                    pw.println(subPrefix + "no DimAnimator ");
                }
            if (mDimAnimator != null) {
                pw.print(prefix); pw.print("mDimAnimator:");
                mDimAnimator.printTo(prefix + "  ", pw);
                if (displayAnimator.mDimParams != null) {
                    pw.println(subPrefix + "mDimParams:");
                    displayAnimator.mDimParams.printTo(subSubPrefix, pw);
                } else {
                pw.print(prefix); pw.print("no DimAnimator ");
                    pw.println(subPrefix + "no DimParams ");
                }
                if (displayAnimator.mScreenRotationAnimation != null) {
                    pw.println(subPrefix + "mScreenRotationAnimation:");
                    displayAnimator.mScreenRotationAnimation.printTo(subSubPrefix, pw);
                } else {
                    pw.print(subPrefix + "no ScreenRotationAnimation ");
                }
            }
            pw.println();
        }
    }

@@ -716,4 +771,29 @@ public class WindowAnimator {
            }
        }
    }

    private DisplayContentsAnimator getDisplayContentsAnimatorLocked(int displayId) {
        DisplayContentsAnimator displayAnimator = mDisplayContentsAnimators.get(displayId);
        if (displayAnimator == null) {
            displayAnimator = new DisplayContentsAnimator();
            mDisplayContentsAnimators.put(displayId, displayAnimator);
        }
        return displayAnimator;
    }

    void setScreenRotationAnimationLocked(int displayId, ScreenRotationAnimation animation) {
        getDisplayContentsAnimatorLocked(displayId).mScreenRotationAnimation = animation;
    }

    ScreenRotationAnimation getScreenRotationAnimationLocked(int displayId) {
        return getDisplayContentsAnimatorLocked(displayId).mScreenRotationAnimation;
    }

    private static class DisplayContentsAnimator {
        WinAnimatorList mWinAnimators = new WinAnimatorList();
        DimAnimator mDimAnimator = null;
        DimAnimator.Parameters mDimParams = null;
        DimSurface mWindowAnimationBackgroundSurface = null;
        ScreenRotationAnimation mScreenRotationAnimation = null;
    }
}
+61 −46

File changed.

Preview size limit exceeded, changes collapsed.

Loading