summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/api/current.txt2
-rw-r--r--core/java/android/view/SurfaceView.java34
-rw-r--r--core/java/android/view/flags/view_flags.aconfig8
3 files changed, 43 insertions, 1 deletions
diff --git a/core/api/current.txt b/core/api/current.txt
index 00541afeea99..65e4f270121b 100644
--- a/core/api/current.txt
+++ b/core/api/current.txt
@@ -52578,10 +52578,12 @@ package android.view {
ctor public SurfaceView(android.content.Context, android.util.AttributeSet, int);
ctor public SurfaceView(android.content.Context, android.util.AttributeSet, int, int);
method public void applyTransactionToFrame(@NonNull android.view.SurfaceControl.Transaction);
+ method @FlaggedApi("android.view.flags.surface_view_set_composition_order") public int getCompositionOrder();
method public android.view.SurfaceHolder getHolder();
method @Deprecated @Nullable public android.os.IBinder getHostToken();
method public android.view.SurfaceControl getSurfaceControl();
method public void setChildSurfacePackage(@NonNull android.view.SurfaceControlViewHost.SurfacePackage);
+ method @FlaggedApi("android.view.flags.surface_view_set_composition_order") public void setCompositionOrder(int);
method @FlaggedApi("com.android.graphics.hwui.flags.limited_hdr") public void setDesiredHdrHeadroom(@FloatRange(from=0.0f, to=10000.0) float);
method public void setSecure(boolean);
method public void setSurfaceLifecycle(int);
diff --git a/core/java/android/view/SurfaceView.java b/core/java/android/view/SurfaceView.java
index f7745d14188e..83b4971c8621 100644
--- a/core/java/android/view/SurfaceView.java
+++ b/core/java/android/view/SurfaceView.java
@@ -16,6 +16,7 @@
package android.view;
+import static android.view.flags.Flags.FLAG_SURFACE_VIEW_SET_COMPOSITION_ORDER;
import static android.view.WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;
import static android.view.WindowManagerPolicyConstants.APPLICATION_MEDIA_OVERLAY_SUBLAYER;
import static android.view.WindowManagerPolicyConstants.APPLICATION_MEDIA_SUBLAYER;
@@ -770,6 +771,36 @@ public class SurfaceView extends View implements ViewRootImpl.SurfaceChangedCall
}
/**
+ * Controls the composition order of the SurfaceView. A non-negative composition order
+ * value indicates that the SurfaceView is composited on top of the parent window, while
+ * a negative composition order indicates that the SurfaceView is behind the parent
+ * window. A SurfaceView with a higher value appears above its peers with lower values.
+ * For SurfaceViews with the same composition order value, their relative order is
+ * undefined.
+ *
+ * @param compositionOrder the composition order of the surface view.
+ */
+ @FlaggedApi(FLAG_SURFACE_VIEW_SET_COMPOSITION_ORDER)
+ public void setCompositionOrder(int compositionOrder) {
+ mRequestedSubLayer = compositionOrder;
+ if (mSubLayer != mRequestedSubLayer) {
+ updateSurface();
+ }
+ }
+
+ /**
+ * Returns the composition order of the SurfaceView.
+ *
+ * @return composition order of the SurfaceView.
+ *
+ * @see #setCompositionOrder(int)
+ */
+ @FlaggedApi(FLAG_SURFACE_VIEW_SET_COMPOSITION_ORDER)
+ public int getCompositionOrder() {
+ return mRequestedSubLayer;
+ }
+
+ /**
* Control whether the surface view's surface is placed on top of another
* regular surface view in the window (but still behind the window itself).
* This is typically used to place overlays on top of an underlying media
@@ -1257,7 +1288,8 @@ public class SurfaceView extends View implements ViewRootImpl.SurfaceChangedCall
final Transaction surfaceUpdateTransaction = new Transaction();
if (creating) {
updateOpaqueFlag();
- final String name = "SurfaceView[" + viewRoot.getTitle().toString() + "]";
+ final String name = Integer.toHexString(System.identityHashCode(this))
+ + " SurfaceView[" + viewRoot.getTitle().toString() + "]";
createBlastSurfaceControls(viewRoot, name, surfaceUpdateTransaction);
} else if (mSurfaceControl == null) {
return;
diff --git a/core/java/android/view/flags/view_flags.aconfig b/core/java/android/view/flags/view_flags.aconfig
index 5115b132af93..1cf26ab64c09 100644
--- a/core/java/android/view/flags/view_flags.aconfig
+++ b/core/java/android/view/flags/view_flags.aconfig
@@ -109,3 +109,11 @@ flag {
purpose: PURPOSE_BUGFIX
}
}
+
+flag {
+ name: "surface_view_set_composition_order"
+ namespace: "window_surfaces"
+ description: "Add a SurfaceView composition order control API."
+ bug: "341021569"
+ is_fixed_read_only: true
+} \ No newline at end of file