Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8522)

Unified Diff: ash/wm/window_mirror_view.cc

Issue 2190963002: Ash window cycle ui: don't create mirrored layers for previews until (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use OnVisibleBoundsChanged Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/wm/window_mirror_view.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/wm/window_mirror_view.cc
diff --git a/ash/wm/window_mirror_view.cc b/ash/wm/window_mirror_view.cc
index 1c50ecb5a2e7ed5a4c87b8bfb2eaf67644541ac6..1705833c2492ea2a86d8d13a7e411645f36f7732 100644
--- a/ash/wm/window_mirror_view.cc
+++ b/ash/wm/window_mirror_view.cc
@@ -11,6 +11,7 @@
#include "ui/aura/window.h"
#include "ui/compositor/layer.h"
#include "ui/compositor/layer_tree_owner.h"
+#include "ui/views/widget/widget.h"
namespace ash {
namespace wm {
@@ -34,27 +35,19 @@ WindowMirrorView::WindowMirrorView(WmWindowAura* window) : target_(window) {
}
WindowMirrorView::~WindowMirrorView() {}
-void WindowMirrorView::Init() {
- SetPaintToLayer(true);
-
- layer_owner_ = ::wm::RecreateLayers(target_->aura_window(), this);
-
- GetMirrorLayer()->parent()->Remove(GetMirrorLayer());
- layer()->Add(GetMirrorLayer());
-
- // Some extra work is needed when the target window is minimized.
- if (target_->GetWindowState()->IsMinimized()) {
- GetMirrorLayer()->SetVisible(true);
- GetMirrorLayer()->SetOpacity(1);
- EnsureAllChildrenAreVisible(GetMirrorLayer());
- }
-}
-
gfx::Size WindowMirrorView::GetPreferredSize() const {
return target_->GetBounds().size();
}
void WindowMirrorView::Layout() {
+ // If |layer_owner_| hasn't been initialized (|this| isn't on screen), no-op.
+ // We call InvalidateLayout() so Layout() will get called again next time even
+ // if the bounds haven't changed.
+ if (!layer_owner_) {
+ InvalidateLayout();
sky 2016/08/08 19:12:40 The main thing I don't particularly like about eit
+ return;
+ }
+
// Position at 0, 0.
GetMirrorLayer()->SetBounds(gfx::Rect(GetMirrorLayer()->bounds().size()));
@@ -68,6 +61,15 @@ void WindowMirrorView::Layout() {
GetMirrorLayer()->SetTransform(mirror_transform);
}
+bool WindowMirrorView::GetNeedsNotificationWhenVisibleBoundsChange() const {
+ return true;
+}
+
+void WindowMirrorView::OnVisibleBoundsChanged() {
+ if (!layer_owner_ && !GetVisibleBounds().IsEmpty())
+ InitLayerOwner();
+}
+
ui::LayerDelegate* WindowMirrorView::CreateDelegate(
ui::LayerDelegate* delegate) {
if (!delegate)
@@ -78,6 +80,22 @@ ui::LayerDelegate* WindowMirrorView::CreateDelegate(
return delegates_.back().get();
}
+void WindowMirrorView::InitLayerOwner() {
+ SetPaintToLayer(true);
+
+ layer_owner_ = ::wm::RecreateLayers(target_->aura_window(), this);
+
+ GetMirrorLayer()->parent()->Remove(GetMirrorLayer());
+ layer()->Add(GetMirrorLayer());
+
+ // Some extra work is needed when the target window is minimized.
+ if (target_->GetWindowState()->IsMinimized()) {
+ GetMirrorLayer()->SetVisible(true);
+ GetMirrorLayer()->SetOpacity(1);
+ EnsureAllChildrenAreVisible(GetMirrorLayer());
+ }
+}
+
ui::Layer* WindowMirrorView::GetMirrorLayer() {
return layer_owner_->root();
}
« no previous file with comments | « ash/wm/window_mirror_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698