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

Commit d92fad65 authored by Vishnu Nair's avatar Vishnu Nair Committed by Android (Google) Code Review
Browse files

Merge "Create Surfaces, Transactions and SurfaceControls in Window Manager via a factory"

parents 29aee534 3319739a
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -814,7 +814,7 @@ final class AccessibilityController {
                private final Paint mPaint = new Paint();

                private final SurfaceControl mSurfaceControl;
                private final Surface mSurface = new Surface();
                private final Surface mSurface = mService.mSurfaceFactory.get();

                private final AnimationController mAnimationController;

@@ -967,7 +967,7 @@ final class AccessibilityController {
                }

                public void releaseSurface() {
                    mService.mTransactionFactory.make().remove(mSurfaceControl).apply();
                    mService.mTransactionFactory.get().remove(mSurfaceControl).apply();
                    mSurface.release();
                }

+8 −5
Original line number Diff line number Diff line
@@ -41,6 +41,8 @@ import android.view.animation.Animation;

import com.android.server.wm.SurfaceAnimator.Animatable;

import java.util.function.Supplier;

/**
 * Represents a surface that is displayed over an {@link AppWindowToken}
 */
@@ -55,8 +57,9 @@ class AppWindowThumbnail implements Animatable {
    private final int mHeight;
    private final boolean mRelative;

    AppWindowThumbnail(Transaction t, AppWindowToken appToken, GraphicBuffer thumbnailHeader) {
        this(t, appToken, thumbnailHeader, false /* relative */);
    AppWindowThumbnail(Supplier<Surface> surfaceFactory, Transaction t, AppWindowToken appToken,
            GraphicBuffer thumbnailHeader) {
        this(surfaceFactory, t, appToken, thumbnailHeader, false /* relative */);
    }

    /**
@@ -66,9 +69,9 @@ class AppWindowThumbnail implements Animatable {
     * @param relative Whether this thumbnail will be a child of appToken (and thus positioned
     *                 relative to it) or not.
     */
    AppWindowThumbnail(Transaction t, AppWindowToken appToken, GraphicBuffer thumbnailHeader,
            boolean relative) {
        this(t, appToken, thumbnailHeader, relative, new Surface(), null);
    AppWindowThumbnail(Supplier<Surface> surfaceFactory, Transaction t, AppWindowToken appToken,
            GraphicBuffer thumbnailHeader, boolean relative) {
        this(t, appToken, thumbnailHeader, relative, surfaceFactory.get(), null);
    }

    AppWindowThumbnail(Transaction t, AppWindowToken appToken, GraphicBuffer thumbnailHeader,
+8 −5
Original line number Diff line number Diff line
@@ -1793,8 +1793,8 @@ class AppWindowToken extends WindowToken implements WindowManagerService.AppFree
                    mWmService.mTaskSnapshotController.createTaskSnapshot(
                            task, 1 /* scaleFraction */);
            if (snapshot != null) {
                mThumbnail = new AppWindowThumbnail(t, this, snapshot.getGraphicBuffer(),
                        true /* relative */);
                mThumbnail = new AppWindowThumbnail(mWmService.mSurfaceFactory, t, this,
                        snapshot.getGraphicBuffer(), true /* relative */);
            }
        }
    }
@@ -2033,7 +2033,8 @@ class AppWindowToken extends WindowToken implements WindowManagerService.AppFree
        final boolean needsLetterbox = surfaceReady && w.isLetterboxedAppWindow() && fillsParent();
        if (needsLetterbox) {
            if (mLetterbox == null) {
                mLetterbox = new Letterbox(() -> makeChildSurface(null));
                mLetterbox = new Letterbox(() -> makeChildSurface(null),
                        mWmService.mTransactionFactory);
                mLetterbox.attachInput(w);
            }
            getPosition(mTmpPoint);
@@ -2981,7 +2982,8 @@ class AppWindowToken extends WindowToken implements WindowManagerService.AppFree
            return;
        }
        clearThumbnail();
        mThumbnail = new AppWindowThumbnail(getPendingTransaction(), this, thumbnailHeader);
        mThumbnail = new AppWindowThumbnail(mWmService.mSurfaceFactory, getPendingTransaction(),
                this, thumbnailHeader);
        mThumbnail.startAnimation(getPendingTransaction(), loadThumbnailAnimation(thumbnailHeader));
    }

@@ -3009,7 +3011,8 @@ class AppWindowToken extends WindowToken implements WindowManagerService.AppFree
        if (thumbnail == null) {
            return;
        }
        mThumbnail = new AppWindowThumbnail(getPendingTransaction(), this, thumbnail);
        mThumbnail = new AppWindowThumbnail(mWmService.mSurfaceFactory,
                getPendingTransaction(), this, thumbnail);
        final Animation animation =
                getDisplayContent().mAppTransition.createCrossProfileAppsThumbnailAnimationLocked(
                        win.getFrameLw());
+5 −4
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ import android.view.Surface.OutOfResourcesException;
import android.view.SurfaceControl;

import java.io.PrintWriter;
import java.util.function.Supplier;

/**
 * Four black surfaces put together to make a black frame.
@@ -97,7 +98,7 @@ public class BlackFrame {
    final BlackSurface[] mBlackSurfaces = new BlackSurface[4];

    final boolean mForceDefaultOrientation;
    private final TransactionFactory mTransactionFactory;
    private final Supplier<SurfaceControl.Transaction> mTransactionFactory;

    public void printTo(String prefix, PrintWriter pw) {
        pw.print(prefix); pw.print("Outer: "); mOuterRect.printShortString(pw);
@@ -112,8 +113,8 @@ public class BlackFrame {
        }
    }

    public BlackFrame(TransactionFactory factory, SurfaceControl.Transaction t, Rect outer,
            Rect inner, int layer, DisplayContent dc, boolean forceDefaultOrientation)
    public BlackFrame(Supplier<SurfaceControl.Transaction> factory, SurfaceControl.Transaction t,
            Rect outer, Rect inner, int layer, DisplayContent dc, boolean forceDefaultOrientation)
            throws OutOfResourcesException {
        boolean success = false;

@@ -151,7 +152,7 @@ public class BlackFrame {

    public void kill() {
        if (mBlackSurfaces != null) {
            SurfaceControl.Transaction t = mTransactionFactory.make();
            SurfaceControl.Transaction t = mTransactionFactory.get();
            for (int i=0; i<mBlackSurfaces.length; i++) {
                if (mBlackSurfaces[i] != null) {
                    if (SHOW_TRANSACTIONS || SHOW_SURFACE_ALLOC) Slog.i(TAG_WM,
+5 −3
Original line number Diff line number Diff line
@@ -34,6 +34,8 @@ import android.view.Surface;
import android.view.Surface.OutOfResourcesException;
import android.view.SurfaceControl;

import java.util.function.Supplier;

class CircularDisplayMask {
    private static final String TAG = TAG_WITH_CLASS_NAME ? "CircularDisplayMask" : TAG_WM;

@@ -43,7 +45,7 @@ class CircularDisplayMask {
    private Point mScreenSize;

    private final SurfaceControl mSurfaceControl;
    private final Surface mSurface = new Surface();
    private final Surface mSurface;
    private int mLastDW;
    private int mLastDH;
    private boolean mDrawNeeded;
@@ -53,10 +55,10 @@ class CircularDisplayMask {
    private boolean mDimensionsUnequal = false;
    private int mMaskThickness;

    public CircularDisplayMask(DisplayContent dc, int zOrder,
    CircularDisplayMask(Supplier<Surface> surfaceFactory, DisplayContent dc, int zOrder,
            int screenOffset, int maskThickness) {
        final Display display = dc.getDisplay();

        mSurface = surfaceFactory.get();
        mScreenSize = new Point();
        display.getSize(mScreenSize);
        if (mScreenSize.x != mScreenSize.y + screenOffset) {
Loading