From eb1d322d1cfc8c7547967bc7e20b1fe3499ec90d Mon Sep 17 00:00:00 2001 From: Andrii Kulian Date: Mon, 16 May 2016 15:17:55 -0700 Subject: [PATCH] Clear mResizedWhileNotDragResizing flag after reporting Currently mResizedWhileNotDragResizing flag is not cleared after reporting resize to client, which causes sending lots of resize messages and relayouts on app side. This CL introduces another flag to track reporting to app. Bug: 28696195 Change-Id: Ib5b6ea3e5f499c96057182f4b20583734dea56c4 --- .../core/java/com/android/server/wm/Task.java | 2 +- .../server/wm/WindowManagerService.java | 11 +++--- .../com/android/server/wm/WindowState.java | 38 ++++++++++++++++--- .../server/wm/WindowStateAnimator.java | 2 +- 4 files changed, 40 insertions(+), 13 deletions(-) diff --git a/services/core/java/com/android/server/wm/Task.java b/services/core/java/com/android/server/wm/Task.java index 0d3535495aff8..f0808acee6361 100644 --- a/services/core/java/com/android/server/wm/Task.java +++ b/services/core/java/com/android/server/wm/Task.java @@ -631,7 +631,7 @@ class Task implements DimLayer.DimLayerUser { // windows since they aren't at the base layer and could be moved around anyway. if (!win.computeDragResizing() && win.mAttrs.type == TYPE_BASE_APPLICATION && !mStack.getBoundsAnimating() && !win.isGoneForLayoutLw()) { - win.mResizedWhileNotDragResizing = true; + win.setResizedWhileNotDragResizing(true); } } if (win.isGoneForLayoutLw()) { diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java index 239cc8eaae8cd..085a3da78bee4 100644 --- a/services/core/java/com/android/server/wm/WindowManagerService.java +++ b/services/core/java/com/android/server/wm/WindowManagerService.java @@ -3057,9 +3057,9 @@ public class WindowManagerService extends IWindowManager.Stub // If we're starting a drag-resize, we'll be changing the surface size as well as // notifying the client to render to with an offset from the surface's top-left. - if (win.isDragResizeChanged() || win.mResizedWhileNotDragResizing) { + if (win.isDragResizeChanged() || win.isResizedWhileNotDragResizing()) { win.setDragResizing(); - win.mResizedWhileNotDragResizing = false; + win.setResizedWhileNotDragResizing(false); // We can only change top level windows to the full-screen surface when // resizing (as we only have one full-screen surface). So there is no need // to preserve and destroy windows which are attached to another, they @@ -9259,7 +9259,7 @@ public class WindowManagerService extends IWindowManager.Stub || w.mOutsetsChanged || configChanged || dragResizingChanged - || w.mResizedWhileNotDragResizing) { + || !w.isResizedWhileNotDragResizingReported()) { if (DEBUG_RESIZE || DEBUG_ORIENTATION) { Slog.v(TAG_WM, "Resize reasons for w=" + w + ": " + " contentInsetsChanged=" + w.mContentInsetsChanged @@ -9273,7 +9273,8 @@ public class WindowManagerService extends IWindowManager.Stub + " surfaceResized=" + winAnimator.mSurfaceResized + " configChanged=" + configChanged + " dragResizingChanged=" + dragResizingChanged - + " resizedWhileNotDragResizing=" + w.mResizedWhileNotDragResizing); + + " resizedWhileNotDragResizingReported=" + + w.isResizedWhileNotDragResizingReported()); } // If it's a dead window left on screen, and the configuration changed, @@ -9295,7 +9296,7 @@ public class WindowManagerService extends IWindowManager.Stub // we need to go through the process of getting informed by the // application when it has finished drawing. if (w.mOrientationChanging || dragResizingChanged - || w.mResizedWhileNotDragResizing) { + || w.isResizedWhileNotDragResizing()) { if (DEBUG_SURFACE_TRACE || DEBUG_ANIM || DEBUG_ORIENTATION || DEBUG_RESIZE) { Slog.v(TAG_WM, "Orientation or resize start waiting for draw" + ", mDrawState=DRAW_PENDING in " + w diff --git a/services/core/java/com/android/server/wm/WindowState.java b/services/core/java/com/android/server/wm/WindowState.java index c3f2367b53b7c..662dfcfd7d856 100644 --- a/services/core/java/com/android/server/wm/WindowState.java +++ b/services/core/java/com/android/server/wm/WindowState.java @@ -486,12 +486,11 @@ final class WindowState implements WindowManagerPolicy.WindowState { */ boolean mResizedWhileGone = false; - /** - * Indicates whether we got resized but drag resizing flag was false. In this case, we also - * need to recreate the surface and defer surface bound updates in order to make sure the - * buffer contents and the positioning/size stay in sync. - */ - boolean mResizedWhileNotDragResizing; + /** @see #isResizedWhileNotDragResizing(). */ + private boolean mResizedWhileNotDragResizing; + + /** @see #isResizedWhileNotDragResizingReported(). */ + private boolean mResizedWhileNotDragResizingReported; WindowState(WindowManagerService service, Session s, IWindow c, WindowToken token, WindowState attachedWindow, int appOp, int seq, WindowManager.LayoutParams a, @@ -2324,6 +2323,7 @@ final class WindowState implements WindowManagerPolicy.WindowState { mVisibleInsetsChanged = false; mStableInsetsChanged = false; mOutsetsChanged = false; + mResizedWhileNotDragResizingReported = true; mWinAnimator.mSurfaceResized = false; } catch (RemoteException e) { mOrientationChanging = false; @@ -2426,6 +2426,32 @@ final class WindowState implements WindowManagerPolicy.WindowState { mDragResizingChangeReported = false; } + /** + * Set whether we got resized but drag resizing flag was false. + * @see #isResizedWhileNotDragResizing(). + */ + void setResizedWhileNotDragResizing(boolean resizedWhileNotDragResizing) { + mResizedWhileNotDragResizing = resizedWhileNotDragResizing; + mResizedWhileNotDragResizingReported = !resizedWhileNotDragResizing; + } + + /** + * Indicates whether we got resized but drag resizing flag was false. In this case, we also + * need to recreate the surface and defer surface bound updates in order to make sure the + * buffer contents and the positioning/size stay in sync. + */ + boolean isResizedWhileNotDragResizing() { + return mResizedWhileNotDragResizing; + } + + /** + * @return Whether we reported "resize while not drag resizing" to the application. + * @see #isResizedWhileNotDragResizing() + */ + boolean isResizedWhileNotDragResizingReported() { + return mResizedWhileNotDragResizingReported; + } + int getResizeMode() { return mResizeMode; } diff --git a/services/core/java/com/android/server/wm/WindowStateAnimator.java b/services/core/java/com/android/server/wm/WindowStateAnimator.java index acf16896a8184..0337616835cc7 100644 --- a/services/core/java/com/android/server/wm/WindowStateAnimator.java +++ b/services/core/java/com/android/server/wm/WindowStateAnimator.java @@ -1402,7 +1402,7 @@ class WindowStateAnimator { final Task task = w.getTask(); // We got resized, so block all updates until we got the new surface. - if (w.mResizedWhileNotDragResizing && !w.isGoneForLayoutLw()) { + if (w.isResizedWhileNotDragResizing() && !w.isGoneForLayoutLw()) { return; }