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

Side by Side Diff: ash/wm/window_mirror_view.cc

Issue 2164803003: Window cycle ui improvements (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: adjust padding, add about:flag Created 4 years, 5 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ash/wm/window_mirror_view.h" 5 #include "ash/wm/window_mirror_view.h"
6 6
7 #include "ash/aura/wm_window_aura.h" 7 #include "ash/aura/wm_window_aura.h"
8 #include "ash/common/wm/forwarding_layer_delegate.h" 8 #include "ash/common/wm/forwarding_layer_delegate.h"
9 #include "ash/common/wm/window_state.h" 9 #include "ash/common/wm/window_state.h"
10 #include "ash/wm/window_state_aura.h" 10 #include "ash/wm/window_state_aura.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 44
45 // Some extra work is needed when the target window is minimized. 45 // Some extra work is needed when the target window is minimized.
46 if (target_->GetWindowState()->IsMinimized()) { 46 if (target_->GetWindowState()->IsMinimized()) {
47 GetMirrorLayer()->SetVisible(true); 47 GetMirrorLayer()->SetVisible(true);
48 GetMirrorLayer()->SetOpacity(1); 48 GetMirrorLayer()->SetOpacity(1);
49 EnsureAllChildrenAreVisible(GetMirrorLayer()); 49 EnsureAllChildrenAreVisible(GetMirrorLayer());
50 } 50 }
51 } 51 }
52 52
53 gfx::Size WindowMirrorView::GetPreferredSize() const { 53 gfx::Size WindowMirrorView::GetPreferredSize() const {
54 const int kMaxWidth = 512; 54 return target_->GetBounds().size();
Evan Stade 2016/07/20 17:01:09 Seems like this logic belongs in the window cycle
sky 2016/07/20 19:48:45 Agreed.
55 const int kMaxHeight = 256;
56
57 gfx::Size target_size = target_->GetBounds().size();
58 if (target_size.width() <= kMaxWidth && target_size.height() <= kMaxHeight) {
59 return target_size;
60 }
61
62 float scale = std::min(kMaxWidth / static_cast<float>(target_size.width()),
63 kMaxHeight / static_cast<float>(target_size.height()));
64 return gfx::ScaleToCeiledSize(target_size, scale, scale);
65 } 55 }
66 56
67 void WindowMirrorView::Layout() { 57 void WindowMirrorView::Layout() {
68 // Position at 0, 0. 58 // Position at 0, 0.
69 GetMirrorLayer()->SetBounds(gfx::Rect(GetMirrorLayer()->bounds().size())); 59 GetMirrorLayer()->SetBounds(gfx::Rect(GetMirrorLayer()->bounds().size()));
70 60
71 // Scale down if necessary. 61 // Scale down if necessary.
72 gfx::Transform mirror_transform; 62 gfx::Transform mirror_transform;
73 if (size() != target_->GetBounds().size()) { 63 if (size() != target_->GetBounds().size()) {
74 const float scale = 64 const float scale =
(...skipping 12 matching lines...) Expand all
87 77
88 return delegates_.back().get(); 78 return delegates_.back().get();
89 } 79 }
90 80
91 ui::Layer* WindowMirrorView::GetMirrorLayer() { 81 ui::Layer* WindowMirrorView::GetMirrorLayer() {
92 return layer_owner_->root(); 82 return layer_owner_->root();
93 } 83 }
94 84
95 } // namespace wm 85 } // namespace wm
96 } // namespace ash 86 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698