Loading core/java/android/view/SurfaceControl.java +19 −9 Original line number Diff line number Diff line Loading @@ -321,14 +321,12 @@ public final class SurfaceControl implements Parcelable { public static final int FX_SURFACE_NORMAL = 0x00000000; /** * Surface creation flag: Creates a Dim surface. * Everything behind this surface is dimmed by the amount specified * in {@link Transaction#setAlpha(SurfaceControl, float)}. It is an error to lock a Dim * surface, since it doesn't have a backing store. * Surface creation flag: Creates a effect surface which * represents a solid color and or shadows. * * @hide */ public static final int FX_SURFACE_DIM = 0x00020000; public static final int FX_SURFACE_EFFECT = 0x00020000; /** * Surface creation flag: Creates a container surface. Loading Loading @@ -739,11 +737,11 @@ public final class SurfaceControl implements Parcelable { */ public Builder setColorLayer() { unsetBufferSize(); return setFlags(FX_SURFACE_DIM, FX_SURFACE_MASK); return setFlags(FX_SURFACE_EFFECT, FX_SURFACE_MASK); } private boolean isColorLayerSet() { return (mFlags & FX_SURFACE_DIM) == FX_SURFACE_DIM; return (mFlags & FX_SURFACE_EFFECT) == FX_SURFACE_EFFECT; } /** Loading Loading @@ -2078,6 +2076,7 @@ public final class SurfaceControl implements Parcelable { private final ArrayMap<SurfaceControl, Point> mResizedSurfaces = new ArrayMap<>(); Runnable mFreeNativeResources; private static final float[] INVALID_COLOR = {-1, -1, -1}; /** * @hide Loading Loading @@ -2533,8 +2532,9 @@ public final class SurfaceControl implements Parcelable { } /** * Sets a color for the Surface. * @param color A float array with three values to represent r, g, b in range [0..1] * Fills the surface with the specified color. * @param color A float array with three values to represent r, g, b in range [0..1]. An * invalid color will remove the color fill. * @hide */ @UnsupportedAppUsage Loading @@ -2544,6 +2544,16 @@ public final class SurfaceControl implements Parcelable { return this; } /** * Removes color fill. * @hide */ public Transaction unsetColor(SurfaceControl sc) { checkPreconditions(sc); nativeSetColor(mNativeObject, sc.mNativeObject, INVALID_COLOR); return this; } /** * Sets the security of the surface. Setting the flag is equivalent to creating the * Surface with the {@link #SECURE} flag. Loading core/java/com/android/internal/policy/DecorView.java +9 −4 Original line number Diff line number Diff line Loading @@ -1627,9 +1627,12 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind int opacity = PixelFormat.OPAQUE; final WindowConfiguration winConfig = getResources().getConfiguration().windowConfiguration; // TODO(b/149585281) remove when root task has the correct bounds for freeform final boolean renderShadowsInCompositor = mWindow.mRenderShadowsInCompositor && winConfig.getWindowingMode() != WINDOWING_MODE_FREEFORM; // If we draw shadows in the compositor we don't need to force the surface to be // translucent. if (winConfig.hasWindowShadow() && !mWindow.mRenderShadowsInCompositor) { if (winConfig.hasWindowShadow() && !renderShadowsInCompositor) { // If the window has a shadow, it must be translucent. opacity = PixelFormat.TRANSLUCENT; } else{ Loading Loading @@ -2414,16 +2417,18 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind } private void updateElevation() { final int windowingMode = getResources().getConfiguration().windowConfiguration.getWindowingMode(); final boolean renderShadowsInCompositor = mWindow.mRenderShadowsInCompositor && windowingMode != WINDOWING_MODE_FREEFORM; // If rendering shadows in the compositor, don't set an elevation on the view if (mWindow.mRenderShadowsInCompositor) { if (renderShadowsInCompositor) { return; } float elevation = 0; final boolean wasAdjustedForStack = mElevationAdjustedForStack; // Do not use a shadow when we are in resizing mode (mBackdropFrameRenderer not null) // since the shadow is bound to the content size and not the target size. final int windowingMode = getResources().getConfiguration().windowConfiguration.getWindowingMode(); if ((windowingMode == WINDOWING_MODE_FREEFORM) && !isResizing()) { elevation = hasWindowFocus() ? DECOR_SHADOW_FOCUSED_HEIGHT_IN_DIP : DECOR_SHADOW_UNFOCUSED_HEIGHT_IN_DIP; Loading services/core/java/com/android/server/wm/Task.java +14 −4 Original line number Diff line number Diff line Loading @@ -199,6 +199,7 @@ class Task extends WindowContainer<WindowContainer> { static final int INVALID_MIN_SIZE = -1; private float mShadowRadius = 0; private final Rect mLastSurfaceCrop = new Rect(); private static final boolean ENABLE_FREEFORM_COMPOSITOR_SHADOWS = false; /** * The modes to control how the stack is moved to the front when calling {@link Task#reparent}. Loading Loading @@ -2547,8 +2548,10 @@ class Task extends WindowContainer<WindowContainer> { } private void updateSurfaceCrop() { // TODO(b/149585281) remove when root task has the correct bounds for freeform // Only update the crop if we are drawing shadows on the task. if (mSurfaceControl == null || !mWmService.mRenderShadowsInCompositor) { if (mSurfaceControl == null || !mWmService.mRenderShadowsInCompositor || !isRootTask() || !ENABLE_FREEFORM_COMPOSITOR_SHADOWS) { return; } Loading Loading @@ -2971,9 +2974,15 @@ class Task extends WindowContainer<WindowContainer> { return true; } @Override void onSurfaceShown(SurfaceControl.Transaction t) { super.onSurfaceShown(t); t.unsetColor(mSurfaceControl); } @Override SurfaceControl.Builder makeSurface() { return super.makeSurface().setMetadata(METADATA_TASK_ID, mTaskId); return super.makeSurface().setColorLayer().setMetadata(METADATA_TASK_ID, mTaskId); } boolean isTaskAnimating() { Loading Loading @@ -3932,7 +3941,8 @@ class Task extends WindowContainer<WindowContainer> { return dipToPixel(PINNED_WINDOWING_MODE_ELEVATION_IN_DIP, mDisplayContent.getDisplayMetrics()); } if (inFreeformWindowingMode()) { // TODO(b/149585281) remove when root task has the correct bounds for freeform if (ENABLE_FREEFORM_COMPOSITOR_SHADOWS && inFreeformWindowingMode()) { final int elevation = taskIsFocused ? DECOR_SHADOW_FOCUSED_HEIGHT_IN_DIP : DECOR_SHADOW_UNFOCUSED_HEIGHT_IN_DIP; return dipToPixel(elevation, mDisplayContent.getDisplayMetrics()); Loading @@ -3947,7 +3957,7 @@ class Task extends WindowContainer<WindowContainer> { */ private void updateShadowsRadius(boolean taskIsFocused, SurfaceControl.Transaction pendingTransaction) { if (!mWmService.mRenderShadowsInCompositor) return; if (!mWmService.mRenderShadowsInCompositor || !isRootTask()) return; final float newShadowRadius = getShadowRadius(taskIsFocused); if (mShadowRadius != newShadowRadius) { Loading services/core/java/com/android/server/wm/WindowContainer.java +9 −1 Original line number Diff line number Diff line Loading @@ -365,6 +365,7 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer< // build a surface. setSurfaceControl(makeSurface().build()); getPendingTransaction().show(mSurfaceControl); onSurfaceShown(getPendingTransaction()); updateSurfacePosition(); } else { // If we have a surface but a new parent, we just need to perform a reparent. Go through Loading @@ -383,6 +384,13 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer< scheduleAnimation(); } /** * Called when the surface is shown for the first time. */ void onSurfaceShown(Transaction t) { // do nothing } // Temp. holders for a chain of containers we are currently processing. private final LinkedList<WindowContainer> mTmpChain1 = new LinkedList<>(); private final LinkedList<WindowContainer> mTmpChain2 = new LinkedList<>(); Loading Loading @@ -1908,7 +1916,7 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer< @Override public Builder makeAnimationLeash() { return makeSurface(); return makeSurface().setContainerLayer(); } @Override Loading Loading
core/java/android/view/SurfaceControl.java +19 −9 Original line number Diff line number Diff line Loading @@ -321,14 +321,12 @@ public final class SurfaceControl implements Parcelable { public static final int FX_SURFACE_NORMAL = 0x00000000; /** * Surface creation flag: Creates a Dim surface. * Everything behind this surface is dimmed by the amount specified * in {@link Transaction#setAlpha(SurfaceControl, float)}. It is an error to lock a Dim * surface, since it doesn't have a backing store. * Surface creation flag: Creates a effect surface which * represents a solid color and or shadows. * * @hide */ public static final int FX_SURFACE_DIM = 0x00020000; public static final int FX_SURFACE_EFFECT = 0x00020000; /** * Surface creation flag: Creates a container surface. Loading Loading @@ -739,11 +737,11 @@ public final class SurfaceControl implements Parcelable { */ public Builder setColorLayer() { unsetBufferSize(); return setFlags(FX_SURFACE_DIM, FX_SURFACE_MASK); return setFlags(FX_SURFACE_EFFECT, FX_SURFACE_MASK); } private boolean isColorLayerSet() { return (mFlags & FX_SURFACE_DIM) == FX_SURFACE_DIM; return (mFlags & FX_SURFACE_EFFECT) == FX_SURFACE_EFFECT; } /** Loading Loading @@ -2078,6 +2076,7 @@ public final class SurfaceControl implements Parcelable { private final ArrayMap<SurfaceControl, Point> mResizedSurfaces = new ArrayMap<>(); Runnable mFreeNativeResources; private static final float[] INVALID_COLOR = {-1, -1, -1}; /** * @hide Loading Loading @@ -2533,8 +2532,9 @@ public final class SurfaceControl implements Parcelable { } /** * Sets a color for the Surface. * @param color A float array with three values to represent r, g, b in range [0..1] * Fills the surface with the specified color. * @param color A float array with three values to represent r, g, b in range [0..1]. An * invalid color will remove the color fill. * @hide */ @UnsupportedAppUsage Loading @@ -2544,6 +2544,16 @@ public final class SurfaceControl implements Parcelable { return this; } /** * Removes color fill. * @hide */ public Transaction unsetColor(SurfaceControl sc) { checkPreconditions(sc); nativeSetColor(mNativeObject, sc.mNativeObject, INVALID_COLOR); return this; } /** * Sets the security of the surface. Setting the flag is equivalent to creating the * Surface with the {@link #SECURE} flag. Loading
core/java/com/android/internal/policy/DecorView.java +9 −4 Original line number Diff line number Diff line Loading @@ -1627,9 +1627,12 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind int opacity = PixelFormat.OPAQUE; final WindowConfiguration winConfig = getResources().getConfiguration().windowConfiguration; // TODO(b/149585281) remove when root task has the correct bounds for freeform final boolean renderShadowsInCompositor = mWindow.mRenderShadowsInCompositor && winConfig.getWindowingMode() != WINDOWING_MODE_FREEFORM; // If we draw shadows in the compositor we don't need to force the surface to be // translucent. if (winConfig.hasWindowShadow() && !mWindow.mRenderShadowsInCompositor) { if (winConfig.hasWindowShadow() && !renderShadowsInCompositor) { // If the window has a shadow, it must be translucent. opacity = PixelFormat.TRANSLUCENT; } else{ Loading Loading @@ -2414,16 +2417,18 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind } private void updateElevation() { final int windowingMode = getResources().getConfiguration().windowConfiguration.getWindowingMode(); final boolean renderShadowsInCompositor = mWindow.mRenderShadowsInCompositor && windowingMode != WINDOWING_MODE_FREEFORM; // If rendering shadows in the compositor, don't set an elevation on the view if (mWindow.mRenderShadowsInCompositor) { if (renderShadowsInCompositor) { return; } float elevation = 0; final boolean wasAdjustedForStack = mElevationAdjustedForStack; // Do not use a shadow when we are in resizing mode (mBackdropFrameRenderer not null) // since the shadow is bound to the content size and not the target size. final int windowingMode = getResources().getConfiguration().windowConfiguration.getWindowingMode(); if ((windowingMode == WINDOWING_MODE_FREEFORM) && !isResizing()) { elevation = hasWindowFocus() ? DECOR_SHADOW_FOCUSED_HEIGHT_IN_DIP : DECOR_SHADOW_UNFOCUSED_HEIGHT_IN_DIP; Loading
services/core/java/com/android/server/wm/Task.java +14 −4 Original line number Diff line number Diff line Loading @@ -199,6 +199,7 @@ class Task extends WindowContainer<WindowContainer> { static final int INVALID_MIN_SIZE = -1; private float mShadowRadius = 0; private final Rect mLastSurfaceCrop = new Rect(); private static final boolean ENABLE_FREEFORM_COMPOSITOR_SHADOWS = false; /** * The modes to control how the stack is moved to the front when calling {@link Task#reparent}. Loading Loading @@ -2547,8 +2548,10 @@ class Task extends WindowContainer<WindowContainer> { } private void updateSurfaceCrop() { // TODO(b/149585281) remove when root task has the correct bounds for freeform // Only update the crop if we are drawing shadows on the task. if (mSurfaceControl == null || !mWmService.mRenderShadowsInCompositor) { if (mSurfaceControl == null || !mWmService.mRenderShadowsInCompositor || !isRootTask() || !ENABLE_FREEFORM_COMPOSITOR_SHADOWS) { return; } Loading Loading @@ -2971,9 +2974,15 @@ class Task extends WindowContainer<WindowContainer> { return true; } @Override void onSurfaceShown(SurfaceControl.Transaction t) { super.onSurfaceShown(t); t.unsetColor(mSurfaceControl); } @Override SurfaceControl.Builder makeSurface() { return super.makeSurface().setMetadata(METADATA_TASK_ID, mTaskId); return super.makeSurface().setColorLayer().setMetadata(METADATA_TASK_ID, mTaskId); } boolean isTaskAnimating() { Loading Loading @@ -3932,7 +3941,8 @@ class Task extends WindowContainer<WindowContainer> { return dipToPixel(PINNED_WINDOWING_MODE_ELEVATION_IN_DIP, mDisplayContent.getDisplayMetrics()); } if (inFreeformWindowingMode()) { // TODO(b/149585281) remove when root task has the correct bounds for freeform if (ENABLE_FREEFORM_COMPOSITOR_SHADOWS && inFreeformWindowingMode()) { final int elevation = taskIsFocused ? DECOR_SHADOW_FOCUSED_HEIGHT_IN_DIP : DECOR_SHADOW_UNFOCUSED_HEIGHT_IN_DIP; return dipToPixel(elevation, mDisplayContent.getDisplayMetrics()); Loading @@ -3947,7 +3957,7 @@ class Task extends WindowContainer<WindowContainer> { */ private void updateShadowsRadius(boolean taskIsFocused, SurfaceControl.Transaction pendingTransaction) { if (!mWmService.mRenderShadowsInCompositor) return; if (!mWmService.mRenderShadowsInCompositor || !isRootTask()) return; final float newShadowRadius = getShadowRadius(taskIsFocused); if (mShadowRadius != newShadowRadius) { Loading
services/core/java/com/android/server/wm/WindowContainer.java +9 −1 Original line number Diff line number Diff line Loading @@ -365,6 +365,7 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer< // build a surface. setSurfaceControl(makeSurface().build()); getPendingTransaction().show(mSurfaceControl); onSurfaceShown(getPendingTransaction()); updateSurfacePosition(); } else { // If we have a surface but a new parent, we just need to perform a reparent. Go through Loading @@ -383,6 +384,13 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer< scheduleAnimation(); } /** * Called when the surface is shown for the first time. */ void onSurfaceShown(Transaction t) { // do nothing } // Temp. holders for a chain of containers we are currently processing. private final LinkedList<WindowContainer> mTmpChain1 = new LinkedList<>(); private final LinkedList<WindowContainer> mTmpChain2 = new LinkedList<>(); Loading Loading @@ -1908,7 +1916,7 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer< @Override public Builder makeAnimationLeash() { return makeSurface(); return makeSurface().setContainerLayer(); } @Override Loading