| 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 "services/service_manager/public/cpp/connection.h" | 13 #include "services/service_manager/public/cpp/connection.h" |
| 14 #include "services/ui/ws/display.h" | 14 #include "services/ui/ws/display.h" |
| 15 #include "services/ui/ws/display_manager.h" | 15 #include "services/ui/ws/display_manager.h" |
| 16 #include "services/ui/ws/frame_generator.h" | 16 #include "services/ui/ws/frame_generator.h" |
| 17 #include "services/ui/ws/gpu_service_proxy.h" | 17 #include "services/ui/ws/gpu_service_proxy.h" |
| 18 #include "services/ui/ws/operation.h" | 18 #include "services/ui/ws/operation.h" |
| 19 #include "services/ui/ws/server_window.h" | 19 #include "services/ui/ws/server_window.h" |
| 20 #include "services/ui/ws/server_window_compositor_frame_sink_manager.h" | 20 #include "services/ui/ws/server_window_compositor_frame_sink_manager.h" |
| 21 #include "services/ui/ws/user_activity_monitor.h" | 21 #include "services/ui/ws/user_activity_monitor.h" |
| 22 #include "services/ui/ws/window_coordinate_conversions.h" | 22 #include "services/ui/ws/window_coordinate_conversions.h" |
| 23 #include "services/ui/ws/window_manager_access_policy.h" | 23 #include "services/ui/ws/window_manager_access_policy.h" |
| 24 #include "services/ui/ws/window_manager_display_root.h" | 24 #include "services/ui/ws/window_manager_display_root.h" |
| 25 #include "services/ui/ws/window_manager_state.h" | 25 #include "services/ui/ws/window_manager_state.h" |
| 26 #include "services/ui/ws/window_manager_window_tree_factory.h" | 26 #include "services/ui/ws/window_manager_window_tree_factory.h" |
| 27 #include "services/ui/ws/window_server_delegate.h" | 27 #include "services/ui/ws/window_server_delegate.h" |
| 28 #include "services/ui/ws/window_tree.h" | 28 #include "services/ui/ws/window_tree.h" |
| 29 #include "services/ui/ws/window_tree_binding.h" | 29 #include "services/ui/ws/window_tree_binding.h" |
| 30 #include "ui/gfx/geometry/dip_util.h" |
| 30 #include "ui/gfx/geometry/size_conversions.h" | 31 #include "ui/gfx/geometry/size_conversions.h" |
| 31 | 32 |
| 32 namespace ui { | 33 namespace ui { |
| 33 namespace ws { | 34 namespace ws { |
| 34 | 35 |
| 35 struct WindowServer::CurrentMoveLoopState { | 36 struct WindowServer::CurrentMoveLoopState { |
| 36 uint32_t change_id; | 37 uint32_t change_id; |
| 37 ServerWindow* window; | 38 ServerWindow* window; |
| 38 WindowTree* initiator; | 39 WindowTree* initiator; |
| 39 gfx::Rect revert_bounds; | 40 gfx::Rect revert_bounds; |
| (...skipping 704 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 744 } | 745 } |
| 745 } | 746 } |
| 746 | 747 |
| 747 void WindowServer::OnGpuServiceInitialized() { | 748 void WindowServer::OnGpuServiceInitialized() { |
| 748 // TODO(kylechar): When gpu channel is removed, this can instead happen | 749 // TODO(kylechar): When gpu channel is removed, this can instead happen |
| 749 // earlier, after GpuServiceProxy::OnInitialized(). | 750 // earlier, after GpuServiceProxy::OnInitialized(). |
| 750 delegate_->StartDisplayInit(); | 751 delegate_->StartDisplayInit(); |
| 751 } | 752 } |
| 752 | 753 |
| 753 void WindowServer::OnSurfaceCreated(const cc::SurfaceId& surface_id, | 754 void WindowServer::OnSurfaceCreated(const cc::SurfaceId& surface_id, |
| 754 const gfx::Size& frame_size, | 755 const gfx::Size& frame_size_in_dip, |
| 755 float device_scale_factor) { | 756 float device_scale_factor) { |
| 756 WindowId window_id( | 757 WindowId window_id( |
| 757 WindowIdFromTransportId(surface_id.frame_sink_id().client_id())); | 758 WindowIdFromTransportId(surface_id.frame_sink_id().client_id())); |
| 758 mojom::CompositorFrameSinkType compositor_frame_sink_type( | 759 mojom::CompositorFrameSinkType compositor_frame_sink_type( |
| 759 static_cast<mojom::CompositorFrameSinkType>( | 760 static_cast<mojom::CompositorFrameSinkType>( |
| 760 surface_id.frame_sink_id().sink_id())); | 761 surface_id.frame_sink_id().sink_id())); |
| 761 ServerWindow* window = GetWindow(window_id); | 762 ServerWindow* window = GetWindow(window_id); |
| 762 // If the window doesn't have a parent then we have nothing to propagate. | 763 // If the window doesn't have a parent then we have nothing to propagate. |
| 763 if (!window) | 764 if (!window) |
| 764 return; | 765 return; |
| 765 | 766 |
| 766 // Cache the last submitted surface ID in the window server. | 767 // Cache the last submitted surface ID in the window server. |
| 767 // DisplayCompositorFrameSink may submit a CompositorFrame without | 768 // DisplayCompositorFrameSink may submit a CompositorFrame without |
| 768 // creating a CompositorFrameSinkManager. | 769 // creating a CompositorFrameSinkManager. |
| 770 gfx::Size frame_size_in_pixels = |
| 771 gfx::ConvertSizeToPixel(device_scale_factor, frame_size_in_dip); |
| 769 window->GetOrCreateCompositorFrameSinkManager()->SetLatestSurfaceInfo( | 772 window->GetOrCreateCompositorFrameSinkManager()->SetLatestSurfaceInfo( |
| 770 compositor_frame_sink_type, surface_id, frame_size); | 773 compositor_frame_sink_type, surface_id, frame_size_in_pixels); |
| 771 | 774 |
| 772 // FrameGenerator will add an appropriate reference for the new surface. | 775 // FrameGenerator will add an appropriate reference for the new surface. |
| 773 DCHECK(display_manager_->GetDisplayContaining(window)); | 776 DCHECK(display_manager_->GetDisplayContaining(window)); |
| 774 display_manager_->GetDisplayContaining(window) | 777 display_manager_->GetDisplayContaining(window) |
| 775 ->platform_display() | 778 ->platform_display() |
| 776 ->GetFrameGenerator() | 779 ->GetFrameGenerator() |
| 777 ->OnSurfaceCreated(surface_id, window); | 780 ->OnSurfaceCreated(surface_id, window); |
| 778 | 781 |
| 779 // This is only used for testing to observe that a window has a | 782 // This is only used for testing to observe that a window has a |
| 780 // CompositorFrame. | 783 // CompositorFrame. |
| 781 if (!window_paint_callback_.is_null()) | 784 if (!window_paint_callback_.is_null()) |
| 782 window_paint_callback_.Run(window); | 785 window_paint_callback_.Run(window); |
| 783 | 786 |
| 784 // We only care about propagating default surface IDs. | 787 // We only care about propagating default surface IDs. |
| 785 // TODO(fsamuel, sadrul): we should get rid of CompositorFrameSinkTypes. | 788 // TODO(fsamuel, sadrul): we should get rid of CompositorFrameSinkTypes. |
| 786 if (compositor_frame_sink_type != mojom::CompositorFrameSinkType::DEFAULT || | 789 if (compositor_frame_sink_type != mojom::CompositorFrameSinkType::DEFAULT || |
| 787 !window->parent()) { | 790 !window->parent()) { |
| 788 return; | 791 return; |
| 789 } | 792 } |
| 790 WindowTree* window_tree = GetTreeWithId(window->parent()->id().client_id); | 793 WindowTree* window_tree = GetTreeWithId(window->parent()->id().client_id); |
| 791 if (window_tree) { | 794 if (window_tree) { |
| 792 window_tree->ProcessWindowSurfaceChanged(window, surface_id, frame_size, | 795 window_tree->ProcessWindowSurfaceChanged( |
| 793 device_scale_factor); | 796 window, surface_id, frame_size_in_pixels, device_scale_factor); |
| 794 } | 797 } |
| 795 } | 798 } |
| 796 | 799 |
| 797 void WindowServer::OnActiveUserIdChanged(const UserId& previously_active_id, | 800 void WindowServer::OnActiveUserIdChanged(const UserId& previously_active_id, |
| 798 const UserId& active_id) { | 801 const UserId& active_id) { |
| 799 } | 802 } |
| 800 | 803 |
| 801 void WindowServer::OnUserIdAdded(const UserId& id) { | 804 void WindowServer::OnUserIdAdded(const UserId& id) { |
| 802 activity_monitor_map_[id] = base::MakeUnique<UserActivityMonitor>(nullptr); | 805 activity_monitor_map_[id] = base::MakeUnique<UserActivityMonitor>(nullptr); |
| 803 } | 806 } |
| 804 | 807 |
| 805 void WindowServer::OnUserIdRemoved(const UserId& id) { | 808 void WindowServer::OnUserIdRemoved(const UserId& id) { |
| 806 activity_monitor_map_.erase(id); | 809 activity_monitor_map_.erase(id); |
| 807 } | 810 } |
| 808 | 811 |
| 809 } // namespace ws | 812 } // namespace ws |
| 810 } // namespace ui | 813 } // namespace ui |
| OLD | NEW |