summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Marzia Favaro <marziana@google.com> 2024-09-12 10:07:27 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2024-09-12 10:07:27 +0000
commit58a10bee92e01e13fcc66871d0ea668879dffeac (patch)
tree547ec48512d18396e13d86c1e4aa98fd2db74800
parent03e8894597c14009016b33bd36535725ce07f63b (diff)
parenta27b862bc0f064a322a38cef2351f6de806ec0b8 (diff)
Merge "Update dim state when new window is drawn" into main
-rw-r--r--core/java/android/window/flags/windowing_frontend.aconfig11
-rw-r--r--services/core/java/com/android/server/wm/DimmerAnimationHelper.java21
-rw-r--r--services/core/java/com/android/server/wm/WindowContainer.java9
-rw-r--r--services/core/java/com/android/server/wm/WindowState.java17
4 files changed, 52 insertions, 6 deletions
diff --git a/core/java/android/window/flags/windowing_frontend.aconfig b/core/java/android/window/flags/windowing_frontend.aconfig
index a786fc24d9a7..03e230c39f05 100644
--- a/core/java/android/window/flags/windowing_frontend.aconfig
+++ b/core/java/android/window/flags/windowing_frontend.aconfig
@@ -181,6 +181,17 @@ flag {
}
flag {
+ name: "update_dims_when_window_shown"
+ namespace: "windowing_frontend"
+ description: "Check if we need to update dim layers when a new window draws the first frame"
+ bug: "327332488"
+ is_fixed_read_only: true
+ metadata {
+ purpose: PURPOSE_BUGFIX
+ }
+}
+
+flag {
name: "release_snapshot_aggressively"
namespace: "windowing_frontend"
description: "Actively release task snapshot memory"
diff --git a/services/core/java/com/android/server/wm/DimmerAnimationHelper.java b/services/core/java/com/android/server/wm/DimmerAnimationHelper.java
index faf6dc667916..bc188959164d 100644
--- a/services/core/java/com/android/server/wm/DimmerAnimationHelper.java
+++ b/services/core/java/com/android/server/wm/DimmerAnimationHelper.java
@@ -109,7 +109,9 @@ public class DimmerAnimationHelper {
// Sets the requested layer to reparent the dim to without applying it immediately
void setRequestedGeometryParent(WindowContainer<?> geometryParent) {
- mRequestedProperties.mGeometryParent = geometryParent;
+ if (geometryParent != null) {
+ mRequestedProperties.mGeometryParent = geometryParent;
+ }
}
// Sets a requested change without applying it immediately
@@ -139,9 +141,14 @@ public class DimmerAnimationHelper {
dim.remove(t);
return;
}
+ if (!dim.mDimSurface.isValid()) {
+ Log.e(TAG, "Dimming surface " + dim.mDimSurface + " has already been released!"
+ + " Can not apply changes.");
+ return;
+ }
dim.ensureVisible(t);
- reparent(dim.mDimSurface,
+ reparent(dim,
startProperties.mGeometryParent != mRequestedProperties.mGeometryParent
? mRequestedProperties.mGeometryParent.getSurfaceControl() : null,
mRequestedProperties.mDimmingContainer != startProperties.mDimmingContainer
@@ -159,7 +166,7 @@ public class DimmerAnimationHelper {
"%s skipping animation and directly setting alpha=%f, blur=%d",
dim, startProperties.mAlpha,
mRequestedProperties.mBlurRadius);
- setCurrentAlphaBlur(dim.mDimSurface, t);
+ setCurrentAlphaBlur(dim, t);
dim.mSkipAnimation = false;
} else {
startAnimation(t, dim, startProperties, mRequestedProperties);
@@ -186,7 +193,7 @@ public class DimmerAnimationHelper {
synchronized (dim.mHostContainer.mWmService.mGlobalLock) {
SurfaceControl.Transaction finishTransaction =
dim.mHostContainer.getSyncTransaction();
- setCurrentAlphaBlur(dim.mDimSurface, finishTransaction);
+ setCurrentAlphaBlur(dim, finishTransaction);
if (targetAlpha == 0f && !dim.isDimming()) {
dim.remove(finishTransaction);
}
@@ -229,10 +236,11 @@ public class DimmerAnimationHelper {
/**
* Change the geometry and relative parent of this dim layer
*/
- static void reparent(@NonNull SurfaceControl dimLayer,
+ void reparent(@NonNull Dimmer.DimState dim,
@Nullable SurfaceControl newGeometryParent,
@Nullable SurfaceControl newRelativeParent,
@NonNull SurfaceControl.Transaction t) {
+ final SurfaceControl dimLayer = dim.mDimSurface;
try {
if (newGeometryParent != null) {
t.reparent(dimLayer, newGeometryParent);
@@ -245,7 +253,8 @@ public class DimmerAnimationHelper {
}
}
- void setCurrentAlphaBlur(@NonNull SurfaceControl sc, @NonNull SurfaceControl.Transaction t) {
+ void setCurrentAlphaBlur(@NonNull Dimmer.DimState dim, @NonNull SurfaceControl.Transaction t) {
+ final SurfaceControl sc = dim.mDimSurface;
try {
t.setAlpha(sc, mCurrentProperties.mAlpha);
t.setBackgroundBlurRadius(sc, mCurrentProperties.mBlurRadius);
diff --git a/services/core/java/com/android/server/wm/WindowContainer.java b/services/core/java/com/android/server/wm/WindowContainer.java
index 1eeb3ecaf9d6..9d4652957487 100644
--- a/services/core/java/com/android/server/wm/WindowContainer.java
+++ b/services/core/java/com/android/server/wm/WindowContainer.java
@@ -2875,6 +2875,15 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer<
}
/**
+ * Go through the hierarchy to allow windows to request a dim if needed
+ */
+ void adjustDims() {
+ for (int i = 0; i < mChildren.size(); i++) {
+ mChildren.get(i).adjustDims();
+ }
+ }
+
+ /**
* Trigger a call to prepareSurfaces from the animation thread, such that pending transactions
* will be applied.
*/
diff --git a/services/core/java/com/android/server/wm/WindowState.java b/services/core/java/com/android/server/wm/WindowState.java
index 021be5727bf6..b5276303f6b9 100644
--- a/services/core/java/com/android/server/wm/WindowState.java
+++ b/services/core/java/com/android/server/wm/WindowState.java
@@ -4409,6 +4409,17 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
for (int i = mChildren.size() - 1; i >= 0; i--) {
committed |= mChildren.get(i).commitFinishDrawing(t);
}
+
+ // When a new activity is showing, update dim in this transaction
+ if (Flags.updateDimsWhenWindowShown()) {
+ final Dimmer dimmer = getDimController();
+ final WindowContainer<?> dimParent = getDimParent();
+ if (dimmer != null && dimParent != null) {
+ dimParent.adjustDims();
+ dimmer.updateDims(t);
+ }
+ }
+
// In case commitFinishDrawingLocked starts a window level animation, make sure the surface
// operation (reparent to leash) is synced with the visibility by transition.
if (getAnimationLeash() != null) {
@@ -5304,6 +5315,12 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
super.prepareSurfaces();
}
+ @Override
+ void adjustDims() {
+ applyDims();
+ super.adjustDims();
+ }
+
void updateSurfacePositionIfNeeded() {
if (mWindowFrames.mRelFrame.top == mWindowFrames.mLastRelFrame.top
&& mWindowFrames.mRelFrame.left == mWindowFrames.mLastRelFrame.left) {