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/connection_manager.h" | 5 #include "mojo/services/view_manager/connection_manager.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "mojo/public/cpp/application/application_connection.h" | 8 #include "mojo/public/cpp/application/application_connection.h" |
9 #include "mojo/public/interfaces/application/service_provider.mojom.h" | 9 #include "mojo/public/interfaces/application/service_provider.mojom.h" |
10 #include "mojo/services/public/cpp/input_events/input_events_type_converters.h" | 10 #include "mojo/services/public/cpp/input_events/input_events_type_converters.h" |
11 #include "mojo/services/view_manager/view_manager_service_impl.h" | 11 #include "mojo/services/view_manager/view_manager_service_impl.h" |
12 #include "ui/aura/env.h" | |
13 | 12 |
14 namespace mojo { | 13 namespace mojo { |
15 namespace service { | 14 namespace service { |
16 | 15 |
17 ConnectionManager::ScopedChange::ScopedChange( | 16 ConnectionManager::ScopedChange::ScopedChange( |
18 ViewManagerServiceImpl* connection, | 17 ViewManagerServiceImpl* connection, |
19 ConnectionManager* connection_manager, | 18 ConnectionManager* connection_manager, |
20 bool is_delete_view) | 19 bool is_delete_view) |
21 : connection_manager_(connection_manager), | 20 : connection_manager_(connection_manager), |
22 connection_id_(connection->id()), | 21 connection_id_(connection->id()), |
23 is_delete_view_(is_delete_view) { | 22 is_delete_view_(is_delete_view) { |
24 connection_manager_->PrepareForChange(this); | 23 connection_manager_->PrepareForChange(this); |
25 } | 24 } |
26 | 25 |
27 ConnectionManager::ScopedChange::~ScopedChange() { | 26 ConnectionManager::ScopedChange::~ScopedChange() { |
28 connection_manager_->FinishChange(); | 27 connection_manager_->FinishChange(); |
29 } | 28 } |
30 | 29 |
31 ConnectionManager::Context::Context() { | |
32 // Pass in false as native viewport creates the PlatformEventSource. | |
33 aura::Env::CreateInstance(false); | |
34 } | |
35 | |
36 ConnectionManager::Context::~Context() { | |
37 aura::Env::DeleteInstance(); | |
38 } | |
39 | |
40 ConnectionManager::ConnectionManager( | 30 ConnectionManager::ConnectionManager( |
41 ApplicationConnection* app_connection, | 31 ApplicationConnection* app_connection, |
42 DisplayManagerDelegate* display_manager_delegate, | |
43 const Callback<void()>& native_viewport_closed_callback) | 32 const Callback<void()>& native_viewport_closed_callback) |
44 : app_connection_(app_connection), | 33 : app_connection_(app_connection), |
45 next_connection_id_(1), | 34 next_connection_id_(1), |
46 display_manager_(app_connection, | 35 display_manager_(app_connection, |
47 this, | 36 this, |
48 display_manager_delegate, | |
49 native_viewport_closed_callback), | 37 native_viewport_closed_callback), |
50 root_(new ServerView(this, RootViewId())), | 38 root_(new ServerView(this, RootViewId())), |
51 current_change_(NULL) { | 39 current_change_(NULL) { |
| 40 root_->SetBounds(gfx::Rect(800, 600)); |
52 } | 41 } |
53 | 42 |
54 ConnectionManager::~ConnectionManager() { | 43 ConnectionManager::~ConnectionManager() { |
55 while (!connections_created_by_connect_.empty()) | 44 while (!connections_created_by_connect_.empty()) |
56 delete *(connections_created_by_connect_.begin()); | 45 delete *(connections_created_by_connect_.begin()); |
57 // All the connections should have been destroyed. | 46 // All the connections should have been destroyed. |
58 DCHECK(connection_map_.empty()); | 47 DCHECK(connection_map_.empty()); |
59 root_.reset(); | 48 root_.reset(); |
60 } | 49 } |
61 | 50 |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 const gfx::Rect& new_bounds) { | 259 const gfx::Rect& new_bounds) { |
271 ProcessViewBoundsChanged(view, old_bounds, new_bounds); | 260 ProcessViewBoundsChanged(view, old_bounds, new_bounds); |
272 if (!view->parent()) | 261 if (!view->parent()) |
273 return; | 262 return; |
274 | 263 |
275 // TODO(sky): optimize this. | 264 // TODO(sky): optimize this. |
276 display_manager_.SchedulePaint(view->parent(), old_bounds); | 265 display_manager_.SchedulePaint(view->parent(), old_bounds); |
277 display_manager_.SchedulePaint(view->parent(), new_bounds); | 266 display_manager_.SchedulePaint(view->parent(), new_bounds); |
278 } | 267 } |
279 | 268 |
280 void ConnectionManager::OnViewBitmapChanged(const ServerView* view) { | 269 void ConnectionManager::OnViewSurfaceIdChanged(const ServerView* view) { |
281 display_manager_.SchedulePaint(view, gfx::Rect(view->bounds().size())); | 270 display_manager_.SchedulePaint(view, gfx::Rect(view->bounds().size())); |
282 } | 271 } |
283 | 272 |
284 void ConnectionManager::OnWillChangeViewVisibility(const ServerView* view) { | 273 void ConnectionManager::OnWillChangeViewVisibility(const ServerView* view) { |
285 for (ConnectionMap::iterator i = connection_map_.begin(); | 274 for (ConnectionMap::iterator i = connection_map_.begin(); |
286 i != connection_map_.end(); | 275 i != connection_map_.end(); |
287 ++i) { | 276 ++i) { |
288 i->second->ProcessWillChangeViewVisibility(view, IsChangeSource(i->first)); | 277 i->second->ProcessWillChangeViewVisibility(view, IsChangeSource(i->first)); |
289 } | 278 } |
290 } | 279 } |
291 | 280 |
292 } // namespace service | 281 } // namespace service |
293 } // namespace mojo | 282 } // namespace mojo |
OLD | NEW |