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

Commit 43456733 authored by Valerie Hau's avatar Valerie Hau Committed by Android (Google) Code Review
Browse files

Merge "Move BLAST flag to WindowManagerService"

parents dfa78d37 779af293
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -97,6 +97,8 @@ interface IWindowManager

    IWindowSession openSession(in IWindowSessionCallback callback);

    boolean useBLAST();

    @UnsupportedAppUsage
    void getInitialDisplaySize(int displayId, out Point size);
    @UnsupportedAppUsage
+6 −7
Original line number Diff line number Diff line
@@ -22,7 +22,6 @@ import static android.view.WindowManagerPolicyConstants.APPLICATION_PANEL_SUBLAY

import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.TestApi;
import android.compat.annotation.UnsupportedAppUsage;
import android.content.Context;
import android.content.res.CompatibilityInfo.Translator;
@@ -43,8 +42,8 @@ import android.os.SystemClock;
import android.util.AttributeSet;
import android.util.Log;
import android.view.SurfaceControl.Transaction;
import android.view.accessibility.AccessibilityNodeInfo;
import android.view.SurfaceControlViewHost;
import android.view.accessibility.AccessibilityNodeInfo;

import com.android.internal.view.SurfaceCallbackHelper;

@@ -386,7 +385,7 @@ public class SurfaceView extends View implements ViewRootImpl.SurfaceChangedCall
                 * This gets called on a RenderThread worker thread, so members accessed here must
                 * be protected by a lock.
                 */
                final boolean useBLAST = WindowManagerGlobal.USE_BLAST_ADAPTER;
                final boolean useBLAST = WindowManagerGlobal.getInstance().useBLAST();
                viewRoot.registerRtFrameCallback(frame -> {
                    try {
                        final SurfaceControl.Transaction t = useBLAST ?
@@ -1120,7 +1119,7 @@ public class SurfaceView extends View implements ViewRootImpl.SurfaceChangedCall

    private void applySurfaceTransforms(SurfaceControl surface, SurfaceControl.Transaction t,
            Rect position, long frameNumber) {
        if (frameNumber > 0 && !WindowManagerGlobal.USE_BLAST_ADAPTER) {
        if (frameNumber > 0 && !WindowManagerGlobal.getInstance().useBLAST()) {
            final ViewRootImpl viewRoot = getViewRootImpl();

            t.deferTransactionUntil(surface, viewRoot.getRenderSurfaceControl(),
@@ -1138,7 +1137,7 @@ public class SurfaceView extends View implements ViewRootImpl.SurfaceChangedCall
    }

    private void setParentSpaceRectangle(Rect position, long frameNumber) {
        final boolean useBLAST = WindowManagerGlobal.USE_BLAST_ADAPTER;
        final boolean useBLAST = WindowManagerGlobal.getInstance().useBLAST();
        final ViewRootImpl viewRoot = getViewRootImpl();
        final SurfaceControl.Transaction t = useBLAST ? viewRoot.getBLASTSyncTransaction() :
            mRtTransaction;
@@ -1199,7 +1198,7 @@ public class SurfaceView extends View implements ViewRootImpl.SurfaceChangedCall

        @Override
        public void positionLost(long frameNumber) {
            boolean useBLAST = WindowManagerGlobal.USE_BLAST_ADAPTER;
            boolean useBLAST = WindowManagerGlobal.getInstance().useBLAST();
            if (DEBUG) {
                Log.d(TAG, String.format("%d windowPositionLost, frameNr = %d",
                        System.identityHashCode(this), frameNumber));
@@ -1538,7 +1537,7 @@ public class SurfaceView extends View implements ViewRootImpl.SurfaceChangedCall
    @Override
    public void invalidate(boolean invalidateCache) {
        super.invalidate(invalidateCache);
        if (!WindowManagerGlobal.USE_BLAST_ADAPTER) {
        if (!WindowManagerGlobal.getInstance().useBLAST()) {
            return;
        }
        final ViewRootImpl viewRoot = getViewRootImpl();
+7 −4
Original line number Diff line number Diff line
@@ -315,6 +315,8 @@ public final class ViewRootImpl implements ViewParent,
     */
    private boolean mForceNextConfigUpdate;

    private final boolean mUseBLASTAdapter;

    /**
     * Signals that compatibility booleans have been initialized according to
     * target SDK versions.
@@ -734,6 +736,7 @@ public final class ViewRootImpl implements ViewParent,

        loadSystemProperties();
        mImeFocusController = new ImeFocusController(this);
        mUseBLASTAdapter = WindowManagerGlobal.getInstance().useBLAST();
    }

    public static void addFirstDrawHandler(Runnable callback) {
@@ -861,7 +864,7 @@ public final class ViewRootImpl implements ViewParent,
                if (mWindowAttributes.packageName == null) {
                    mWindowAttributes.packageName = mBasePackageName;
                }
                if (WindowManagerGlobal.USE_BLAST_ADAPTER) {
                if (mUseBLASTAdapter) {
                    mWindowAttributes.privateFlags |=
                        WindowManager.LayoutParams.PRIVATE_FLAG_USE_BLAST;
                }
@@ -1341,7 +1344,7 @@ public final class ViewRootImpl implements ViewParent,
            }
            mWindowAttributes.privateFlags |= compatibleWindowFlag;

            if (WindowManagerGlobal.USE_BLAST_ADAPTER) {
            if (mUseBLASTAdapter) {
                mWindowAttributes.privateFlags |=
                    WindowManager.LayoutParams.PRIVATE_FLAG_USE_BLAST;
            }
@@ -7342,7 +7345,7 @@ public final class ViewRootImpl implements ViewParent,
                mPendingMergedConfiguration, mSurfaceControl, mTempInsets, mSurfaceSize,
                mBlastSurfaceControl);
        if (mSurfaceControl.isValid()) {
            if (!WindowManagerGlobal.USE_BLAST_ADAPTER) {
            if (!mUseBLASTAdapter) {
                mSurface.copyFrom(mSurfaceControl);
            } else {
                mSurface.transferFrom(getOrCreateBLASTSurface(mSurfaceSize.x,
@@ -9537,7 +9540,7 @@ public final class ViewRootImpl implements ViewParent,
    }

    SurfaceControl getRenderSurfaceControl() {
        if (WindowManagerGlobal.USE_BLAST_ADAPTER) {
        if (mUseBLASTAdapter) {
            return mBlastSurfaceControl;
        } else {
            return mSurfaceControl;
+13 −7
Original line number Diff line number Diff line
@@ -56,13 +56,7 @@ import java.util.ArrayList;
public final class WindowManagerGlobal {
    private static final String TAG = "WindowManager";

    private static final String WM_USE_BLAST_ADAPTER_FLAG = "wm_use_blast_adapter";

    /**
     * This flag controls whether ViewRootImpl will utilize the Blast Adapter
     * to send buffer updates to SurfaceFlinger
     */
    public static final boolean USE_BLAST_ADAPTER = false;
    private final boolean mUseBLASTAdapter;

    /**
     * The user is navigating with keys (not the touch screen), so
@@ -165,6 +159,11 @@ public final class WindowManagerGlobal {
    private Runnable mSystemPropertyUpdater;

    private WindowManagerGlobal() {
        try {
            mUseBLASTAdapter = getWindowManagerService().useBLAST();
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    @UnsupportedAppUsage
@@ -233,6 +232,13 @@ public final class WindowManagerGlobal {
        }
    }

    /**
     * Whether or not to use BLAST for ViewRootImpl
     */
    public boolean useBLAST() {
        return mUseBLASTAdapter;
    }

    @UnsupportedAppUsage
    public String[] getViewRootNames() {
        synchronized (mLock) {
+15 −0
Original line number Diff line number Diff line
@@ -187,6 +187,7 @@ import android.os.SystemService;
import android.os.Trace;
import android.os.UserHandle;
import android.os.WorkSource;
import android.provider.DeviceConfig;
import android.provider.Settings;
import android.service.vr.IVrManager;
import android.service.vr.IVrStateCallbacks;
@@ -309,6 +310,8 @@ public class WindowManagerService extends IWindowManager.Stub
        implements Watchdog.Monitor, WindowManagerPolicy.WindowManagerFuncs {
    private static final String TAG = TAG_WITH_CLASS_NAME ? "WindowManagerService" : TAG_WM;

    private static final String WM_USE_BLAST_ADAPTER_FLAG = "wm_use_blast_adapter";

    static final int LAYOUT_REPEAT_THRESHOLD = 4;

    static final boolean PROFILE_ORIENTATION = false;
@@ -623,6 +626,9 @@ public class WindowManagerService extends IWindowManager.Stub
    // The root of the device window hierarchy.
    RootWindowContainer mRoot;

    // Whether the system should use BLAST for ViewRootImpl
    final boolean mUseBLAST;

    int mDockedStackCreateMode = SPLIT_SCREEN_CREATE_MODE_TOP_OR_LEFT;
    Rect mDockedStackCreateBounds;

@@ -1137,6 +1143,10 @@ public class WindowManagerService extends IWindowManager.Stub
        mAnimator = new WindowAnimator(this);
        mRoot = new RootWindowContainer(this);

        mUseBLAST = DeviceConfig.getBoolean(
                    DeviceConfig.NAMESPACE_WINDOW_MANAGER_NATIVE_BOOT,
                    WM_USE_BLAST_ADAPTER_FLAG, false);

        mWindowPlacerLocked = new WindowSurfacePlacer(this);
        mTaskSnapshotController = new TaskSnapshotController(this);

@@ -5050,6 +5060,11 @@ public class WindowManagerService extends IWindowManager.Stub
        return new Session(this, callback);
    }

    @Override
    public boolean useBLAST() {
        return mUseBLAST;
    }

    @Override
    public void getInitialDisplaySize(int displayId, Point size) {
        synchronized (mGlobalLock) {