From 1b152e712159c0b82831a7567ce2f3c49cdc11bf Mon Sep 17 00:00:00 2001 From: John Reck Date: Tue, 24 Oct 2023 20:43:22 -0400 Subject: Implement automatic SV clipping Clip SV to its ancestor clipping bounds. This enables Z-above SurfaceView + scrolling containers to work more naturally Replaces the hidden API of setEnableSurfaceClipping Fixes: 298621623 Test: Sample app Change-Id: Iaa862598e37065677f5ba163a5ac7a6fab2739ea --- graphics/java/android/graphics/RenderNode.java | 37 ++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'graphics/java/android') diff --git a/graphics/java/android/graphics/RenderNode.java b/graphics/java/android/graphics/RenderNode.java index 15d26ebe66f6..27325694073c 100644 --- a/graphics/java/android/graphics/RenderNode.java +++ b/graphics/java/android/graphics/RenderNode.java @@ -271,6 +271,17 @@ public final class RenderNode { */ void positionChanged(long frameNumber, int left, int top, int right, int bottom); + /** + * Called by native by a Rendering Worker thread to update window position; includes + * the local rect that represents the clipped area of the RenderNode's bounds. + * + * @hide + */ + default void positionChanged(long frameNumber, int left, int top, int right, int bottom, + int clipLeft, int clipTop, int clipRight, int clipBottom) { + positionChanged(frameNumber, left, top, right, bottom); + } + /** * Called by JNI * @@ -286,6 +297,23 @@ public final class RenderNode { } } + /** + * Called by JNI + * + * @hide */ + static boolean callPositionChanged2(WeakReference weakListener, + long frameNumber, int left, int top, int right, int bottom, + int clipLeft, int clipTop, int clipRight, int clipBottom) { + final PositionUpdateListener listener = weakListener.get(); + if (listener != null) { + listener.positionChanged(frameNumber, left, top, right, bottom, clipLeft, + clipTop, clipRight, clipBottom); + return true; + } else { + return false; + } + } + /** * Call to apply a stretch effect to any child SurfaceControl layers * @@ -370,6 +398,15 @@ public final class RenderNode { } } + @Override + public void positionChanged(long frameNumber, int left, int top, int right, int bottom, + int clipLeft, int clipTop, int clipRight, int clipBottom) { + for (PositionUpdateListener pul : mListeners) { + pul.positionChanged(frameNumber, left, top, right, bottom, clipLeft, clipTop, + clipRight, clipBottom); + } + } + @Override public void positionLost(long frameNumber) { for (PositionUpdateListener pul : mListeners) { -- cgit v1.2.3-59-g8ed1b