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

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

Merge "Clean up FocusedStackFrame layer setting."

parents 3dc75ac6 f7666467
Loading
Loading
Loading
Loading
+14 −3
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.server.wm;

import static com.android.server.wm.WindowManagerService.DEBUG_STACK;
import static com.android.server.wm.WindowManagerService.DEBUG_SURFACE_TRACE;

import android.graphics.Canvas;
import android.graphics.Color;
@@ -29,6 +30,8 @@ import android.view.Surface;
import android.view.SurfaceControl;
import android.view.SurfaceSession;

import com.android.server.wm.WindowStateAnimator.SurfaceTrace;

class FocusedStackFrame {
    private static final String TAG = "FocusedStackFrame";
    private static final int THICKNESS = 10;
@@ -43,10 +46,14 @@ class FocusedStackFrame {
    public FocusedStackFrame(Display display, SurfaceSession session) {
        SurfaceControl ctrl = null;
        try {
            if (DEBUG_SURFACE_TRACE) {
                ctrl = new SurfaceTrace(session, "FocusedStackFrame",
                    1, 1, PixelFormat.TRANSLUCENT, SurfaceControl.HIDDEN);
            } else {
                ctrl = new SurfaceControl(session, "FocusedStackFrame",
                    1, 1, PixelFormat.TRANSLUCENT, SurfaceControl.HIDDEN);
            }
            ctrl.setLayerStack(display.getLayerStack());
            ctrl.setLayer(WindowManagerService.TYPE_LAYER_MULTIPLIER * 102);
            ctrl.setAlpha(ALPHA);
            mSurface.copyFrom(ctrl);
        } catch (SurfaceControl.OutOfResourcesException e) {
@@ -127,4 +134,8 @@ class FocusedStackFrame {
        if (DEBUG_STACK) Slog.i(TAG, "setBounds: bounds=" + bounds);
        mBounds.set(bounds);
    }

    public void setLayer(int layer) {
        mSurfaceControl.setLayer(layer);
    }
}
+2 −0
Original line number Diff line number Diff line
@@ -625,6 +625,8 @@ public class WindowAnimator {
                }
            }

            mService.setFocusedStackLayer();

            if (mService.mWatermark != null) {
                mService.mWatermark.drawIfNeeded();
            }
+40 −15
Original line number Diff line number Diff line
@@ -218,6 +218,11 @@ public class WindowManagerService extends IWindowManager.Stub
     */
    static final int LAYER_OFFSET_BLUR = 2;

    /**
     * FocusedStackFrame layer is immediately above focused window.
     */
    static final int LAYER_OFFSET_FOCUSED_STACK = 1;

    /**
     * Animation thumbnail is as far as possible below the window above
     * the thumbnail (or in other words as far as possible above the window
@@ -405,6 +410,8 @@ public class WindowManagerService extends IWindowManager.Stub
    StrictModeFlash mStrictModeFlash;
    FocusedStackFrame mFocusedStackFrame;

    int mFocusedStackLayer;

    final float[] mTmpFloats = new float[9];

    boolean mDisplayReady;
@@ -3686,7 +3693,32 @@ public class WindowManagerService extends IWindowManager.Stub
        }
    }

    void setFocusedStackFrame(TaskStack stack) {
    /** Call while in a Surface transaction. */
    void setFocusedStackLayer() {
        mFocusedStackLayer = 0;
        final WindowList windows = mFocusedApp.allAppWindows;
        for (int i = windows.size() - 1; i >= 0; --i) {
            final WindowState win = windows.get(i);
            final int animLayer = win.mWinAnimator.mAnimLayer;
            if (win.mAttachedWindow == null && win.isVisibleLw() &&
                    animLayer > mFocusedStackLayer) {
                mFocusedStackLayer = animLayer + LAYER_OFFSET_FOCUSED_STACK;
            }
        }
        if (DEBUG_LAYERS) Slog.v(TAG, "Setting FocusedStackFrame to layer=" +
                mFocusedStackLayer);
        mFocusedStackFrame.setLayer(mFocusedStackLayer);
    }

    void setFocusedStackFrame() {
        final TaskStack stack;
        if (mFocusedApp != null) {
            Task task = mTaskIdToTask.get(mFocusedApp.groupId);
            stack = task.mStack;
            task.getDisplayContent().mTapDetector.setStackBounds(stack.mStackBox.mBounds);
        } else {
            stack = null;
        }
        if (SHOW_LIGHT_TRANSACTIONS) Slog.i(TAG, ">>> OPEN TRANSACTION setFocusedStackFrame");
        SurfaceControl.openTransaction();
        try {
@@ -7858,13 +7890,14 @@ public class WindowManagerService extends IWindowManager.Stub
                layerChanged = true;
                anyLayerChanged = true;
            }
            final AppWindowToken wtoken = w.mAppToken;
            oldLayer = winAnimator.mAnimLayer;
            if (w.mTargetAppToken != null) {
                winAnimator.mAnimLayer =
                        w.mLayer + w.mTargetAppToken.mAppAnimator.animLayerAdjustment;
            } else if (w.mAppToken != null) {
            } else if (wtoken != null) {
                winAnimator.mAnimLayer =
                        w.mLayer + w.mAppToken.mAppAnimator.animLayerAdjustment;
                        w.mLayer + wtoken.mAppAnimator.animLayerAdjustment;
            } else {
                winAnimator.mAnimLayer = w.mLayer;
            }
@@ -7884,8 +7917,8 @@ public class WindowManagerService extends IWindowManager.Stub
            if (DEBUG_LAYERS) Slog.v(TAG, "Assign layer " + w + ": "
                    + "mBase=" + w.mBaseLayer
                    + " mLayer=" + w.mLayer
                    + (w.mAppToken == null ?
                            "" : " mAppLayer=" + w.mAppToken.mAppAnimator.animLayerAdjustment)
                    + (wtoken == null ?
                            "" : " mAppLayer=" + wtoken.mAppAnimator.animLayerAdjustment)
                    + " =mAnimLayer=" + winAnimator.mAnimLayer);
            //System.out.println(
            //    "Assigned layer " + curLayer + " to " + w.mClient.asBinder());
@@ -9269,15 +9302,7 @@ public class WindowManagerService extends IWindowManager.Stub
            }
        }

        final TaskStack stack;
        if (mFocusedApp != null) {
            Task task = mTaskIdToTask.get(mFocusedApp.groupId);
            stack = task.mStack;
            task.getDisplayContent().mTapDetector.setStackBounds(stack.mStackBox.mBounds);
        } else {
            stack = null;
        }
        setFocusedStackFrame(stack);
        setFocusedStackFrame();
        
        // Check to see if we are now in a state where the screen should
        // be enabled, because the window obscured flags have changed.
+0 −1
Original line number Diff line number Diff line
@@ -19,7 +19,6 @@ import android.util.Slog;
import android.view.Display;
import android.view.DisplayInfo;
import android.view.MagnificationSpec;
import android.view.Surface;
import android.view.SurfaceControl;
import android.view.SurfaceSession;
import android.view.WindowManager;