From 4552d3e896c884a43a836a55b1329fe304ff5ca7 Mon Sep 17 00:00:00 2001 From: Riddle Hsu Date: Mon, 3 Jul 2023 10:13:05 +0000 Subject: [PATCH] Avoid changing z-order of overlay layer after resizing display The WindowToken of cutout/rounded corner overlay will be collected in transition for sync drawing, so buildFinishTransaction will put the restore operations in finishTransaction. But previously the finishTransaction will always reparent the token to the parent in window hierarchy, which doesn't consider the override operation while creating the surface (makeSurface). Then after the first display resize transition, the overlay becomes flickering in next display resize because it is occluded by the screenshot layer which has a higher z-order without including the overlay. Bug: 288726181 Test: Change screen resolution in Settings. The cutout won't have a small flickering (disappear in a frame). Change-Id: Ibee8c5b8daffdaf38f4f0ce9351dd085929ccb45 --- .../core/java/com/android/server/wm/Transition.java | 2 +- .../core/java/com/android/server/wm/WindowToken.java | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/wm/Transition.java b/services/core/java/com/android/server/wm/Transition.java index 79a54c3cfb32d..79839ef98d562 100644 --- a/services/core/java/com/android/server/wm/Transition.java +++ b/services/core/java/com/android/server/wm/Transition.java @@ -2262,7 +2262,7 @@ class Transition implements BLASTSyncEngine.TransactionReadyListener { // transitions anyways). return wc.getParent().asDisplayContent().getWindowingLayer(); } - return wc.getParent().getSurfaceControl(); + return wc.getParentSurfaceControl(); } /** diff --git a/services/core/java/com/android/server/wm/WindowToken.java b/services/core/java/com/android/server/wm/WindowToken.java index 31afcbf262203..9806be85467b5 100644 --- a/services/core/java/com/android/server/wm/WindowToken.java +++ b/services/core/java/com/android/server/wm/WindowToken.java @@ -388,12 +388,23 @@ class WindowToken extends WindowContainer { @Override SurfaceControl.Builder makeSurface() { final SurfaceControl.Builder builder = super.makeSurface(); + // The overlay may use COLOR_MODE_A8 that needs to be at the top of the display to avoid + // additional memory usage, see b/235601833. Note that getParentSurfaceControl() must use + // the same parent. if (mRoundedCornerOverlay) { builder.setParent(null); } return builder; } + @Override + public SurfaceControl getParentSurfaceControl() { + if (mRoundedCornerOverlay) { + return null; + } + return super.getParentSurfaceControl(); + } + boolean isClientVisible() { return mClientVisible; }