mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-03-04 01:46:49 +00:00
Merge "Skip scheduling frame callback if view root is already detached" into sc-v2-dev am: a5642379d9
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Launcher3/+/16308550 Change-Id: Ic05deba16fd01fc2bda81b91a1273ba798b7c92a
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user