Loading core/api/current.txt +7 −0 Original line number Diff line number Diff line Loading @@ -48712,6 +48712,7 @@ package android.view { method @Nullable public android.graphics.drawable.Drawable getVerticalScrollbarThumbDrawable(); method @Nullable public android.graphics.drawable.Drawable getVerticalScrollbarTrackDrawable(); method public int getVerticalScrollbarWidth(); method @Nullable public android.view.ViewRoot getViewRoot(); method @Nullable public android.view.translation.ViewTranslationCallback getViewTranslationCallback(); method public android.view.ViewTreeObserver getViewTreeObserver(); method public int getVisibility(); Loading Loading @@ -49788,6 +49789,11 @@ package android.view { method public android.view.ViewPropertyAnimator zBy(float); } @UiThread public interface ViewRoot { method public boolean applyTransactionOnDraw(@NonNull android.view.SurfaceControl.Transaction); method @Nullable public android.view.SurfaceControl.Transaction buildReparentTransaction(@NonNull android.view.SurfaceControl); } public abstract class ViewStructure { ctor public ViewStructure(); method public abstract int addChildCount(int); Loading Loading @@ -49983,6 +49989,7 @@ package android.view { method @NonNull public java.util.List<android.graphics.Rect> getSystemGestureExclusionRects(); method public long getTransitionBackgroundFadeDuration(); method public android.transition.TransitionManager getTransitionManager(); method @Nullable public android.view.ViewRoot getViewRoot(); method public abstract int getVolumeControlStream(); method public android.view.WindowManager getWindowManager(); method public final android.content.res.TypedArray getWindowStyle(); core/java/android/view/View.java +20 −0 Original line number Diff line number Diff line Loading @@ -29543,6 +29543,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:"); Loading Loading @@ -30930,4 +30934,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; } } core/java/android/view/ViewRoot.java 0 → 100644 +53 −0 Original line number Diff line number Diff line /* * Copyright (C) 2021 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.view; import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.UiThread; /** * Provides an interface to the root-Surface of a View Hierarchy or Window. This * is used in combination with the {@link android.view.SurfaceControl} API to enable * attaching app created SurfaceControl to the ViewRoot's surface hierarchy, and enable * SurfaceTransactions to be performed in sync with the ViewRoot drawing. This object * is obtained from {@link android.view.View#getViewRoot} and * {@link android.view.Window#getViewRoot}. It must be used from the UI thread of * the object it was obtained from. */ @UiThread public interface ViewRoot { /** * Create a transaction which will reparent {@param child} to the ViewRoot. See * {@link SurfaceControl.Transaction#reparent}. This transacton must be applied * or merged in to another transaction by the caller, otherwise it will have * no effect. * * @param child The SurfaceControl to reparent. * @return A new transaction which performs the reparent operation when applied. */ @Nullable SurfaceControl.Transaction buildReparentTransaction(@NonNull SurfaceControl child); /** * Consume the passed in transaction, and request the ViewRoot to apply it with the * next draw. This transaction will be merged with the buffer transaction from the ViewRoot * and they will show up on-screen atomically synced. * * This will not cause a draw to be scheduled, and if there are no other changes * to the View hierarchy you may need to call {@link android.view.View#invalidate} */ boolean applyTransactionOnDraw(@NonNull SurfaceControl.Transaction t); } core/java/android/view/ViewRootImpl.java +18 −1 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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; } } core/java/android/view/Window.java +10 −0 Original line number Diff line number Diff line Loading @@ -2717,4 +2717,14 @@ public abstract class Window { public @Nullable WindowInsetsController getInsetsController() { return null; } /** * This will be null before a content view is added, e.g. via * {@link #setContentView} or {@link #addContentView}. * * @return The {@link android.view.ViewRoot} interface for this Window */ public @Nullable ViewRoot getViewRoot() { return null; } } Loading
core/api/current.txt +7 −0 Original line number Diff line number Diff line Loading @@ -48712,6 +48712,7 @@ package android.view { method @Nullable public android.graphics.drawable.Drawable getVerticalScrollbarThumbDrawable(); method @Nullable public android.graphics.drawable.Drawable getVerticalScrollbarTrackDrawable(); method public int getVerticalScrollbarWidth(); method @Nullable public android.view.ViewRoot getViewRoot(); method @Nullable public android.view.translation.ViewTranslationCallback getViewTranslationCallback(); method public android.view.ViewTreeObserver getViewTreeObserver(); method public int getVisibility(); Loading Loading @@ -49788,6 +49789,11 @@ package android.view { method public android.view.ViewPropertyAnimator zBy(float); } @UiThread public interface ViewRoot { method public boolean applyTransactionOnDraw(@NonNull android.view.SurfaceControl.Transaction); method @Nullable public android.view.SurfaceControl.Transaction buildReparentTransaction(@NonNull android.view.SurfaceControl); } public abstract class ViewStructure { ctor public ViewStructure(); method public abstract int addChildCount(int); Loading Loading @@ -49983,6 +49989,7 @@ package android.view { method @NonNull public java.util.List<android.graphics.Rect> getSystemGestureExclusionRects(); method public long getTransitionBackgroundFadeDuration(); method public android.transition.TransitionManager getTransitionManager(); method @Nullable public android.view.ViewRoot getViewRoot(); method public abstract int getVolumeControlStream(); method public android.view.WindowManager getWindowManager(); method public final android.content.res.TypedArray getWindowStyle();
core/java/android/view/View.java +20 −0 Original line number Diff line number Diff line Loading @@ -29543,6 +29543,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:"); Loading Loading @@ -30930,4 +30934,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; } }
core/java/android/view/ViewRoot.java 0 → 100644 +53 −0 Original line number Diff line number Diff line /* * Copyright (C) 2021 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.view; import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.UiThread; /** * Provides an interface to the root-Surface of a View Hierarchy or Window. This * is used in combination with the {@link android.view.SurfaceControl} API to enable * attaching app created SurfaceControl to the ViewRoot's surface hierarchy, and enable * SurfaceTransactions to be performed in sync with the ViewRoot drawing. This object * is obtained from {@link android.view.View#getViewRoot} and * {@link android.view.Window#getViewRoot}. It must be used from the UI thread of * the object it was obtained from. */ @UiThread public interface ViewRoot { /** * Create a transaction which will reparent {@param child} to the ViewRoot. See * {@link SurfaceControl.Transaction#reparent}. This transacton must be applied * or merged in to another transaction by the caller, otherwise it will have * no effect. * * @param child The SurfaceControl to reparent. * @return A new transaction which performs the reparent operation when applied. */ @Nullable SurfaceControl.Transaction buildReparentTransaction(@NonNull SurfaceControl child); /** * Consume the passed in transaction, and request the ViewRoot to apply it with the * next draw. This transaction will be merged with the buffer transaction from the ViewRoot * and they will show up on-screen atomically synced. * * This will not cause a draw to be scheduled, and if there are no other changes * to the View hierarchy you may need to call {@link android.view.View#invalidate} */ boolean applyTransactionOnDraw(@NonNull SurfaceControl.Transaction t); }
core/java/android/view/ViewRootImpl.java +18 −1 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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; } }
core/java/android/view/Window.java +10 −0 Original line number Diff line number Diff line Loading @@ -2717,4 +2717,14 @@ public abstract class Window { public @Nullable WindowInsetsController getInsetsController() { return null; } /** * This will be null before a content view is added, e.g. via * {@link #setContentView} or {@link #addContentView}. * * @return The {@link android.view.ViewRoot} interface for this Window */ public @Nullable ViewRoot getViewRoot() { return null; } }