From 8a3568667f5481724e525a8118ce0c5658f1a232 Mon Sep 17 00:00:00 2001 From: Vishnu Nair Date: Thu, 18 Feb 2021 09:04:16 -0800 Subject: [PATCH] SurfaceControlViewHost: Always set FLAG_HARDWARE_ACCELERATED for embedded views If FLAG_HARDWARE_ACCELERATED is not set, view framework will not use hw rendering and the shadows will not be rendered. Fix this by adding the flag when setting the view in SurfaceControlViewHost. The public api already sets this flag, so this brings parity to the internal api as well. Test: Embedded window can draw shadows Fixes: 180613222 Change-Id: Ife84ea9e09d415679fdf973bbc572eda360921e4 --- .../android/view/SurfaceControlViewHost.java | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/core/java/android/view/SurfaceControlViewHost.java b/core/java/android/view/SurfaceControlViewHost.java index 18029af6a85e7..870fd8cc4f5d8 100644 --- a/core/java/android/view/SurfaceControlViewHost.java +++ b/core/java/android/view/SurfaceControlViewHost.java @@ -217,16 +217,6 @@ public class SurfaceControlViewHost { } } - /** - * @hide - */ - @TestApi - public void setView(@NonNull View view, @NonNull WindowManager.LayoutParams attrs) { - Objects.requireNonNull(view); - view.setLayoutParams(attrs); - mViewRoot.setView(view, attrs, null); - } - /** * Set the root view of the SurfaceControlViewHost. This view will render in to * the SurfaceControl, and receive input based on the SurfaceControls positioning on @@ -240,10 +230,20 @@ public class SurfaceControlViewHost { final WindowManager.LayoutParams lp = new WindowManager.LayoutParams(width, height, WindowManager.LayoutParams.TYPE_APPLICATION, 0, PixelFormat.TRANSPARENT); - lp.flags |= WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED; setView(view, lp); } + /** + * @hide + */ + @TestApi + public void setView(@NonNull View view, @NonNull WindowManager.LayoutParams attrs) { + Objects.requireNonNull(view); + attrs.flags |= WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED; + view.setLayoutParams(attrs); + mViewRoot.setView(view, attrs, null); + } + /** * @return The view passed to setView, or null if none has been passed. */