From 5d53a7540a089a0397c9fb687bbccc7127a65698 Mon Sep 17 00:00:00 2001 From: John Reck Date: Mon, 8 Feb 2021 19:22:59 -0500 Subject: Wire up SurfaceView stretch effect Bug: 179047472 Test: StretchySurfaceViewActivity Change-Id: I7f3d582cc66fb732a557e9332edc6d186db2335c --- graphics/java/android/graphics/RenderNode.java | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'graphics/java/android') diff --git a/graphics/java/android/graphics/RenderNode.java b/graphics/java/android/graphics/RenderNode.java index 4a92cf11fa5c..f6f770be3de8 100644 --- a/graphics/java/android/graphics/RenderNode.java +++ b/graphics/java/android/graphics/RenderNode.java @@ -271,6 +271,16 @@ public final class RenderNode { */ void positionChanged(long frameNumber, int left, int top, int right, int bottom); + /** + * Call to apply a stretch effect to any child SurfaceControl layers + * + * TODO: Fold this into positionChanged & have HWUI do the ASurfaceControl calls? + * + * @hide + */ + default void applyStretch(long frameNumber, float left, float top, float right, + float bottom, float vecX, float vecY, float maxStretch) { } + /** * Called by native on RenderThread to notify that the view is no longer in the * draw tree. UI thread is blocked at this point. @@ -312,6 +322,14 @@ public final class RenderNode { pul.positionLost(frameNumber); } } + + @Override + public void applyStretch(long frameNumber, float left, float top, float right, float bottom, + float vecX, float vecY, float maxStretch) { + for (PositionUpdateListener pul : mListeners) { + pul.applyStretch(frameNumber, left, top, right, bottom, vecX, vecY, maxStretch); + } + } } /** @@ -707,7 +725,7 @@ public final class RenderNode { if (1.0 < vecY || vecY < -1.0) { throw new IllegalArgumentException("vecY must be in the range [-1, 1], was " + vecY); } - if (top <= bottom || right <= left) { + if (top >= bottom || left >= right) { throw new IllegalArgumentException( "Stretch region must not be empty, got " + new RectF(left, top, right, bottom).toString()); -- cgit v1.2.3-59-g8ed1b