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 // RootWindowHost, public: | 73 // RootWindowHost, public: |
74 | 74 |
75 RootWindowHost::~RootWindowHost() { | 75 RootWindowHost::~RootWindowHost() { |
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 RootWindowHost::InitHost() { | 79 void RootWindowHost::InitHost() { |
85 compositor_->SetScaleAndSize(GetDeviceScaleFactorFromDisplay(window()), | 80 compositor_->SetScaleAndSize(GetDeviceScaleFactorFromDisplay(window()), |
86 GetBounds().size()); | 81 GetBounds().size()); |
87 window()->Init(ui::LAYER_NOT_DRAWN); | 82 window()->Init(ui::LAYER_NOT_DRAWN); |
88 compositor_->SetRootLayer(window()->layer()); | 83 compositor_->SetRootLayer(window()->layer()); |
89 transformer_.reset( | 84 transformer_.reset( |
90 new SimpleRootWindowTransformer(window(), gfx::Transform())); | 85 new SimpleRootWindowTransformer(window(), gfx::Transform())); |
91 UpdateRootWindowSize(GetBounds().size()); | 86 UpdateRootWindowSize(GetBounds().size()); |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 *point = gfx::ToFlooredPoint(point_3f.AsPointF()); | 156 *point = gfx::ToFlooredPoint(point_3f.AsPointF()); |
162 } | 157 } |
163 | 158 |
164 //////////////////////////////////////////////////////////////////////////////// | 159 //////////////////////////////////////////////////////////////////////////////// |
165 // RootWindowHost, protected: | 160 // RootWindowHost, protected: |
166 | 161 |
167 RootWindowHost::RootWindowHost() | 162 RootWindowHost::RootWindowHost() |
168 : delegate_(NULL) { | 163 : delegate_(NULL) { |
169 } | 164 } |
170 | 165 |
| 166 void RootWindowHost::DestroyCompositor() { compositor_.reset(); } |
| 167 |
171 void RootWindowHost::CreateCompositor( | 168 void RootWindowHost::CreateCompositor( |
172 gfx::AcceleratedWidget accelerated_widget) { | 169 gfx::AcceleratedWidget accelerated_widget) { |
173 compositor_.reset(new ui::Compositor(GetAcceleratedWidget())); | 170 compositor_.reset(new ui::Compositor(GetAcceleratedWidget())); |
174 DCHECK(compositor_.get()); | 171 DCHECK(compositor_.get()); |
175 } | 172 } |
176 | 173 |
177 void RootWindowHost::NotifyHostResized(const gfx::Size& new_size) { | 174 void RootWindowHost::NotifyHostResized(const gfx::Size& new_size) { |
178 // The compositor should have the same size as the native root window host. | 175 // The compositor should have the same size as the native root window host. |
179 // Get the latest scale from display because it might have been changed. | 176 // Get the latest scale from display because it might have been changed. |
180 compositor_->SetScaleAndSize(GetDeviceScaleFactorFromDisplay(window()), | 177 compositor_->SetScaleAndSize(GetDeviceScaleFactorFromDisplay(window()), |
181 new_size); | 178 new_size); |
182 | 179 |
183 // The layer, and the observers should be notified of the | 180 // The layer, and the observers should be notified of the |
184 // transformed size of the root window. | 181 // transformed size of the root window. |
185 UpdateRootWindowSize(new_size); | 182 UpdateRootWindowSize(new_size); |
186 delegate_->OnHostResized(new_size); | 183 delegate_->OnHostResized(new_size); |
187 } | 184 } |
188 | 185 |
189 } // namespace aura | 186 } // namespace aura |
OLD | NEW |