OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "mojo/services/view_manager/root_view_manager.h" | 5 #include "mojo/services/view_manager/display_manager.h" |
6 | 6 |
7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
8 #include "base/scoped_observer.h" | 8 #include "base/scoped_observer.h" |
9 #include "mojo/public/cpp/application/application_connection.h" | 9 #include "mojo/public/cpp/application/application_connection.h" |
10 #include "mojo/services/public/interfaces/gpu/gpu.mojom.h" | 10 #include "mojo/services/public/interfaces/gpu/gpu.mojom.h" |
| 11 #include "mojo/services/view_manager/display_manager_delegate.h" |
11 #include "mojo/services/view_manager/root_node_manager.h" | 12 #include "mojo/services/view_manager/root_node_manager.h" |
12 #include "mojo/services/view_manager/root_view_manager_delegate.h" | |
13 #include "mojo/services/view_manager/screen_impl.h" | 13 #include "mojo/services/view_manager/screen_impl.h" |
14 #include "mojo/services/view_manager/window_tree_host_impl.h" | 14 #include "mojo/services/view_manager/window_tree_host_impl.h" |
15 #include "ui/aura/client/default_capture_client.h" | 15 #include "ui/aura/client/default_capture_client.h" |
16 #include "ui/aura/client/focus_client.h" | 16 #include "ui/aura/client/focus_client.h" |
17 #include "ui/aura/client/window_tree_client.h" | 17 #include "ui/aura/client/window_tree_client.h" |
18 #include "ui/aura/window.h" | 18 #include "ui/aura/window.h" |
19 #include "ui/aura/window_delegate.h" | 19 #include "ui/aura/window_delegate.h" |
20 #include "ui/base/cursor/cursor.h" | 20 #include "ui/base/cursor/cursor.h" |
21 #include "ui/base/hit_test.h" | 21 #include "ui/base/hit_test.h" |
22 #include "ui/compositor/layer.h" | 22 #include "ui/compositor/layer.h" |
(...skipping 24 matching lines...) Expand all Loading... |
47 origin.x(), origin.y()); | 47 origin.x(), origin.y()); |
48 std::vector<const Node*> children(node->GetChildren()); | 48 std::vector<const Node*> children(node->GetChildren()); |
49 for (size_t i = 0; i < children.size(); ++i) { | 49 for (size_t i = 0; i < children.size(); ++i) { |
50 PaintNodeTree(canvas, children[i], | 50 PaintNodeTree(canvas, children[i], |
51 origin + children[i]->bounds().OffsetFromOrigin()); | 51 origin + children[i]->bounds().OffsetFromOrigin()); |
52 } | 52 } |
53 } | 53 } |
54 | 54 |
55 } // namespace | 55 } // namespace |
56 | 56 |
57 class RootViewManager::RootWindowDelegateImpl : public aura::WindowDelegate { | 57 class DisplayManager::RootWindowDelegateImpl : public aura::WindowDelegate { |
58 public: | 58 public: |
59 explicit RootWindowDelegateImpl(const Node* root_node) | 59 explicit RootWindowDelegateImpl(const Node* root_node) |
60 : root_node_(root_node) {} | 60 : root_node_(root_node) {} |
61 virtual ~RootWindowDelegateImpl() {} | 61 virtual ~RootWindowDelegateImpl() {} |
62 | 62 |
63 // aura::WindowDelegate: | 63 // aura::WindowDelegate: |
64 virtual gfx::Size GetMinimumSize() const OVERRIDE { | 64 virtual gfx::Size GetMinimumSize() const OVERRIDE { |
65 return gfx::Size(); | 65 return gfx::Size(); |
66 } | 66 } |
67 virtual gfx::Size GetMaximumSize() const OVERRIDE { | 67 virtual gfx::Size GetMaximumSize() const OVERRIDE { |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 } | 150 } |
151 | 151 |
152 private: | 152 private: |
153 aura::Window* window_; | 153 aura::Window* window_; |
154 | 154 |
155 scoped_ptr<aura::client::DefaultCaptureClient> capture_client_; | 155 scoped_ptr<aura::client::DefaultCaptureClient> capture_client_; |
156 | 156 |
157 DISALLOW_COPY_AND_ASSIGN(WindowTreeClientImpl); | 157 DISALLOW_COPY_AND_ASSIGN(WindowTreeClientImpl); |
158 }; | 158 }; |
159 | 159 |
160 RootViewManager::RootViewManager( | 160 DisplayManager::DisplayManager( |
161 ApplicationConnection* app_connection, | 161 ApplicationConnection* app_connection, |
162 RootNodeManager* root_node, | 162 RootNodeManager* root_node, |
163 RootViewManagerDelegate* delegate, | 163 DisplayManagerDelegate* delegate, |
164 const Callback<void()>& native_viewport_closed_callback) | 164 const Callback<void()>& native_viewport_closed_callback) |
165 : delegate_(delegate), | 165 : delegate_(delegate), |
166 root_node_manager_(root_node), | 166 root_node_manager_(root_node), |
167 in_setup_(false), | 167 in_setup_(false), |
168 root_window_(NULL) { | 168 root_window_(NULL) { |
169 screen_.reset(ScreenImpl::Create()); | 169 screen_.reset(ScreenImpl::Create()); |
170 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, screen_.get()); | 170 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, screen_.get()); |
171 NativeViewportPtr viewport; | 171 NativeViewportPtr viewport; |
172 app_connection->ConnectToService( | 172 app_connection->ConnectToService( |
173 "mojo:mojo_native_viewport_service", &viewport); | 173 "mojo:mojo_native_viewport_service", &viewport); |
174 GpuPtr gpu_service; | 174 GpuPtr gpu_service; |
175 // TODO(jamesr): Should be mojo:mojo_gpu_service | 175 // TODO(jamesr): Should be mojo:mojo_gpu_service |
176 app_connection->ConnectToService("mojo:mojo_native_viewport_service", | 176 app_connection->ConnectToService("mojo:mojo_native_viewport_service", |
177 &gpu_service); | 177 &gpu_service); |
178 window_tree_host_.reset(new WindowTreeHostImpl( | 178 window_tree_host_.reset(new WindowTreeHostImpl( |
179 viewport.Pass(), | 179 viewport.Pass(), |
180 gpu_service.Pass(), | 180 gpu_service.Pass(), |
181 gfx::Rect(800, 600), | 181 gfx::Rect(800, 600), |
182 base::Bind(&RootViewManager::OnCompositorCreated, base::Unretained(this)), | 182 base::Bind(&DisplayManager::OnCompositorCreated, base::Unretained(this)), |
183 native_viewport_closed_callback, | 183 native_viewport_closed_callback, |
184 base::Bind(&RootNodeManager::DispatchNodeInputEventToWindowManager, | 184 base::Bind(&RootNodeManager::DispatchNodeInputEventToWindowManager, |
185 base::Unretained(root_node_manager_)))); | 185 base::Unretained(root_node_manager_)))); |
186 } | 186 } |
187 | 187 |
188 RootViewManager::~RootViewManager() { | 188 DisplayManager::~DisplayManager() { |
189 window_tree_client_.reset(); | 189 window_tree_client_.reset(); |
190 window_tree_host_.reset(); | 190 window_tree_host_.reset(); |
191 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, NULL); | 191 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, NULL); |
192 } | 192 } |
193 | 193 |
194 void RootViewManager::SchedulePaint(const Node* node, const gfx::Rect& bounds) { | 194 void DisplayManager::SchedulePaint(const Node* node, const gfx::Rect& bounds) { |
195 if (root_window_) | 195 if (root_window_) |
196 root_window_->SchedulePaintInRect(ConvertRectToRoot(node, bounds)); | 196 root_window_->SchedulePaintInRect(ConvertRectToRoot(node, bounds)); |
197 } | 197 } |
198 | 198 |
199 void RootViewManager::OnCompositorCreated() { | 199 void DisplayManager::OnCompositorCreated() { |
200 base::AutoReset<bool> resetter(&in_setup_, true); | 200 base::AutoReset<bool> resetter(&in_setup_, true); |
201 window_tree_host_->InitHost(); | 201 window_tree_host_->InitHost(); |
202 | 202 |
203 window_delegate_.reset( | 203 window_delegate_.reset( |
204 new RootWindowDelegateImpl(root_node_manager_->root())); | 204 new RootWindowDelegateImpl(root_node_manager_->root())); |
205 root_window_ = new aura::Window(window_delegate_.get()); | 205 root_window_ = new aura::Window(window_delegate_.get()); |
206 root_window_->Init(aura::WINDOW_LAYER_TEXTURED); | 206 root_window_->Init(aura::WINDOW_LAYER_TEXTURED); |
207 root_window_->Show(); | 207 root_window_->Show(); |
208 root_window_->SetBounds( | 208 root_window_->SetBounds( |
209 gfx::Rect(window_tree_host_->window()->bounds().size())); | 209 gfx::Rect(window_tree_host_->window()->bounds().size())); |
210 window_tree_host_->window()->AddChild(root_window_); | 210 window_tree_host_->window()->AddChild(root_window_); |
211 | 211 |
212 root_node_manager_->root()->SetBounds( | 212 root_node_manager_->root()->SetBounds( |
213 gfx::Rect(window_tree_host_->window()->bounds().size())); | 213 gfx::Rect(window_tree_host_->window()->bounds().size())); |
214 | 214 |
215 window_tree_client_.reset( | 215 window_tree_client_.reset( |
216 new WindowTreeClientImpl(window_tree_host_->window())); | 216 new WindowTreeClientImpl(window_tree_host_->window())); |
217 | 217 |
218 focus_client_.reset(new FocusClientImpl); | 218 focus_client_.reset(new FocusClientImpl); |
219 aura::client::SetFocusClient(window_tree_host_->window(), | 219 aura::client::SetFocusClient(window_tree_host_->window(), |
220 focus_client_.get()); | 220 focus_client_.get()); |
221 | 221 |
222 window_tree_host_->Show(); | 222 window_tree_host_->Show(); |
223 | 223 |
224 delegate_->OnRootViewManagerWindowTreeHostCreated(); | 224 delegate_->OnDisplayManagerWindowTreeHostCreated(); |
225 } | 225 } |
226 | 226 |
227 } // namespace service | 227 } // namespace service |
228 } // namespace mojo | 228 } // namespace mojo |
OLD | NEW |