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 "services/ui/ws/window_server.h" | 5 #include "services/ui/ws/window_server.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
12 #include "base/stl_util.h" | 12 #include "base/stl_util.h" |
| 13 #include "cc/surfaces/surface.h" |
13 #include "services/shell/public/cpp/connection.h" | 14 #include "services/shell/public/cpp/connection.h" |
14 #include "services/ui/ws/display.h" | 15 #include "services/ui/ws/display.h" |
15 #include "services/ui/ws/display_binding.h" | 16 #include "services/ui/ws/display_binding.h" |
16 #include "services/ui/ws/display_manager.h" | 17 #include "services/ui/ws/display_manager.h" |
17 #include "services/ui/ws/gpu_service_proxy.h" | 18 #include "services/ui/ws/gpu_service_proxy.h" |
18 #include "services/ui/ws/operation.h" | 19 #include "services/ui/ws/operation.h" |
19 #include "services/ui/ws/server_window.h" | 20 #include "services/ui/ws/server_window.h" |
| 21 #include "services/ui/ws/server_window_surface_manager.h" |
20 #include "services/ui/ws/user_activity_monitor.h" | 22 #include "services/ui/ws/user_activity_monitor.h" |
21 #include "services/ui/ws/window_coordinate_conversions.h" | 23 #include "services/ui/ws/window_coordinate_conversions.h" |
22 #include "services/ui/ws/window_manager_access_policy.h" | 24 #include "services/ui/ws/window_manager_access_policy.h" |
23 #include "services/ui/ws/window_manager_display_root.h" | 25 #include "services/ui/ws/window_manager_display_root.h" |
24 #include "services/ui/ws/window_manager_state.h" | 26 #include "services/ui/ws/window_manager_state.h" |
25 #include "services/ui/ws/window_manager_window_tree_factory.h" | 27 #include "services/ui/ws/window_manager_window_tree_factory.h" |
26 #include "services/ui/ws/window_server_delegate.h" | 28 #include "services/ui/ws/window_server_delegate.h" |
27 #include "services/ui/ws/window_tree.h" | 29 #include "services/ui/ws/window_tree.h" |
28 #include "services/ui/ws/window_tree_binding.h" | 30 #include "services/ui/ws/window_tree_binding.h" |
29 #include "ui/gfx/geometry/size_conversions.h" | 31 #include "ui/gfx/geometry/size_conversions.h" |
30 | 32 |
31 namespace ui { | 33 namespace ui { |
32 namespace ws { | 34 namespace ws { |
33 | 35 |
34 struct WindowServer::CurrentMoveLoopState { | 36 struct WindowServer::CurrentMoveLoopState { |
35 uint32_t change_id; | 37 uint32_t change_id; |
36 ServerWindow* window; | 38 ServerWindow* window; |
37 WindowTree* initiator; | 39 WindowTree* initiator; |
38 gfx::Rect revert_bounds; | 40 gfx::Rect revert_bounds; |
39 }; | 41 }; |
40 | 42 |
41 struct WindowServer::CurrentDragLoopState { | 43 struct WindowServer::CurrentDragLoopState { |
42 uint32_t change_id; | 44 uint32_t change_id; |
43 ServerWindow* window; | 45 ServerWindow* window; |
44 WindowTree* initiator; | 46 WindowTree* initiator; |
45 }; | 47 }; |
46 | 48 |
47 WindowServer::WindowServer(WindowServerDelegate* delegate) | 49 WindowServer::WindowServer(WindowServerDelegate* delegate) |
48 : delegate_(delegate), | 50 : delegate_(delegate), |
49 surfaces_state_(new SurfacesState()), | 51 display_compositor_(new surfaces::DisplayCompositor(this)), |
50 next_client_id_(1), | 52 next_client_id_(1), |
51 display_manager_(new DisplayManager(this, &user_id_tracker_)), | 53 display_manager_(new DisplayManager(this, &user_id_tracker_)), |
52 current_operation_(nullptr), | 54 current_operation_(nullptr), |
53 in_destructor_(false), | 55 in_destructor_(false), |
54 next_wm_change_id_(0), | 56 next_wm_change_id_(0), |
55 gpu_proxy_(new GpuServiceProxy(this)), | 57 gpu_proxy_(new GpuServiceProxy(this)), |
56 window_manager_window_tree_factory_set_(this, &user_id_tracker_) { | 58 window_manager_window_tree_factory_set_(this, &user_id_tracker_) { |
57 user_id_tracker_.AddObserver(this); | 59 user_id_tracker_.AddObserver(this); |
58 OnUserIdAdded(user_id_tracker_.active_id()); | 60 OnUserIdAdded(user_id_tracker_.active_id()); |
59 } | 61 } |
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
368 | 370 |
369 void WindowServer::ProcessWindowBoundsChanged(const ServerWindow* window, | 371 void WindowServer::ProcessWindowBoundsChanged(const ServerWindow* window, |
370 const gfx::Rect& old_bounds, | 372 const gfx::Rect& old_bounds, |
371 const gfx::Rect& new_bounds) { | 373 const gfx::Rect& new_bounds) { |
372 for (auto& pair : tree_map_) { | 374 for (auto& pair : tree_map_) { |
373 pair.second->ProcessWindowBoundsChanged(window, old_bounds, new_bounds, | 375 pair.second->ProcessWindowBoundsChanged(window, old_bounds, new_bounds, |
374 IsOperationSource(pair.first)); | 376 IsOperationSource(pair.first)); |
375 } | 377 } |
376 } | 378 } |
377 | 379 |
| 380 void WindowServer::ProcessWindowSurfaceCreated( |
| 381 ServerWindow* window, |
| 382 const gfx::Size& size, |
| 383 float device_scale_factor, |
| 384 const cc::SurfaceId& surface_id) { |
| 385 ServerWindowSurfaceManager* surface_manager = |
| 386 window->GetOrCreateSurfaceManager(); |
| 387 for (auto& pair : tree_map_) { |
| 388 cc::SurfaceSequence surface_sequence = |
| 389 surface_manager->CreateSurfaceSequence(); |
| 390 surfaces::DisplayCompositor* compositor = GetDisplayCompositor(); |
| 391 compositor->manager() |
| 392 ->GetSurfaceForId(surface_id) |
| 393 ->AddDestructionDependency(surface_sequence); |
| 394 pair.second->ProcessWindowSurfaceCreated(window, size, |
| 395 1.0f /* device_scale_factor */, |
| 396 surface_id, surface_sequence); |
| 397 } |
| 398 } |
| 399 |
378 void WindowServer::ProcessClientAreaChanged( | 400 void WindowServer::ProcessClientAreaChanged( |
379 const ServerWindow* window, | 401 const ServerWindow* window, |
380 const gfx::Insets& new_client_area, | 402 const gfx::Insets& new_client_area, |
381 const std::vector<gfx::Rect>& new_additional_client_areas) { | 403 const std::vector<gfx::Rect>& new_additional_client_areas) { |
382 for (auto& pair : tree_map_) { | 404 for (auto& pair : tree_map_) { |
383 pair.second->ProcessClientAreaChanged(window, new_client_area, | 405 pair.second->ProcessClientAreaChanged(window, new_client_area, |
384 new_additional_client_areas, | 406 new_additional_client_areas, |
385 IsOperationSource(pair.first)); | 407 IsOperationSource(pair.first)); |
386 } | 408 } |
387 } | 409 } |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
536 void WindowServer::OnNoMoreDisplays() { | 558 void WindowServer::OnNoMoreDisplays() { |
537 delegate_->OnNoMoreDisplays(); | 559 delegate_->OnNoMoreDisplays(); |
538 } | 560 } |
539 | 561 |
540 WindowManagerState* WindowServer::GetWindowManagerStateForUser( | 562 WindowManagerState* WindowServer::GetWindowManagerStateForUser( |
541 const UserId& user_id) { | 563 const UserId& user_id) { |
542 return window_manager_window_tree_factory_set_.GetWindowManagerStateForUser( | 564 return window_manager_window_tree_factory_set_.GetWindowManagerStateForUser( |
543 user_id); | 565 user_id); |
544 } | 566 } |
545 | 567 |
546 ui::SurfacesState* WindowServer::GetSurfacesState() { | 568 ui::surfaces::DisplayCompositor* WindowServer::GetDisplayCompositor() { |
547 return surfaces_state_.get(); | 569 return display_compositor_.get(); |
548 } | 570 } |
549 | 571 |
550 bool WindowServer::GetFrameDecorationsForUser( | 572 bool WindowServer::GetFrameDecorationsForUser( |
551 const UserId& user_id, | 573 const UserId& user_id, |
552 mojom::FrameDecorationValuesPtr* values) { | 574 mojom::FrameDecorationValuesPtr* values) { |
553 WindowManagerState* window_manager_state = | 575 WindowManagerState* window_manager_state = |
554 window_manager_window_tree_factory_set_.GetWindowManagerStateForUser( | 576 window_manager_window_tree_factory_set_.GetWindowManagerStateForUser( |
555 user_id); | 577 user_id); |
556 if (!window_manager_state) | 578 if (!window_manager_state) |
557 return false; | 579 return false; |
558 if (values && window_manager_state->got_frame_decoration_values()) | 580 if (values && window_manager_state->got_frame_decoration_values()) |
559 *values = window_manager_state->frame_decoration_values().Clone(); | 581 *values = window_manager_state->frame_decoration_values().Clone(); |
560 return window_manager_state->got_frame_decoration_values(); | 582 return window_manager_state->got_frame_decoration_values(); |
561 } | 583 } |
562 | 584 |
| 585 void WindowServer::OnSurfaceCreated(const gfx::Size& size, |
| 586 float device_scale_factor, |
| 587 const cc::SurfaceId& surface_id) { |
| 588 WindowId window_id(surface_id.client_id(), surface_id.sink_id()); |
| 589 ServerWindow* window = GetWindow(window_id); |
| 590 if (!window) |
| 591 return; |
| 592 ProcessWindowSurfaceCreated(window, size, device_scale_factor, surface_id); |
| 593 } |
| 594 |
563 bool WindowServer::GetAndClearInFlightWindowManagerChange( | 595 bool WindowServer::GetAndClearInFlightWindowManagerChange( |
564 uint32_t window_manager_change_id, | 596 uint32_t window_manager_change_id, |
565 InFlightWindowManagerChange* change) { | 597 InFlightWindowManagerChange* change) { |
566 // There are valid reasons as to why we wouldn't know about the id. The | 598 // There are valid reasons as to why we wouldn't know about the id. The |
567 // most likely is the client disconnected before the response from the window | 599 // most likely is the client disconnected before the response from the window |
568 // manager came back. | 600 // manager came back. |
569 auto iter = in_flight_wm_change_map_.find(window_manager_change_id); | 601 auto iter = in_flight_wm_change_map_.find(window_manager_change_id); |
570 if (iter == in_flight_wm_change_map_.end()) | 602 if (iter == in_flight_wm_change_map_.end()) |
571 return false; | 603 return false; |
572 | 604 |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
833 void WindowServer::OnUserIdAdded(const UserId& id) { | 865 void WindowServer::OnUserIdAdded(const UserId& id) { |
834 activity_monitor_map_[id] = base::MakeUnique<UserActivityMonitor>(nullptr); | 866 activity_monitor_map_[id] = base::MakeUnique<UserActivityMonitor>(nullptr); |
835 } | 867 } |
836 | 868 |
837 void WindowServer::OnUserIdRemoved(const UserId& id) { | 869 void WindowServer::OnUserIdRemoved(const UserId& id) { |
838 activity_monitor_map_.erase(id); | 870 activity_monitor_map_.erase(id); |
839 } | 871 } |
840 | 872 |
841 } // namespace ws | 873 } // namespace ws |
842 } // namespace ui | 874 } // namespace ui |
OLD | NEW |