OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "ui/aura/window_tree_host.h" | 5 #include "ui/aura/window_tree_host.h" |
6 | 6 |
7 #include "ui/aura/env.h" | 7 #include "ui/aura/env.h" |
8 #include "ui/aura/root_window.h" | 8 #include "ui/aura/root_window.h" |
9 #include "ui/aura/root_window_transformer.h" | 9 #include "ui/aura/root_window_transformer.h" |
10 #include "ui/aura/window.h" | 10 #include "ui/aura/window.h" |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 const Window* root_window_; | 66 const Window* root_window_; |
67 const gfx::Transform transform_; | 67 const gfx::Transform transform_; |
68 | 68 |
69 DISALLOW_COPY_AND_ASSIGN(SimpleRootWindowTransformer); | 69 DISALLOW_COPY_AND_ASSIGN(SimpleRootWindowTransformer); |
70 }; | 70 }; |
71 | 71 |
72 //////////////////////////////////////////////////////////////////////////////// | 72 //////////////////////////////////////////////////////////////////////////////// |
73 // WindowTreeHost, public: | 73 // WindowTreeHost, public: |
74 | 74 |
75 WindowTreeHost::~WindowTreeHost() { | 75 WindowTreeHost::~WindowTreeHost() { |
76 // TODO(beng): this represents an ordering change. In the old code, the | 76 DCHECK(!compositor_) << "compositor must be destroyed before root window"; |
77 // compositor was reset before the window hierarchy was destroyed. | |
78 // verify that this has no adverse effects. | |
79 // Make sure to destroy the compositor before terminating so that state is | |
80 // cleared and we don't hit asserts. | |
81 compositor_.reset(); | |
82 } | 77 } |
83 | 78 |
84 void WindowTreeHost::InitHost() { | 79 void WindowTreeHost::InitHost() { |
85 window()->Init(ui::LAYER_NOT_DRAWN); | 80 window()->Init(ui::LAYER_NOT_DRAWN); |
86 InitCompositor(); | 81 InitCompositor(); |
87 UpdateRootWindowSize(GetBounds().size()); | 82 UpdateRootWindowSize(GetBounds().size()); |
88 Env::GetInstance()->NotifyRootWindowInitialized(delegate_->AsRootWindow()); | 83 Env::GetInstance()->NotifyRootWindowInitialized(delegate_->AsRootWindow()); |
89 window()->Show(); | 84 window()->Show(); |
90 } | 85 } |
91 | 86 |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 *point = gfx::ToFlooredPoint(point_3f.AsPointF()); | 160 *point = gfx::ToFlooredPoint(point_3f.AsPointF()); |
166 } | 161 } |
167 | 162 |
168 //////////////////////////////////////////////////////////////////////////////// | 163 //////////////////////////////////////////////////////////////////////////////// |
169 // WindowTreeHost, protected: | 164 // WindowTreeHost, protected: |
170 | 165 |
171 WindowTreeHost::WindowTreeHost() | 166 WindowTreeHost::WindowTreeHost() |
172 : delegate_(NULL) { | 167 : delegate_(NULL) { |
173 } | 168 } |
174 | 169 |
| 170 void WindowTreeHost::DestroyCompositor() { compositor_.reset(); } |
| 171 |
175 void WindowTreeHost::CreateCompositor( | 172 void WindowTreeHost::CreateCompositor( |
176 gfx::AcceleratedWidget accelerated_widget) { | 173 gfx::AcceleratedWidget accelerated_widget) { |
177 compositor_.reset(new ui::Compositor(GetAcceleratedWidget())); | 174 compositor_.reset(new ui::Compositor(GetAcceleratedWidget())); |
178 DCHECK(compositor_.get()); | 175 DCHECK(compositor_.get()); |
179 } | 176 } |
180 | 177 |
181 void WindowTreeHost::NotifyHostResized(const gfx::Size& new_size) { | 178 void WindowTreeHost::NotifyHostResized(const gfx::Size& new_size) { |
182 // The compositor should have the same size as the native root window host. | 179 // The compositor should have the same size as the native root window host. |
183 // Get the latest scale from display because it might have been changed. | 180 // Get the latest scale from display because it might have been changed. |
184 compositor_->SetScaleAndSize(GetDeviceScaleFactorFromDisplay(window()), | 181 compositor_->SetScaleAndSize(GetDeviceScaleFactorFromDisplay(window()), |
185 new_size); | 182 new_size); |
186 | 183 |
187 // The layer, and the observers should be notified of the | 184 // The layer, and the observers should be notified of the |
188 // transformed size of the root window. | 185 // transformed size of the root window. |
189 UpdateRootWindowSize(new_size); | 186 UpdateRootWindowSize(new_size); |
190 delegate_->OnHostResized(new_size); | 187 delegate_->OnHostResized(new_size); |
191 } | 188 } |
192 | 189 |
193 } // namespace aura | 190 } // namespace aura |
OLD | NEW |