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

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

Merge "Defer a couple of Surface actions for WSAnimator."

parents 5d724f50 48ba1e7f
Loading
Loading
Loading
Loading
+42 −17
Original line number Diff line number Diff line
@@ -1972,6 +1972,11 @@ public class WindowManagerService extends IWindowManager.Stub
        }
    }

    // TODO(cmautner):  Move to WindowAnimator.
    void setWallpaperOffset(final WindowStateAnimator winAnimator, final int left, final int top) {
        mH.sendMessage(mH.obtainMessage(H.SET_WALLPAPER_OFFSET, left, top, winAnimator));
    }

    void updateWallpaperOffsetLocked(WindowState changingTarget, boolean sync) {
        final int dw = mAppDisplayWidth;
        final int dh = mAppDisplayHeight;
@@ -2010,10 +2015,8 @@ public class WindowManagerService extends IWindowManager.Stub
                            if (SHOW_TRANSACTIONS) logSurface(wallpaper,
                                    "POS " + wallpaper.mShownFrame.left
                                    + ", " + wallpaper.mShownFrame.top, null);
                            winAnimator.mSurfaceX = wallpaper.mShownFrame.left;
                            winAnimator.mSurfaceY = wallpaper.mShownFrame.top;
                            winAnimator.mSurface.setPosition(wallpaper.mShownFrame.left,
                                    wallpaper.mShownFrame.top);
                            setWallpaperOffset(winAnimator, (int) wallpaper.mShownFrame.left,
                                (int) wallpaper.mShownFrame.top);
                        } catch (RuntimeException e) {
                            Slog.w(TAG, "Error positioning surface of " + wallpaper
                                    + " pos=(" + wallpaper.mShownFrame.left
@@ -2475,24 +2478,19 @@ public class WindowManagerService extends IWindowManager.Stub
        }
    }

    // TODO(cmautner): Move to WindowStateAnimator.
    void setTransparentRegionHint(final WindowStateAnimator winAnimator, final Region region) {
        mH.sendMessage(mH.obtainMessage(H.SET_TRANSPARENT_REGION,
                new Pair<WindowStateAnimator, Region>(winAnimator, region)));
    }

    void setTransparentRegionWindow(Session session, IWindow client, Region region) {
        long origId = Binder.clearCallingIdentity();
        try {
            synchronized (mWindowMap) {
                WindowState w = windowForClientLocked(session, client, false);
                if ((w != null) && w.mHasSurface) {
                    if (SHOW_LIGHT_TRANSACTIONS) Slog.i(TAG,
                            ">>> OPEN TRANSACTION setTransparentRegion");
                    Surface.openTransaction();
                    try {
                        if (SHOW_TRANSACTIONS) logSurface(w,
                                "transparentRegionHint=" + region, null);
                        w.mWinAnimator.mSurface.setTransparentRegionHint(region);
                    } finally {
                        Surface.closeTransaction();
                        if (SHOW_LIGHT_TRANSACTIONS) Slog.i(TAG,
                                "<<< CLOSE TRANSACTION setTransparentRegion");
                    }
                    setTransparentRegionHint(w.mWinAnimator, region);
                }
            }
        } finally {
@@ -2615,6 +2613,7 @@ public class WindowManagerService extends IWindowManager.Stub
        long origId = Binder.clearCallingIdentity();

        synchronized(mWindowMap) {
            // TODO(cmautner): synchronize on mAnimator or win.mWinAnimator.
            WindowState win = windowForClientLocked(session, client, false);
            if (win == null) {
                return 0;
@@ -6656,6 +6655,10 @@ public class WindowManagerService extends IWindowManager.Stub
        public static final int WAITING_FOR_DRAWN_TIMEOUT = 24;
        public static final int BULK_UPDATE_PARAMETERS = 25;

        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;

        private Session mLastReportedHold;

        public H() {
@@ -7079,6 +7082,28 @@ public class WindowManagerService extends IWindowManager.Stub

                        requestTraversalLocked();
                    }
                    break;
                }

                // Animation messages. Move to Window{State}Animator
                case SET_TRANSPARENT_REGION: {
                    // TODO(cmautner): Remove sync.
                    synchronized (mWindowMap) {
                        Pair<WindowStateAnimator, Region> pair =
                                (Pair<WindowStateAnimator, Region>) msg.obj;
                        final WindowStateAnimator winAnimator = pair.first;
                        winAnimator.setTransparentRegionHint(pair.second);
                    }
                    break;
                }

                case SET_WALLPAPER_OFFSET: {
                    // TODO(cmautner): Remove sync.
                    synchronized (mWindowMap) {
                        final WindowStateAnimator winAnimator = (WindowStateAnimator) msg.obj;
                        winAnimator.setWallpaperOffset(msg.arg1, msg.arg2);
                    }
                    break;
                }
            }
        }
+32 −2
Original line number Diff line number Diff line
@@ -9,6 +9,7 @@ import android.content.Context;
import android.graphics.Matrix;
import android.graphics.PixelFormat;
import android.graphics.Rect;
import android.graphics.Region;
import android.os.RemoteException;
import android.util.Slog;
import android.view.Surface;
@@ -357,7 +358,7 @@ class WindowStateAnimator {

    boolean finishDrawingLocked() {
        if (mDrawPending) {
            if (SHOW_TRANSACTIONS || WindowManagerService.DEBUG_ORIENTATION) Slog.v(
            if (SHOW_TRANSACTIONS || DEBUG_ORIENTATION) Slog.v(
                TAG, "finishDrawingLocked: " + this + " in " + mSurface);
            mCommitDrawPending = true;
            mDrawPending = false;
@@ -386,7 +387,7 @@ class WindowStateAnimator {
        if (mSurface == null) {
            mReportDestroySurface = false;
            mSurfacePendingDestroy = false;
            if (WindowManagerService.DEBUG_ORIENTATION) Slog.i(TAG,
            if (DEBUG_ORIENTATION) Slog.i(TAG,
                    "createSurface " + this + ": DRAW NOW PENDING");
            mDrawPending = true;
            mCommitDrawPending = false;
@@ -923,6 +924,34 @@ class WindowStateAnimator {
        }
    }

    void setTransparentRegionHint(final Region region) {
        if (SHOW_LIGHT_TRANSACTIONS) Slog.i(TAG,
            ">>> OPEN TRANSACTION setTransparentRegion");
        Surface.openTransaction();
        try {
            if (SHOW_TRANSACTIONS) WindowManagerService.logSurface(mWin,
                    "transparentRegionHint=" + region, null);
            mSurface.setTransparentRegionHint(region);
        } finally {
            Surface.closeTransaction();
            if (SHOW_LIGHT_TRANSACTIONS) Slog.i(TAG,
                    "<<< CLOSE TRANSACTION setTransparentRegion");
        }
    }

    void setWallpaperOffset(int left, int top) {
        Surface.openTransaction();
        try {
            mSurfaceX = left;
            mSurfaceY = top;
            mSurface.setPosition(left, top);
        } catch (RuntimeException e) {
            Slog.w(TAG, "Error positioning surface of " + mWin
                    + " pos=(" + left + "," + top + ")", e);
        }
        Surface.closeTransaction();
    }

    // This must be called while inside a transaction.
    boolean performShowLocked() {
        if (DEBUG_VISIBILITY) {
@@ -1053,6 +1082,7 @@ class WindowStateAnimator {
        applyAnimationLocked(transit, true);
    }

    // TODO(cmautner): Move back to WindowState?
    /**
     * Choose the correct animation and set it to the passed WindowState.
     * @param transit If WindowManagerPolicy.TRANSIT_PREVIEW_DONE and the app window has been drawn