Loading core/java/android/view/AttachedSurfaceControl.java +18 −0 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package android.view; import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.UiThread; import android.graphics.Rect; import android.graphics.Region; import android.hardware.HardwareBuffer; import android.window.SurfaceSyncGroup; Loading Loading @@ -149,4 +150,21 @@ public interface AttachedSurfaceControl { default SurfaceSyncGroup getOrCreateSurfaceSyncGroup() { return null; } /** * Set a crop region on all children parented to the layer represented by this * AttachedSurfaceControl. This includes SurfaceView, and an example usage may * be to ensure that SurfaceView with {@link android.view.SurfaceView#setZOrderOnTop} * are cropped to a region not including the app bar. * * This cropped is expressed in terms of insets in window-space. Negative insets * are considered invalid and will produce an exception. Insets of zero will produce * the same result as if this function had never been called. * * @param insets The insets in each direction by which to bound the children * expressed in window-space. * @hide */ default void setChildBoundingInsets(@NonNull Rect insets) { } } core/java/android/view/ViewRootImpl.java +19 −3 Original line number Diff line number Diff line Loading @@ -919,6 +919,8 @@ public final class ViewRootImpl implements ViewParent, } } }; private final Rect mChildBoundingInsets = new Rect(); private boolean mChildBoundingInsetsChanged = false; private String mTag = TAG; Loading Loading @@ -2222,6 +2224,8 @@ public final class ViewRootImpl implements ViewParent, mTempRect.inset(mWindowAttributes.surfaceInsets.left, mWindowAttributes.surfaceInsets.top, mWindowAttributes.surfaceInsets.right, mWindowAttributes.surfaceInsets.bottom); mTempRect.inset(mChildBoundingInsets.left, mChildBoundingInsets.top, mChildBoundingInsets.right, mChildBoundingInsets.bottom); t.setWindowCrop(mBoundsLayer, mTempRect); } Loading @@ -2243,7 +2247,7 @@ public final class ViewRootImpl implements ViewParent, if (!sc.isValid()) return; if (updateBoundsLayer(t)) { mergeWithNextTransaction(t, mSurface.getNextFrameNumber()); applyTransactionOnDraw(t); } } Loading Loading @@ -3447,7 +3451,8 @@ public final class ViewRootImpl implements ViewParent, } } if (surfaceSizeChanged || surfaceReplaced || surfaceCreated || windowAttributesChanged) { if (surfaceSizeChanged || surfaceReplaced || surfaceCreated || windowAttributesChanged || mChildBoundingInsetsChanged) { // If the surface has been replaced, there's a chance the bounds layer is not parented // to the new layer. When updating bounds layer, also reparent to the main VRI // SurfaceControl to ensure it's correctly placed in the hierarchy. Loading @@ -3458,6 +3463,7 @@ public final class ViewRootImpl implements ViewParent, // enough. WMS doesn't want to keep around old children since they will leak when the // client creates new children. prepareSurfaces(); mChildBoundingInsetsChanged = false; } final boolean didLayout = layoutRequested && (!mStopped || mReportNextDraw); Loading Loading @@ -11078,7 +11084,7 @@ public final class ViewRootImpl implements ViewParent, @Nullable public SurfaceControl.Transaction buildReparentTransaction( @NonNull SurfaceControl child) { if (mSurfaceControl.isValid()) { return new SurfaceControl.Transaction().reparent(child, mSurfaceControl); return new SurfaceControl.Transaction().reparent(child, getBoundsLayer()); } return null; } Loading Loading @@ -11334,4 +11340,14 @@ public final class ViewRootImpl implements ViewParent, } mActiveSurfaceSyncGroup.addToSync(syncable, false /* parentSyncGroupMerge */); } @Override public void setChildBoundingInsets(@NonNull Rect insets) { if (insets.left < 0 || insets.top < 0 || insets.right < 0 || insets.bottom < 0) { throw new IllegalArgumentException("Negative insets passed to setChildBoundingInsets."); } mChildBoundingInsets.set(insets); mChildBoundingInsetsChanged = true; scheduleTraversals(); } } Loading
core/java/android/view/AttachedSurfaceControl.java +18 −0 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package android.view; import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.UiThread; import android.graphics.Rect; import android.graphics.Region; import android.hardware.HardwareBuffer; import android.window.SurfaceSyncGroup; Loading Loading @@ -149,4 +150,21 @@ public interface AttachedSurfaceControl { default SurfaceSyncGroup getOrCreateSurfaceSyncGroup() { return null; } /** * Set a crop region on all children parented to the layer represented by this * AttachedSurfaceControl. This includes SurfaceView, and an example usage may * be to ensure that SurfaceView with {@link android.view.SurfaceView#setZOrderOnTop} * are cropped to a region not including the app bar. * * This cropped is expressed in terms of insets in window-space. Negative insets * are considered invalid and will produce an exception. Insets of zero will produce * the same result as if this function had never been called. * * @param insets The insets in each direction by which to bound the children * expressed in window-space. * @hide */ default void setChildBoundingInsets(@NonNull Rect insets) { } }
core/java/android/view/ViewRootImpl.java +19 −3 Original line number Diff line number Diff line Loading @@ -919,6 +919,8 @@ public final class ViewRootImpl implements ViewParent, } } }; private final Rect mChildBoundingInsets = new Rect(); private boolean mChildBoundingInsetsChanged = false; private String mTag = TAG; Loading Loading @@ -2222,6 +2224,8 @@ public final class ViewRootImpl implements ViewParent, mTempRect.inset(mWindowAttributes.surfaceInsets.left, mWindowAttributes.surfaceInsets.top, mWindowAttributes.surfaceInsets.right, mWindowAttributes.surfaceInsets.bottom); mTempRect.inset(mChildBoundingInsets.left, mChildBoundingInsets.top, mChildBoundingInsets.right, mChildBoundingInsets.bottom); t.setWindowCrop(mBoundsLayer, mTempRect); } Loading @@ -2243,7 +2247,7 @@ public final class ViewRootImpl implements ViewParent, if (!sc.isValid()) return; if (updateBoundsLayer(t)) { mergeWithNextTransaction(t, mSurface.getNextFrameNumber()); applyTransactionOnDraw(t); } } Loading Loading @@ -3447,7 +3451,8 @@ public final class ViewRootImpl implements ViewParent, } } if (surfaceSizeChanged || surfaceReplaced || surfaceCreated || windowAttributesChanged) { if (surfaceSizeChanged || surfaceReplaced || surfaceCreated || windowAttributesChanged || mChildBoundingInsetsChanged) { // If the surface has been replaced, there's a chance the bounds layer is not parented // to the new layer. When updating bounds layer, also reparent to the main VRI // SurfaceControl to ensure it's correctly placed in the hierarchy. Loading @@ -3458,6 +3463,7 @@ public final class ViewRootImpl implements ViewParent, // enough. WMS doesn't want to keep around old children since they will leak when the // client creates new children. prepareSurfaces(); mChildBoundingInsetsChanged = false; } final boolean didLayout = layoutRequested && (!mStopped || mReportNextDraw); Loading Loading @@ -11078,7 +11084,7 @@ public final class ViewRootImpl implements ViewParent, @Nullable public SurfaceControl.Transaction buildReparentTransaction( @NonNull SurfaceControl child) { if (mSurfaceControl.isValid()) { return new SurfaceControl.Transaction().reparent(child, mSurfaceControl); return new SurfaceControl.Transaction().reparent(child, getBoundsLayer()); } return null; } Loading Loading @@ -11334,4 +11340,14 @@ public final class ViewRootImpl implements ViewParent, } mActiveSurfaceSyncGroup.addToSync(syncable, false /* parentSyncGroupMerge */); } @Override public void setChildBoundingInsets(@NonNull Rect insets) { if (insets.left < 0 || insets.top < 0 || insets.right < 0 || insets.bottom < 0) { throw new IllegalArgumentException("Negative insets passed to setChildBoundingInsets."); } mChildBoundingInsets.set(insets); mChildBoundingInsetsChanged = true; scheduleTraversals(); } }