Skip to content

Commit bedcd38

Browse files
sammiequon71Sammie Quon
authored and
Sammie Quon
committed
[merge to 73] wm: Introduce Hide/HideAndMinimize without animations.
Hide and HideAndMinimize without animations by using ScopedAnimationDisabler is used in a couple places already, but if we minimize or hide, the gpu memory usage for overview/alt tab is super high. Introduce two new functions which in addition to minimizing without animations, recreates the layers. This fixes the issue, but i think is a workaround, so we need to investigate further. [email protected] (cherry picked from commit 73adf74) Test: manual Bug: 924802 Change-Id: Ida56a2b77cdd6d68a14e54d520ef890f3f541f34 Reviewed-on: https://chromium-review.googlesource.com/c/1437618 Reviewed-by: Mitsuru Oshima <[email protected]> Commit-Queue: Sammie Quon <[email protected]> Cr-Original-Commit-Position: refs/heads/master@{#626703} Reviewed-on: https://chromium-review.googlesource.com/c/1443969 Reviewed-by: Sammie Quon <[email protected]> Cr-Commit-Position: refs/branch-heads/3683@{#49} Cr-Branched-From: e510299-refs/heads/master@{#625896}
1 parent 7213884 commit bedcd38

File tree

4 files changed

+32
-20
lines changed

4 files changed

+32
-20
lines changed

ash/app_list/home_launcher_gesture_handler.cc

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -466,24 +466,16 @@ void HomeLauncherGestureHandler::OnImplicitAnimationsCompleted() {
466466
window2_->ResetOpacityAndTransform();
467467

468468
if (is_final_state_show) {
469-
ScopedAnimationDisabler disable(GetWindow1());
470-
GetWindow1()->Hide();
471-
wm::GetWindowState(GetWindow1())->Minimize();
469+
wm::HideAndMinimizeWithoutAnimation(GetWindow1());
472470

473-
if (window2_) {
474-
ScopedAnimationDisabler disable(GetWindow2());
475-
GetWindow2()->Hide();
476-
wm::GetWindowState(GetWindow2())->Minimize();
477-
}
471+
if (window2_)
472+
wm::HideAndMinimizeWithoutAnimation(GetWindow2());
478473

479474
// Minimize the hidden windows so they can be used normally with alt+tab
480475
// and overview. Minimize in reverse order to preserve mru ordering.
481476
std::reverse(hidden_windows_.begin(), hidden_windows_.end());
482-
for (auto* window : hidden_windows_) {
483-
ScopedAnimationDisabler disable(window);
484-
window->Hide();
485-
wm::GetWindowState(window)->Minimize();
486-
}
477+
for (auto* window : hidden_windows_)
478+
wm::HideAndMinimizeWithoutAnimation(window);
487479
} else {
488480
// Reshow all windows previously hidden.
489481
for (auto* window : hidden_windows_) {
@@ -820,8 +812,7 @@ bool HomeLauncherGestureHandler::SetUpWindows(Mode mode, aura::Window* window) {
820812
if (window->IsVisible()) {
821813
hidden_windows_.push_back(window);
822814
window->AddObserver(this);
823-
ScopedAnimationDisabler disable(window);
824-
window->Hide();
815+
wm::HideWithoutAnimation(window);
825816
}
826817
}
827818
}

ash/wm/overview/overview_controller.cc

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -335,10 +335,7 @@ bool OverviewController::ToggleOverview(
335335
for (aura::Window* window : windows) {
336336
if (wm::GetWindowState(window)->IsMinimized())
337337
continue;
338-
339-
ScopedAnimationDisabler disable(window);
340-
window->Hide();
341-
wm::GetWindowState(window)->Minimize();
338+
wm::HideAndMinimizeWithoutAnimation(window);
342339
}
343340
}
344341

ash/wm/window_util.cc

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@
1010
#include "ash/public/cpp/shell_window_ids.h"
1111
#include "ash/public/cpp/window_properties.h"
1212
#include "ash/root_window_controller.h"
13+
#include "ash/scoped_animation_disabler.h"
1314
#include "ash/session/session_controller.h"
1415
#include "ash/shelf/shelf.h"
1516
#include "ash/shell.h"
1617
#include "ash/wm/splitview/split_view_controller.h"
1718
#include "ash/wm/widget_finder.h"
1819
#include "ash/wm/window_positioning_utils.h"
19-
#include "ash/wm/window_properties.h"
2020
#include "ash/wm/window_state.h"
2121
#include "ash/wm/wm_event.h"
2222
#include "ash/ws/window_service_owner.h"
@@ -30,6 +30,7 @@
3030
#include "ui/aura/window_targeter.h"
3131
#include "ui/base/hit_test.h"
3232
#include "ui/compositor/dip_util.h"
33+
#include "ui/compositor/layer_tree_owner.h"
3334
#include "ui/display/display.h"
3435
#include "ui/display/screen.h"
3536
#include "ui/gfx/geometry/rect.h"
@@ -38,6 +39,7 @@
3839
#include "ui/views/widget/widget.h"
3940
#include "ui/wm/core/coordinate_conversion.h"
4041
#include "ui/wm/core/easy_resize_window_targeter.h"
42+
#include "ui/wm/core/window_animations.h"
4143
#include "ui/wm/core/window_properties.h"
4244
#include "ui/wm/core/window_util.h"
4345
#include "ui/wm/public/activation_client.h"
@@ -310,5 +312,22 @@ void RemoveTransientDescendants(std::vector<aura::Window*>* out_window_list) {
310312
}
311313
}
312314

315+
void HideAndMinimizeWithoutAnimation(aura::Window* window) {
316+
// Disable the animations using |disable|. However, doing so will skip
317+
// detaching and recreating layers that animating does which has memory
318+
// implications, so use recreate layers to get the same effect. See
319+
// crbug.com/924802.
320+
ScopedAnimationDisabler disable(window);
321+
window->Hide();
322+
wm::GetWindowState(window)->Minimize();
323+
std::unique_ptr<ui::LayerTreeOwner> owner = ::wm::RecreateLayers(window);
324+
}
325+
326+
void HideWithoutAnimation(aura::Window* window) {
327+
ScopedAnimationDisabler disable(window);
328+
window->Hide();
329+
std::unique_ptr<ui::LayerTreeOwner> owner = ::wm::RecreateLayers(window);
330+
}
331+
313332
} // namespace wm
314333
} // namespace ash

ash/wm/window_util.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,11 @@ ASH_EXPORT bool ShouldExcludeForOverview(const aura::Window* window);
116116
ASH_EXPORT void RemoveTransientDescendants(
117117
std::vector<aura::Window*>* out_window_list);
118118

119+
// Minimizes or hides |window| without any animations, in case users what it to
120+
// hide right away or apply their own animations.
121+
ASH_EXPORT void HideAndMinimizeWithoutAnimation(aura::Window* window);
122+
ASH_EXPORT void HideWithoutAnimation(aura::Window* window);
123+
119124
} // namespace wm
120125
} // namespace ash
121126

0 commit comments

Comments
 (0)