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" |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 // GpuServiceProxy. | 48 // GpuServiceProxy. |
49 WindowServer::WindowServer(WindowServerDelegate* delegate) | 49 WindowServer::WindowServer(WindowServerDelegate* delegate) |
50 : delegate_(delegate), | 50 : delegate_(delegate), |
51 next_client_id_(1), | 51 next_client_id_(1), |
52 display_manager_(new DisplayManager(this, &user_id_tracker_)), | 52 display_manager_(new DisplayManager(this, &user_id_tracker_)), |
53 current_operation_(nullptr), | 53 current_operation_(nullptr), |
54 in_destructor_(false), | 54 in_destructor_(false), |
55 next_wm_change_id_(0), | 55 next_wm_change_id_(0), |
56 gpu_proxy_(new GpuServiceProxy(this)), | 56 gpu_proxy_(new GpuServiceProxy(this)), |
57 window_manager_window_tree_factory_set_(this, &user_id_tracker_), | 57 window_manager_window_tree_factory_set_(this, &user_id_tracker_), |
58 display_compositor_client_binding_(this), | 58 display_compositor_client_binding_(this) { |
59 display_compositor_(new DisplayCompositor( | |
60 display_compositor_client_binding_.CreateInterfacePtrAndBind())) { | |
61 user_id_tracker_.AddObserver(this); | 59 user_id_tracker_.AddObserver(this); |
62 OnUserIdAdded(user_id_tracker_.active_id()); | 60 OnUserIdAdded(user_id_tracker_.active_id()); |
| 61 display_compositor_request_ = mojo::GetProxy(&display_compositor_); |
63 } | 62 } |
64 | 63 |
65 WindowServer::~WindowServer() { | 64 WindowServer::~WindowServer() { |
66 in_destructor_ = true; | 65 in_destructor_ = true; |
67 | 66 |
68 for (auto& pair : tree_map_) | 67 for (auto& pair : tree_map_) |
69 pair.second->PrepareForWindowServerShutdown(); | 68 pair.second->PrepareForWindowServerShutdown(); |
70 | 69 |
71 // Destroys the window trees results in querying for the display. Tear down | 70 // Destroys the window trees results in querying for the display. Tear down |
72 // the displays first so that the trees are notified of the display going | 71 // the displays first so that the trees are notified of the display going |
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
488 return nullptr; | 487 return nullptr; |
489 } | 488 } |
490 | 489 |
491 WindowTree* WindowServer::GetCurrentDragLoopInitiator() { | 490 WindowTree* WindowServer::GetCurrentDragLoopInitiator() { |
492 if (current_drag_loop_) | 491 if (current_drag_loop_) |
493 return current_drag_loop_->initiator; | 492 return current_drag_loop_->initiator; |
494 return nullptr; | 493 return nullptr; |
495 } | 494 } |
496 | 495 |
497 void WindowServer::OnDisplayReady(Display* display, bool is_first) { | 496 void WindowServer::OnDisplayReady(Display* display, bool is_first) { |
498 if (gpu_channel_) | |
499 display->platform_display()->OnGpuChannelEstablished(gpu_channel_); | |
500 if (is_first) | 497 if (is_first) |
501 delegate_->OnFirstDisplayReady(); | 498 delegate_->OnFirstDisplayReady(); |
502 } | 499 } |
503 | 500 |
504 void WindowServer::OnNoMoreDisplays() { | 501 void WindowServer::OnNoMoreDisplays() { |
505 delegate_->OnNoMoreDisplays(); | 502 delegate_->OnNoMoreDisplays(); |
506 } | 503 } |
507 | 504 |
508 WindowManagerState* WindowServer::GetWindowManagerStateForUser( | 505 WindowManagerState* WindowServer::GetWindowManagerStateForUser( |
509 const UserId& user_id) { | 506 const UserId& user_id) { |
510 return window_manager_window_tree_factory_set_.GetWindowManagerStateForUser( | 507 return window_manager_window_tree_factory_set_.GetWindowManagerStateForUser( |
511 user_id); | 508 user_id); |
512 } | 509 } |
513 | 510 |
514 ui::DisplayCompositor* WindowServer::GetDisplayCompositor() { | 511 cc::mojom::DisplayCompositor* WindowServer::GetDisplayCompositor() { |
515 return display_compositor_.get(); | 512 return display_compositor_.get(); |
516 } | 513 } |
517 | 514 |
518 bool WindowServer::GetFrameDecorationsForUser( | 515 bool WindowServer::GetFrameDecorationsForUser( |
519 const UserId& user_id, | 516 const UserId& user_id, |
520 mojom::FrameDecorationValuesPtr* values) { | 517 mojom::FrameDecorationValuesPtr* values) { |
521 WindowManagerState* window_manager_state = | 518 WindowManagerState* window_manager_state = |
522 window_manager_window_tree_factory_set_.GetWindowManagerStateForUser( | 519 window_manager_window_tree_factory_set_.GetWindowManagerStateForUser( |
523 user_id); | 520 user_id); |
524 if (!window_manager_state) | 521 if (!window_manager_state) |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
737 ServerWindow* transient_child) { | 734 ServerWindow* transient_child) { |
738 // If we're deleting a window, then this is a superfluous message. | 735 // If we're deleting a window, then this is a superfluous message. |
739 if (current_operation_type() == OperationType::DELETE_WINDOW) | 736 if (current_operation_type() == OperationType::DELETE_WINDOW) |
740 return; | 737 return; |
741 for (auto& pair : tree_map_) { | 738 for (auto& pair : tree_map_) { |
742 pair.second->ProcessTransientWindowRemoved(window, transient_child, | 739 pair.second->ProcessTransientWindowRemoved(window, transient_child, |
743 IsOperationSource(pair.first)); | 740 IsOperationSource(pair.first)); |
744 } | 741 } |
745 } | 742 } |
746 | 743 |
747 void WindowServer::OnGpuChannelEstablished( | 744 void WindowServer::OnGpuServiceInitialized() { |
748 scoped_refptr<gpu::GpuChannelHost> gpu_channel) { | 745 gpu_proxy_->CreateDisplayCompositor( |
749 gpu_channel_ = std::move(gpu_channel); | 746 std::move(display_compositor_request_), |
750 const std::set<Display*>& displays = display_manager()->displays(); | 747 display_compositor_client_binding_.CreateInterfacePtrAndBind()); |
751 for (auto* display : displays) | |
752 display->platform_display()->OnGpuChannelEstablished(gpu_channel_); | |
753 // TODO(kylechar): When gpu channel is removed, this can instead happen | 748 // TODO(kylechar): When gpu channel is removed, this can instead happen |
754 // earlier, after GpuServiceProxy::OnInitialized(). | 749 // earlier, after GpuServiceProxy::OnInitialized(). |
755 delegate_->StartDisplayInit(); | 750 delegate_->StartDisplayInit(); |
756 } | 751 } |
757 | 752 |
758 void WindowServer::OnSurfaceCreated(const cc::SurfaceId& surface_id, | 753 void WindowServer::OnSurfaceCreated(const cc::SurfaceId& surface_id, |
759 const gfx::Size& frame_size, | 754 const gfx::Size& frame_size, |
760 float device_scale_factor) { | 755 float device_scale_factor) { |
761 WindowId window_id( | 756 WindowId window_id( |
762 WindowIdFromTransportId(surface_id.frame_sink_id().client_id())); | 757 WindowIdFromTransportId(surface_id.frame_sink_id().client_id())); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
799 void WindowServer::OnUserIdAdded(const UserId& id) { | 794 void WindowServer::OnUserIdAdded(const UserId& id) { |
800 activity_monitor_map_[id] = base::MakeUnique<UserActivityMonitor>(nullptr); | 795 activity_monitor_map_[id] = base::MakeUnique<UserActivityMonitor>(nullptr); |
801 } | 796 } |
802 | 797 |
803 void WindowServer::OnUserIdRemoved(const UserId& id) { | 798 void WindowServer::OnUserIdRemoved(const UserId& id) { |
804 activity_monitor_map_.erase(id); | 799 activity_monitor_map_.erase(id); |
805 } | 800 } |
806 | 801 |
807 } // namespace ws | 802 } // namespace ws |
808 } // namespace ui | 803 } // namespace ui |
OLD | NEW |