summaryrefslogtreecommitdiff
path: root/core/java/android/view/ViewRootImpl.java
diff options
context:
space:
mode:
authorRobert Carr <racarr@google.com>2021-03-11 12:13:37 -0800
committerRob Carr <racarr@google.com>2021-03-30 04:10:05 +0000
commitee90cd4871121ae02da9b0b4d3fd7573084d729e (patch)
tree219dd74c302eba9533dc2edeab8f94f0d44157fb /core/java/android/view/ViewRootImpl.java
parent64f83419987f126fe7bd1a0edfe95caa7076f8ac (diff)
Expose API for using SurfaceControl with ViewRootImpl
This API is appropriately called "ViewRoot". So far we just expose an API surface to reparent SurfaceControl to the ViewRoot (but without exposing the ViewRoot's SurfaceControl, to encourage developers not to shoot themselves in the foot) and to synchronize with the drawing of the ViewRoot SurfaceControl. Bug: 173463039 Test: ViewRootSyncTests Change-Id: I8ce0ed4b3efe50cdb3b71ae0f05ce25438d42368
Diffstat (limited to 'core/java/android/view/ViewRootImpl.java')
-rw-r--r--core/java/android/view/ViewRootImpl.java19
1 files changed, 18 insertions, 1 deletions
diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java
index 426c9504c4f9..c3770f0ef478 100644
--- a/core/java/android/view/ViewRootImpl.java
+++ b/core/java/android/view/ViewRootImpl.java
@@ -224,7 +224,7 @@ import java.util.concurrent.CountDownLatch;
*/
@SuppressWarnings({"EmptyCatchBlock", "PointlessBooleanExpression"})
public final class ViewRootImpl implements ViewParent,
- View.AttachInfo.Callbacks, ThreadedRenderer.DrawCallbacks {
+ View.AttachInfo.Callbacks, ThreadedRenderer.DrawCallbacks, ViewRoot {
private static final String TAG = "ViewRootImpl";
private static final boolean DBG = false;
private static final boolean LOCAL_LOGV = false;
@@ -10249,4 +10249,21 @@ public final class ViewRootImpl implements ViewParent,
t.apply();
}
}
+
+ @Override
+ @Nullable public SurfaceControl.Transaction buildReparentTransaction(
+ @NonNull SurfaceControl child) {
+ if (mSurfaceControl.isValid()) {
+ return new SurfaceControl.Transaction().reparent(child, mSurfaceControl);
+ }
+ return null;
+ }
+
+ @Override
+ public boolean applyTransactionOnDraw(@NonNull SurfaceControl.Transaction t) {
+ registerRtFrameCallback(frame -> {
+ mergeWithNextTransaction(t, frame);
+ });
+ return true;
+ }
}