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

Commit 83323f42 authored by Craig Mautner's avatar Craig Mautner Committed by Android (Google) Code Review
Browse files

Merge "Further decouple layout and animation."

parents 4791ce9d 9339c401
Loading
Loading
Loading
Loading
+9 −14
Original line number Diff line number Diff line
@@ -22,7 +22,6 @@ public class AppWindowAnimator {

    boolean animating;
    Animation animation;
    boolean animInitialized;
    boolean hasTransformation;
    final Transformation transformation = new Transformation();

@@ -58,12 +57,15 @@ public class AppWindowAnimator {
        mAnimator = atoken.mAnimator;
    }

    public void setAnimation(Animation anim) {
    public void setAnimation(Animation anim, int width, int height) {
        if (WindowManagerService.localLOGV) Slog.v(
            TAG, "Setting animation in " + mAppToken + ": " + anim);
            TAG, "Setting animation in " + mAppToken + ": " + anim
                    + " wxh=" + width + "x" + height);
        animation = anim;
        animating = false;
        animInitialized = anim.isInitialized();
        if (!anim.isInitialized()) {
            anim.initialize(width, height, width, height);
        }
        anim.restrictDuration(WindowManagerService.MAX_ANIMATION_DURATION);
        anim.scaleCurrentDuration(mService.mTransitionAnimationScale);
        int zorder = anim.getZAdjustment();
@@ -87,7 +89,6 @@ public class AppWindowAnimator {
    public void setDummyAnimation() {
        if (WindowManagerService.localLOGV) Slog.v(TAG, "Setting dummy animation in " + mAppToken);
        animation = sDummyAnimation;
        animInitialized = false;
        hasTransformation = true;
        transformation.clear();
        transformation.setAlpha(mAppToken.reportedVisible ? 1 : 0);
@@ -97,7 +98,6 @@ public class AppWindowAnimator {
        if (animation != null) {
            animation = null;
            animating = true;
            animInitialized = false;
        }
        clearThumbnail();
        if (mAppToken.deferClearAllDrawn) {
@@ -189,7 +189,7 @@ public class AppWindowAnimator {
    }

    // This must be called while inside a transaction.
    boolean stepAnimationLocked(long currentTime, int dw, int dh) {
    boolean stepAnimationLocked(long currentTime) {
        if (mService.okToDisplay()) {
            // We will run animations as long as the display isn't frozen.

@@ -206,12 +206,8 @@ public class AppWindowAnimator {
                if (!animating) {
                    if (WindowManagerService.DEBUG_ANIM) Slog.v(
                        TAG, "Starting animation in " + mAppToken +
                        " @ " + currentTime + ": dw=" + dw + " dh=" + dh
                        + " scale=" + mService.mTransitionAnimationScale
                        " @ " + currentTime + " scale=" + mService.mTransitionAnimationScale
                        + " allDrawn=" + mAppToken.allDrawn + " animating=" + animating);
                    if (!animInitialized) {
                        animation.initialize(dw, dh, dw, dh);
                    }
                    animation.setStartTime(currentTime);
                    animating = true;
                    if (thumbnail != null) {
@@ -290,8 +286,7 @@ public class AppWindowAnimator {
                pw.print(" allDrawn="); pw.print(allDrawn);
                pw.print(" animLayerAdjustment="); pw.println(animLayerAdjustment);
        if (animating || animation != null) {
            pw.print(prefix); pw.print("animating="); pw.print(animating);
                    pw.print(" animInitialized="); pw.println(animInitialized);
            pw.print(prefix); pw.print("animating="); pw.println(animating);
            pw.print(prefix); pw.print("animation="); pw.println(animation);
        }
        if (hasTransformation) {
+9 −2
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.server.wm;

import android.graphics.PixelFormat;
import android.util.Slog;
import android.view.DisplayInfo;
import android.view.Surface;
import android.view.SurfaceSession;

@@ -31,8 +32,11 @@ class DimSurface {
    int mDimColor = 0;
    int mLayer = -1;
    int mLastDimWidth, mLastDimHeight;
    final DisplayContent mDisplayContent;

    DimSurface(SurfaceSession session, final int layerStack) {
    DimSurface(SurfaceSession session, DisplayContent displayContent) {
        mDisplayContent = displayContent;
        final int layerStack = displayContent.getDisplayId();
        try {
            if (WindowManagerService.DEBUG_SURFACE_TRACE) {
                mDimSurface = new WindowStateAnimator.SurfaceTrace(session,
@@ -58,7 +62,10 @@ class DimSurface {
    /**
     * Show the dim surface.
     */
    void show(int dw, int dh, int layer, int color) {
    void show(int layer, int color) {
        final DisplayInfo info = mDisplayContent.getDisplayInfo();
        final int dw = info.logicalWidth;
        final int dh = info.logicalHeight;
        if (mDimSurface == null) {
            Slog.e(TAG, "show: no Surface");
            return;
+7 −26
Original line number Diff line number Diff line
@@ -52,13 +52,6 @@ public class WindowAnimator {
    // Layout changes for individual Displays. Indexed by displayId.
    SparseIntArray mPendingLayoutChanges = new SparseIntArray();

    // TODO: Assign these from each iteration through DisplayContent. Only valid between loops.
    /** Overall window dimensions */
    int mDw, mDh;

    /** Interior window dimensions */
    int mInnerDw, mInnerDh;

    /** Time of current animation step. Reset on each iteration */
    long mCurrentTime;

@@ -311,7 +304,7 @@ public class WindowAnimator {
            final AppWindowAnimator appAnimator = mAppAnimators.get(i);
            final boolean wasAnimating = appAnimator.animation != null
                    && appAnimator.animation != AppWindowAnimator.sDummyAnimation;
            if (appAnimator.stepAnimationLocked(mCurrentTime, mInnerDw, mInnerDh)) {
            if (appAnimator.stepAnimationLocked(mCurrentTime)) {
                mAnimating = true;
            } else if (wasAnimating) {
                // stopped animating, do one more pass through the layout
@@ -327,7 +320,7 @@ public class WindowAnimator {
            final AppWindowAnimator appAnimator = mService.mExitingAppTokens.get(i).mAppAnimator;
            final boolean wasAnimating = appAnimator.animation != null
                    && appAnimator.animation != AppWindowAnimator.sDummyAnimation;
            if (appAnimator.stepAnimationLocked(mCurrentTime, mInnerDw, mInnerDh)) {
            if (appAnimator.stepAnimationLocked(mCurrentTime)) {
                mAnimating = true;
            } else if (wasAnimating) {
                // stopped animating, do one more pass through the layout
@@ -579,7 +572,7 @@ public class WindowAnimator {
            }

            if (windowAnimationBackgroundSurface != null) {
                windowAnimationBackgroundSurface.show(mDw, mDh,
                windowAnimationBackgroundSurface.show(
                        animLayer - WindowManagerService.LAYER_OFFSET_DIM,
                        windowAnimationBackgroundColor);
            }
@@ -590,9 +583,9 @@ public class WindowAnimator {
        }
    }

    /** See if any windows have been drawn, so they (and others associated with them) can now be
     *  shown. */
    private void testTokenMayBeDrawnLocked() {
        // See if any windows have been drawn, so they (and others
        // associated with them) can now be shown.
        final int NT = mAppAnimators.size();
        for (int i=0; i<NT; i++) {
            AppWindowAnimator appAnimator = mAppAnimators.get(i);
@@ -750,14 +743,6 @@ public class WindowAnimator {
        mCurrentFocus = currentFocus;
    }

    void setDisplayDimensions(final int curWidth, final int curHeight,
                        final int appWidth, final int appHeight) {
        mDw = curWidth;
        mDh = curHeight;
        mInnerDw = appWidth;
        mInnerDh = appHeight;
    }

    boolean isDimmingLocked(int displayId) {
        return getDisplayContentsAnimatorLocked(displayId).mDimParams != null;
    }
@@ -876,10 +861,6 @@ public class WindowAnimator {
                    pw.print(" mForceHiding="); pw.println(forceHidingToString());
            pw.print(prefix); pw.print("mCurrentTime=");
                    pw.println(TimeUtils.formatUptime(mCurrentTime));
            pw.print(prefix); pw.print("mDw=");
                    pw.print(mDw); pw.print(" mDh="); pw.print(mDh);
                    pw.print(" mInnerDw="); pw.print(mInnerDw);
                    pw.print(" mInnerDh="); pw.println(mInnerDh);
        }
        if (mBulkUpdateParams != 0) {
            pw.print(prefix); pw.print("mBulkUpdateParams=0x");
@@ -961,8 +942,8 @@ public class WindowAnimator {

        public DisplayContentsAnimator(int displayId) {
            mDimAnimator = new DimAnimator(mService.mFxSession, displayId);
            mWindowAnimationBackgroundSurface =
                    new DimSurface(mService.mFxSession, displayId);
            mWindowAnimationBackgroundSurface = new DimSurface(mService.mFxSession,
                    mService.getDisplayContentLocked(displayId));
        }
    }
}
+4 −10
Original line number Diff line number Diff line
@@ -3076,10 +3076,11 @@ public class WindowManagerService extends IWindowManager.Stub
        // is running.
        if (okToDisplay()) {
            DisplayInfo displayInfo = getDefaultDisplayInfoLocked();
            final int width = displayInfo.appWidth;
            final int height = displayInfo.appHeight;
            if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) Slog.v(TAG, "applyAnimation: atoken="
                    + atoken);
            Animation a = mAppTransition.loadAnimation(lp, transit, enter,
                    displayInfo.appWidth,  displayInfo.appHeight);
            Animation a = mAppTransition.loadAnimation(lp, transit, enter, width, height);
            if (a != null) {
                if (DEBUG_ANIM) {
                    RuntimeException e = null;
@@ -3089,7 +3090,7 @@ public class WindowManagerService extends IWindowManager.Stub
                    }
                    Slog.v(TAG, "Loaded animation " + a + " for " + atoken, e);
                }
                atoken.mAppAnimator.setAnimation(a);
                atoken.mAppAnimator.setAnimation(a, width, height);
            }
        } else {
            atoken.mAppAnimator.clearAnimation();
@@ -6257,8 +6258,6 @@ public class WindowManagerService extends IWindowManager.Stub
            displayInfo.getAppMetrics(mDisplayMetrics, null);
            mDisplayManagerService.setDisplayInfoOverrideFromWindowManager(
                    displayContent.getDisplayId(), displayInfo);

            mAnimator.setDisplayDimensions(dw, dh, appWidth, appHeight);
        }
        if (false) {
            Slog.i(TAG, "Set app display size: " + appWidth + " x " + appHeight);
@@ -6563,11 +6562,6 @@ public class WindowManagerService extends IWindowManager.Stub
            mIsTouchDevice = mContext.getPackageManager().hasSystemFeature(
                    PackageManager.FEATURE_TOUCHSCREEN);

            final DisplayInfo displayInfo = getDefaultDisplayInfoLocked();
            mAnimator.setDisplayDimensions(
                    displayInfo.logicalWidth, displayInfo.logicalHeight,
                    displayInfo.appWidth, displayInfo.appHeight);

            mPolicy.setInitialDisplaySize(displayContent.getDisplay(),
                    displayContent.mInitialDisplayWidth,
                    displayContent.mInitialDisplayHeight,