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

Commit a5642379 authored by Winson Chung's avatar Winson Chung Committed by Android (Google) Code Review
Browse files

Merge "Skip scheduling frame callback if view root is already detached" into sc-v2-dev

parents 426b021e e2074f01
Loading
Loading
Loading
Loading
+7 −5
Original line number Diff line number Diff line
@@ -15,8 +15,10 @@
 */
package com.android.quickstep;

import android.graphics.HardwareRenderer;
import android.os.Handler;
import android.view.View;
import android.view.ViewRootImpl;

import com.android.launcher3.Utilities;
import com.android.systemui.shared.system.ViewRootImplCompat;
@@ -45,9 +47,9 @@ public class ViewUtils {
        return new FrameHandler(view, onFinishRunnable, canceled).schedule();
    }

    private static class FrameHandler implements LongConsumer {
    private static class FrameHandler implements HardwareRenderer.FrameDrawingCallback {

        final ViewRootImplCompat mViewRoot;
        final ViewRootImpl mViewRoot;
        final Runnable mFinishCallback;
        final BooleanSupplier mCancelled;
        final Handler mHandler;
@@ -55,14 +57,14 @@ public class ViewUtils {
        int mDeferFrameCount = 1;

        FrameHandler(View view, Runnable finishCallback, BooleanSupplier cancelled) {
            mViewRoot = new ViewRootImplCompat(view);
            mViewRoot = view.getViewRootImpl();
            mFinishCallback = finishCallback;
            mCancelled = cancelled;
            mHandler = new Handler();
        }

        @Override
        public void accept(long l) {
        public void onFrameDraw(long frame) {
            Utilities.postAsyncCallback(mHandler, this::onFrame);
        }

@@ -83,7 +85,7 @@ public class ViewUtils {
        }

        private boolean schedule() {
            if (mViewRoot.isValid()) {
            if (mViewRoot.getView() != null) {
                mViewRoot.registerRtFrameCallback(this);
                mViewRoot.getView().invalidate();
                return true;
+5 −5
Original line number Diff line number Diff line
@@ -22,10 +22,10 @@ import android.os.Message;
import android.view.SurfaceControl;
import android.view.SurfaceControl.Transaction;
import android.view.View;
import android.view.ViewRootImpl;

import com.android.quickstep.RemoteAnimationTargets.ReleaseCheck;
import com.android.systemui.shared.system.SyncRtSurfaceTransactionApplierCompat.SurfaceParams;
import com.android.systemui.shared.system.ViewRootImplCompat;

import java.util.function.Consumer;

@@ -41,7 +41,7 @@ public class SurfaceTransactionApplier extends ReleaseCheck {
    private static final int MSG_UPDATE_SEQUENCE_NUMBER = 0;

    private final SurfaceControl mBarrierSurfaceControl;
    private final ViewRootImplCompat mTargetViewRootImpl;
    private final ViewRootImpl mTargetViewRootImpl;
    private final Handler mApplyHandler;

    private int mLastSequenceNumber = 0;
@@ -50,8 +50,8 @@ public class SurfaceTransactionApplier extends ReleaseCheck {
     * @param targetView The view in the surface that acts as synchronization anchor.
     */
    public SurfaceTransactionApplier(View targetView) {
        mTargetViewRootImpl = new ViewRootImplCompat(targetView);
        mBarrierSurfaceControl = mTargetViewRootImpl.getRenderSurfaceControl();
        mTargetViewRootImpl = targetView.getViewRootImpl();
        mBarrierSurfaceControl = mTargetViewRootImpl.getSurfaceControl();
        mApplyHandler = new Handler(this::onApplyMessage);
    }

@@ -109,7 +109,7 @@ public class SurfaceTransactionApplier extends ReleaseCheck {
        if (targetView == null) {
            // No target view, no applier
            callback.accept(null);
        } else if (new ViewRootImplCompat(targetView).isValid()) {
        } else if (targetView.isAttachedToWindow()) {
            // Already attached, we're good to go
            callback.accept(new SurfaceTransactionApplier(targetView));
        } else {