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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 // GpuServiceProxy. | 49 // GpuServiceProxy. |
50 WindowServer::WindowServer(WindowServerDelegate* delegate) | 50 WindowServer::WindowServer(WindowServerDelegate* delegate) |
51 : delegate_(delegate), | 51 : delegate_(delegate), |
52 next_client_id_(1), | 52 next_client_id_(1), |
53 display_manager_(new DisplayManager(this, &user_id_tracker_)), | 53 display_manager_(new DisplayManager(this, &user_id_tracker_)), |
54 current_operation_(nullptr), | 54 current_operation_(nullptr), |
55 in_destructor_(false), | 55 in_destructor_(false), |
56 next_wm_change_id_(0), | 56 next_wm_change_id_(0), |
57 gpu_proxy_(new GpuServiceProxy(this)), | 57 gpu_proxy_(new GpuServiceProxy(this)), |
58 window_manager_window_tree_factory_set_(this, &user_id_tracker_), | 58 window_manager_window_tree_factory_set_(this, &user_id_tracker_), |
59 display_compositor_client_binding_(this), | 59 display_compositor_client_binding_(this) { |
60 display_compositor_(new DisplayCompositor( | |
61 display_compositor_client_binding_.CreateInterfacePtrAndBind())) { | |
62 user_id_tracker_.AddObserver(this); | 60 user_id_tracker_.AddObserver(this); |
63 OnUserIdAdded(user_id_tracker_.active_id()); | 61 OnUserIdAdded(user_id_tracker_.active_id()); |
| 62 display_compositor_request_ = mojo::GetProxy(&display_compositor_); |
64 } | 63 } |
65 | 64 |
66 WindowServer::~WindowServer() { | 65 WindowServer::~WindowServer() { |
67 in_destructor_ = true; | 66 in_destructor_ = true; |
68 | 67 |
69 for (auto& pair : tree_map_) | 68 for (auto& pair : tree_map_) |
70 pair.second->PrepareForWindowServerShutdown(); | 69 pair.second->PrepareForWindowServerShutdown(); |
71 | 70 |
72 // Destroys the window trees results in querying for the display. Tear down | 71 // Destroys the window trees results in querying for the display. Tear down |
73 // the displays first so that the trees are notified of the display going | 72 // 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... |
489 return nullptr; | 488 return nullptr; |
490 } | 489 } |
491 | 490 |
492 WindowTree* WindowServer::GetCurrentDragLoopInitiator() { | 491 WindowTree* WindowServer::GetCurrentDragLoopInitiator() { |
493 if (current_drag_loop_) | 492 if (current_drag_loop_) |
494 return current_drag_loop_->initiator; | 493 return current_drag_loop_->initiator; |
495 return nullptr; | 494 return nullptr; |
496 } | 495 } |
497 | 496 |
498 void WindowServer::OnDisplayReady(Display* display, bool is_first) { | 497 void WindowServer::OnDisplayReady(Display* display, bool is_first) { |
499 if (gpu_channel_) | |
500 display->platform_display()->OnGpuChannelEstablished(gpu_channel_); | |
501 if (is_first) | 498 if (is_first) |
502 delegate_->OnFirstDisplayReady(); | 499 delegate_->OnFirstDisplayReady(); |
503 } | 500 } |
504 | 501 |
505 void WindowServer::OnNoMoreDisplays() { | 502 void WindowServer::OnNoMoreDisplays() { |
506 delegate_->OnNoMoreDisplays(); | 503 delegate_->OnNoMoreDisplays(); |
507 } | 504 } |
508 | 505 |
509 WindowManagerState* WindowServer::GetWindowManagerStateForUser( | 506 WindowManagerState* WindowServer::GetWindowManagerStateForUser( |
510 const UserId& user_id) { | 507 const UserId& user_id) { |
511 return window_manager_window_tree_factory_set_.GetWindowManagerStateForUser( | 508 return window_manager_window_tree_factory_set_.GetWindowManagerStateForUser( |
512 user_id); | 509 user_id); |
513 } | 510 } |
514 | 511 |
515 ui::DisplayCompositor* WindowServer::GetDisplayCompositor() { | 512 cc::mojom::DisplayCompositor* WindowServer::GetDisplayCompositor() { |
516 return display_compositor_.get(); | 513 return display_compositor_.get(); |
517 } | 514 } |
518 | 515 |
519 bool WindowServer::GetFrameDecorationsForUser( | 516 bool WindowServer::GetFrameDecorationsForUser( |
520 const UserId& user_id, | 517 const UserId& user_id, |
521 mojom::FrameDecorationValuesPtr* values) { | 518 mojom::FrameDecorationValuesPtr* values) { |
522 WindowManagerState* window_manager_state = | 519 WindowManagerState* window_manager_state = |
523 window_manager_window_tree_factory_set_.GetWindowManagerStateForUser( | 520 window_manager_window_tree_factory_set_.GetWindowManagerStateForUser( |
524 user_id); | 521 user_id); |
525 if (!window_manager_state) | 522 if (!window_manager_state) |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
738 ServerWindow* transient_child) { | 735 ServerWindow* transient_child) { |
739 // If we're deleting a window, then this is a superfluous message. | 736 // If we're deleting a window, then this is a superfluous message. |
740 if (current_operation_type() == OperationType::DELETE_WINDOW) | 737 if (current_operation_type() == OperationType::DELETE_WINDOW) |
741 return; | 738 return; |
742 for (auto& pair : tree_map_) { | 739 for (auto& pair : tree_map_) { |
743 pair.second->ProcessTransientWindowRemoved(window, transient_child, | 740 pair.second->ProcessTransientWindowRemoved(window, transient_child, |
744 IsOperationSource(pair.first)); | 741 IsOperationSource(pair.first)); |
745 } | 742 } |
746 } | 743 } |
747 | 744 |
748 void WindowServer::OnGpuChannelEstablished( | 745 void WindowServer::OnGpuServiceInitialized() { |
749 scoped_refptr<gpu::GpuChannelHost> gpu_channel) { | 746 // TODO(fsamuel): Currently we: 1. create the gpu service, 2. we initialize |
750 gpu_channel_ = std::move(gpu_channel); | 747 // GL and then 3. we request a display compositor interface after |
751 const std::set<Display*>& displays = display_manager()->displays(); | 748 // initialization. A display compositor interface can be created at any time, |
752 for (auto* display : displays) | 749 // even prior to completing initialization. If initialization crashes the GPU |
753 display->platform_display()->OnGpuChannelEstablished(gpu_channel_); | 750 // process, then we will still get a connection error on the |
| 751 // |display_compositor_client_binding_| binding. We should investigate doing |
| 752 // this in parallel with initialization in the future. |
| 753 // The display compositor gets its own thread in mus-gpu. The gpu service, |
| 754 // where GL commands are processed resides on its own thread. Various |
| 755 // components of the display compositor such as Display, ResourceProvider, |
| 756 // and GLRenderer block on sync tokens from other command buffers. Thus, |
| 757 // the gpu service must live on a separate thread. |
| 758 gpu_proxy_->CreateDisplayCompositor( |
| 759 std::move(display_compositor_request_), |
| 760 display_compositor_client_binding_.CreateInterfacePtrAndBind()); |
754 // TODO(kylechar): When gpu channel is removed, this can instead happen | 761 // TODO(kylechar): When gpu channel is removed, this can instead happen |
755 // earlier, after GpuServiceProxy::OnInitialized(). | 762 // earlier, after GpuServiceProxy::OnInitialized(). |
756 delegate_->StartDisplayInit(); | 763 delegate_->StartDisplayInit(); |
757 } | 764 } |
758 | 765 |
759 void WindowServer::OnSurfaceCreated(const cc::SurfaceId& surface_id, | 766 void WindowServer::OnSurfaceCreated(const cc::SurfaceId& surface_id, |
760 const gfx::Size& frame_size, | 767 const gfx::Size& frame_size, |
761 float device_scale_factor) { | 768 float device_scale_factor) { |
762 WindowId window_id( | 769 WindowId window_id( |
763 WindowIdFromTransportId(surface_id.frame_sink_id().client_id())); | 770 WindowIdFromTransportId(surface_id.frame_sink_id().client_id())); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
807 void WindowServer::OnUserIdAdded(const UserId& id) { | 814 void WindowServer::OnUserIdAdded(const UserId& id) { |
808 activity_monitor_map_[id] = base::MakeUnique<UserActivityMonitor>(nullptr); | 815 activity_monitor_map_[id] = base::MakeUnique<UserActivityMonitor>(nullptr); |
809 } | 816 } |
810 | 817 |
811 void WindowServer::OnUserIdRemoved(const UserId& id) { | 818 void WindowServer::OnUserIdRemoved(const UserId& id) { |
812 activity_monitor_map_.erase(id); | 819 activity_monitor_map_.erase(id); |
813 } | 820 } |
814 | 821 |
815 } // namespace ws | 822 } // namespace ws |
816 } // namespace ui | 823 } // namespace ui |
OLD | NEW |