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

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

Use new object to sync DimAnimator.

The controls for the DimAnimator were going through the H Handler
to sync with the Animator. We are switching to using the
LayoutToAnimator object for passing data from layout to animator.

Change-Id: Ib6d0afabba781c88bcc1c525e3ae424cf19ac1ad
parent 46282394
Loading
Loading
Loading
Loading
+19 −23
Original line number Diff line number Diff line
@@ -9,7 +9,6 @@ import static com.android.server.wm.WindowManagerService.LayoutFields.SET_UPDATE
import static com.android.server.wm.WindowManagerService.LayoutFields.SET_WALLPAPER_MAY_CHANGE;
import static com.android.server.wm.WindowManagerService.LayoutFields.SET_FORCE_HIDING_CHANGED;

import static com.android.server.wm.WindowManagerService.H.SET_DIM_PARAMETERS;
import static com.android.server.wm.WindowManagerService.H.UPDATE_ANIM_PARAMETERS;

import android.content.Context;
@@ -108,6 +107,7 @@ public class WindowAnimator {
        };

        mWindowAnimationBackgroundSurface = new DimSurface(mService.mFxSession);
        mDimAnimator = new DimAnimator(mService.mFxSession);
    }

    /** Locked on mAnimToLayout */
@@ -133,6 +133,24 @@ public class WindowAnimator {

            mWinAnimators = new ArrayList<WindowStateAnimator>(layoutToAnim.mWinAnimators);
            mWallpaperTarget = layoutToAnim.mWallpaperTarget;

            // Set the new DimAnimator params.
            DimAnimator.Parameters dimParams = layoutToAnim.mDimParams;
            if (dimParams == null) {
                mDimParams = dimParams;
            } 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
                        || existingDimWinAnimator.mAnimLayer < newWinAnimator.mAnimLayer)) {
                    mDimParams = dimParams;
                }
            }
        }
    }

@@ -571,28 +589,6 @@ public class WindowAnimator {
        mInnerDh = appHeight;
    }

    void startDimming(final WindowStateAnimator winAnimator, final float target,
                      final int width, final int height) {
        if (mDimAnimator == null) {
            mDimAnimator = new DimAnimator(mService.mFxSession);
        }
        // Only set dim params on the highest dimmed layer.
        final WindowStateAnimator dimWinAnimator = mDimParams == null
                ? null : mDimParams.mDimWinAnimator;
        // Don't turn on for an unshown surface, or for any layer but the highest dimmed one.
        if (winAnimator.mSurfaceShown &&
                (dimWinAnimator == null || !dimWinAnimator.mSurfaceShown
                || dimWinAnimator.mAnimLayer < winAnimator.mAnimLayer)) {
            mService.mH.sendMessage(mService.mH.obtainMessage(SET_DIM_PARAMETERS,
                    new DimAnimator.Parameters(winAnimator, width, height, target)));
        }
    }

    // TODO(cmautner): Move into Handler
    void stopDimming() {
        mService.mH.sendMessage(mService.mH.obtainMessage(SET_DIM_PARAMETERS, null));
    }

    boolean isDimming() {
        return mDimParams != null;
    }
+19 −12
Original line number Diff line number Diff line
@@ -6914,8 +6914,7 @@ public class WindowManagerService extends IWindowManager.Stub
        public static final int ANIMATOR_WHAT_OFFSET = 100000;
        public static final int SET_TRANSPARENT_REGION = ANIMATOR_WHAT_OFFSET + 1;
        public static final int SET_WALLPAPER_OFFSET = ANIMATOR_WHAT_OFFSET + 2;
        public static final int SET_DIM_PARAMETERS = ANIMATOR_WHAT_OFFSET + 3;
        public static final int CLEAR_PENDING_ACTIONS = ANIMATOR_WHAT_OFFSET + 4;
        public static final int CLEAR_PENDING_ACTIONS = ANIMATOR_WHAT_OFFSET + 3;

        private Session mLastReportedHold;

@@ -7412,13 +7411,6 @@ public class WindowManagerService extends IWindowManager.Stub
                    break;
                }

                case SET_DIM_PARAMETERS: {
                    mAnimator.mDimParams = (DimAnimator.Parameters) msg.obj;

                    scheduleAnimationLocked();
                    break;
                }

                case CLEAR_PENDING_ACTIONS: {
                    mAnimator.clearPendingActions();
                    break;
@@ -8539,8 +8531,7 @@ public class WindowManagerService extends IWindowManager.Stub
                        width = innerDw;
                        height = innerDh;
                    }
                    mAnimator.startDimming(winAnimator, w.mExiting ? 0 : w.mAttrs.dimAmount,
                            width, height);
                    startDimming(winAnimator, w.mExiting ? 0 : w.mAttrs.dimAmount, width, height);
                }
            }
        }
@@ -8806,7 +8797,7 @@ public class WindowManagerService extends IWindowManager.Stub
            }

            if (!mInnerFields.mDimming && mAnimator.isDimming()) {
                mAnimator.stopDimming();
                stopDimming();
            }
        } catch (RuntimeException e) {
            Log.wtf(TAG, "Unhandled exception in Window Manager", e);
@@ -9149,6 +9140,22 @@ public class WindowManagerService extends IWindowManager.Stub
        }
    }

    void setAnimDimParams(DimAnimator.Parameters params) {
        synchronized (mLayoutToAnim) {
            mLayoutToAnim.mDimParams = params;
            scheduleAnimationLocked();
        }
    }

    void startDimming(final WindowStateAnimator winAnimator, final float target,
                      final int width, final int height) {
        setAnimDimParams(new DimAnimator.Parameters(winAnimator, width, height, target));
    }

    void stopDimming() {
        setAnimDimParams(null);
    }

    boolean reclaimSomeSurfaceMemoryLocked(WindowStateAnimator winAnimator, String operation,
                                           boolean secure) {
        final Surface surface = winAnimator.mSurface;
+1 −1
Original line number Diff line number Diff line
@@ -1104,7 +1104,7 @@ class WindowStateAnimator {
                mAnimator.mPendingLayoutChanges |=
                        WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER;
                if ((w.mAttrs.flags & LayoutParams.FLAG_DIM_BEHIND) != 0) {
                    mAnimator.startDimming(this, w.mExiting ? 0 : w.mAttrs.dimAmount,
                    mService.startDimming(this, w.mExiting ? 0 : w.mAttrs.dimAmount,
                            mService.mAppDisplayWidth, mService.mAppDisplayHeight);
                }
            } catch (RuntimeException e) {