diff options
| author | 2021-09-13 17:24:41 +0200 | |
|---|---|---|
| committer | 2021-09-21 16:25:30 +0200 | |
| commit | ea2130f4990a1a9e598b13c7102cf9434579cccf (patch) | |
| tree | df6a7c2c54dc561d4ed74ebbb1f085c9dbea712d | |
| parent | 2ccc829e71dca5af5eba565319911a53499e99ef (diff) | |
Add color layer to TaskDisplayArea for animations
We want a solid color background to be used for task animations so that we show that instead of the wallpaper.
We need a way to set the color when the animation start and clear it at
the end of the animation.
Test: atest FlickerTests:TaskTransitionTest
Bug: 199507257
Change-Id: I47fe530ffe37b453bbec8e65e0a4199fba2f04a3
| -rw-r--r-- | services/core/java/com/android/server/wm/TaskDisplayArea.java | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/services/core/java/com/android/server/wm/TaskDisplayArea.java b/services/core/java/com/android/server/wm/TaskDisplayArea.java index d450dbffe4a1..70464fc4e0ea 100644 --- a/services/core/java/com/android/server/wm/TaskDisplayArea.java +++ b/services/core/java/com/android/server/wm/TaskDisplayArea.java @@ -42,6 +42,9 @@ import static com.android.server.wm.Task.TASK_VISIBILITY_VISIBLE; import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_ROOT_TASK; import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM; +import static java.lang.Integer.MIN_VALUE; + +import android.annotation.ColorInt; import android.annotation.Nullable; import android.app.ActivityOptions; import android.app.WindowConfiguration; @@ -80,6 +83,22 @@ final class TaskDisplayArea extends DisplayArea<WindowContainer> { DisplayContent mDisplayContent; /** + * A color layer that serves as a solid color background to certain animations. + */ + private SurfaceControl mColorBackgroundLayer; + + /** + * This counter is used to make sure we don't prematurely clear the background color in the + * case that background color animations are interleaved. + * NOTE: The last set color will remain until the counter is reset to 0, which means that an + * animation background color may sometime remain after the animation has finished through an + * animation with a different background color if an animation starts after and ends before + * another where both set different background colors. However, this is not a concern as + * currently all task animation backgrounds are the same color. + */ + private int mColorLayerCounter = 0; + + /** * A control placed at the appropriate level for transitions to occur. */ private SurfaceControl mAppAnimationLayer; @@ -961,6 +980,11 @@ final class TaskDisplayArea extends DisplayArea<WindowContainer> { void onParentChanged(ConfigurationContainer newParent, ConfigurationContainer oldParent) { if (getParent() != null) { super.onParentChanged(newParent, oldParent, () -> { + mColorBackgroundLayer = makeChildSurface(null) + .setColorLayer() + .setName("colorBackgroundLayer") + .setCallsite("TaskDisplayArea.onParentChanged") + .build(); mAppAnimationLayer = makeChildSurface(null) .setName("animationLayer") .setCallsite("TaskDisplayArea.onParentChanged") @@ -977,6 +1001,7 @@ final class TaskDisplayArea extends DisplayArea<WindowContainer> { .setName("splitScreenDividerAnchor") .setCallsite("TaskDisplayArea.onParentChanged") .build(); + getSyncTransaction() .show(mAppAnimationLayer) .show(mBoostedAppAnimationLayer) @@ -986,11 +1011,13 @@ final class TaskDisplayArea extends DisplayArea<WindowContainer> { } else { super.onParentChanged(newParent, oldParent); mWmService.mTransactionFactory.get() + .remove(mColorBackgroundLayer) .remove(mAppAnimationLayer) .remove(mBoostedAppAnimationLayer) .remove(mHomeAppAnimationLayer) .remove(mSplitScreenDividerAnchor) .apply(); + mColorBackgroundLayer = null; mAppAnimationLayer = null; mBoostedAppAnimationLayer = null; mHomeAppAnimationLayer = null; @@ -998,6 +1025,39 @@ final class TaskDisplayArea extends DisplayArea<WindowContainer> { } } + void setBackgroundColor(@ColorInt int color) { + if (mColorBackgroundLayer == null) { + return; + } + + float r = ((color >> 16) & 0xff) / 255.0f; + float g = ((color >> 8) & 0xff) / 255.0f; + float b = ((color >> 0) & 0xff) / 255.0f; + float a = ((color >> 24) & 0xff) / 255.0f; + + mColorLayerCounter++; + + getPendingTransaction().setLayer(mColorBackgroundLayer, MIN_VALUE) + .setColor(mColorBackgroundLayer, new float[]{r, g, b}) + .setAlpha(mColorBackgroundLayer, a) + .setWindowCrop(mColorBackgroundLayer, getSurfaceWidth(), getSurfaceHeight()) + .setPosition(mColorBackgroundLayer, 0, 0) + .show(mColorBackgroundLayer); + + scheduleAnimation(); + } + + void clearBackgroundColor() { + mColorLayerCounter--; + + // Only clear the color layer if we have received the same amounts of clear as set + // requests. + if (mColorLayerCounter == 0) { + getPendingTransaction().hide(mColorBackgroundLayer); + scheduleAnimation(); + } + } + @Override void migrateToNewSurfaceControl(SurfaceControl.Transaction t) { super.migrateToNewSurfaceControl(t); @@ -1006,6 +1066,7 @@ final class TaskDisplayArea extends DisplayArea<WindowContainer> { } // As TaskDisplayArea is getting a new surface, reparent and reorder the child surfaces. + t.reparent(mColorBackgroundLayer, mSurfaceControl); t.reparent(mAppAnimationLayer, mSurfaceControl); t.reparent(mBoostedAppAnimationLayer, mSurfaceControl); t.reparent(mHomeAppAnimationLayer, mSurfaceControl); |