diff options
| author | Robert Carr <racarr@google.com> | 2021-03-11 12:13:37 -0800 |
|---|---|---|
| committer | Rob Carr <racarr@google.com> | 2021-03-30 04:10:05 +0000 |
| commit | ee90cd4871121ae02da9b0b4d3fd7573084d729e (patch) | |
| tree | 219dd74c302eba9533dc2edeab8f94f0d44157fb /core/java/android/view/View.java | |
| parent | 64f83419987f126fe7bd1a0edfe95caa7076f8ac (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/View.java')
| -rw-r--r-- | core/java/android/view/View.java | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index 615dd82fb848..612058ebcea5 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -29541,6 +29541,10 @@ public class View implements Drawable.Callback, KeyEvent.Callback, return mScrollCaptureInternal; } + ViewRoot getViewRoot() { + return mViewRootImpl; + } + public void dump(String prefix, PrintWriter writer) { String innerPrefix = prefix + " "; writer.println(prefix + "AttachInfo:"); @@ -30928,4 +30932,20 @@ public class View implements Drawable.Callback, KeyEvent.Callback, callback.onDisplayHashError(DISPLAY_HASH_ERROR_UNKNOWN); } } + + /** + * @return The {@link android.view.ViewRoot} interface for this View. This will only + * return a non-null value when called between {@link #onAttachedToWindow} and + * {@link #onDetachedFromWindow}. + * + * The ViewRoot itself is not a View, it is just the interface to the windowing-system + * object that contains the entire view hierarchy. For the root View of a given hierarchy + * see {@link #getRootView}. + */ + public @Nullable ViewRoot getViewRoot() { + if (mAttachInfo != null) { + return mAttachInfo.getViewRoot(); + } + return null; + } } |
