Chromium Code Reviews| 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 588 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 599 event_dispatcher->UpdateNonClientAreaForCurrentWindow(); | 599 event_dispatcher->UpdateNonClientAreaForCurrentWindow(); |
| 600 display_root->display()->UpdateNativeCursor( | 600 display_root->display()->UpdateNativeCursor( |
| 601 event_dispatcher->GetCurrentMouseCursor()); | 601 event_dispatcher->GetCurrentMouseCursor()); |
| 602 } | 602 } |
| 603 | 603 |
| 604 bool WindowServer::IsUserInHighContrastMode(const UserId& user) const { | 604 bool WindowServer::IsUserInHighContrastMode(const UserId& user) const { |
| 605 const auto iter = high_contrast_mode_.find(user); | 605 const auto iter = high_contrast_mode_.find(user); |
| 606 return (iter == high_contrast_mode_.end()) ? false : iter->second; | 606 return (iter == high_contrast_mode_.end()) ? false : iter->second; |
| 607 } | 607 } |
| 608 | 608 |
| 609 void WindowServer::ClaimTemporaryReference(ServerWindow* window, | |
| 610 const cc::SurfaceId& surface_id) { | |
| 611 const ClientSpecificId window_client_id = window->id().client_id; | |
| 612 | |
| 613 // Find the first parent window owned by a different client. Since it is a | |
| 614 // a different client, it will need to have a CompositorFrameSink in order to | |
| 615 // embed |window|. | |
| 616 ServerWindow* current = window->parent(); | |
| 617 while (current && current->id().client_id == window_client_id) | |
| 618 current = current->parent(); | |
| 619 | |
| 620 // The client that embeds |window| is expected to submit a CompositorFrame | |
| 621 // that references |surface_id|. Have the parent claim ownership of the | |
| 622 // temporary reference to |surface_id|. If the parent client crashes before it | |
| 623 // adds a surface reference then the GPU can cleanup temporary references. If | |
| 624 // no parent client embeds |window| then tell the GPU to drop the temporary | |
| 625 // reference immediately. | |
| 626 if (current) { | |
| 627 current->GetOrCreateCompositorFrameSinkManager()->ClaimTemporaryReference( | |
| 628 surface_id); | |
| 629 } else { | |
| 630 display_compositor_->DropTemporaryReference(surface_id); | |
| 631 } | |
| 632 } | |
| 633 | |
| 609 ServerWindow* WindowServer::GetRootWindow(const ServerWindow* window) { | 634 ServerWindow* WindowServer::GetRootWindow(const ServerWindow* window) { |
| 610 Display* display = display_manager_->GetDisplayContaining(window); | 635 Display* display = display_manager_->GetDisplayContaining(window); |
| 611 return display ? display->root_window() : nullptr; | 636 return display ? display->root_window() : nullptr; |
| 612 } | 637 } |
| 613 | 638 |
| 614 void WindowServer::OnWindowDestroyed(ServerWindow* window) { | 639 void WindowServer::OnWindowDestroyed(ServerWindow* window) { |
| 615 ProcessWindowDeleted(window); | 640 ProcessWindowDeleted(window); |
| 616 } | 641 } |
| 617 | 642 |
| 618 void WindowServer::OnWillChangeWindowHierarchy(ServerWindow* window, | 643 void WindowServer::OnWillChangeWindowHierarchy(ServerWindow* window, |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 763 // If we're deleting a window, then this is a superfluous message. | 788 // If we're deleting a window, then this is a superfluous message. |
| 764 if (current_operation_type() == OperationType::DELETE_WINDOW) | 789 if (current_operation_type() == OperationType::DELETE_WINDOW) |
| 765 return; | 790 return; |
| 766 for (auto& pair : tree_map_) { | 791 for (auto& pair : tree_map_) { |
| 767 pair.second->ProcessTransientWindowRemoved(window, transient_child, | 792 pair.second->ProcessTransientWindowRemoved(window, transient_child, |
| 768 IsOperationSource(pair.first)); | 793 IsOperationSource(pair.first)); |
| 769 } | 794 } |
| 770 } | 795 } |
| 771 | 796 |
| 772 void WindowServer::OnGpuServiceInitialized() { | 797 void WindowServer::OnGpuServiceInitialized() { |
| 773 // TODO(kylechar): When gpu channel is removed, this can instead happen | |
| 774 // earlier, after GpuHost::OnInitialized(). | |
| 775 delegate_->StartDisplayInit(); | 798 delegate_->StartDisplayInit(); |
| 776 } | 799 } |
| 777 | 800 |
| 778 void WindowServer::OnSurfaceCreated(const cc::SurfaceInfo& surface_info) { | 801 void WindowServer::OnSurfaceCreated(const cc::SurfaceInfo& surface_info) { |
| 779 WindowId window_id( | 802 WindowId window_id( |
| 780 WindowIdFromTransportId(surface_info.id().frame_sink_id().client_id())); | 803 WindowIdFromTransportId(surface_info.id().frame_sink_id().client_id())); |
| 781 ServerWindow* window = GetWindow(window_id); | 804 ServerWindow* window = GetWindow(window_id); |
| 805 | |
| 782 // If the window doesn't have a parent then we have nothing to propagate. | 806 // If the window doesn't have a parent then we have nothing to propagate. |
| 783 if (!window) | 807 if (!window) { |
| 808 display_compositor_->DropTemporaryReference(surface_info.id()); | |
| 784 return; | 809 return; |
| 810 } | |
| 785 | 811 |
| 786 // FrameGenerator will add an appropriate reference for the new surface. | |
| 787 DCHECK(display_manager_->GetDisplayContaining(window)); | 812 DCHECK(display_manager_->GetDisplayContaining(window)); |
| 788 auto* display = display_manager_->GetDisplayContaining(window); | 813 auto* display = display_manager_->GetDisplayContaining(window); |
| 789 if (window == display->GetActiveRootWindow()) { | 814 if (window == display->GetActiveRootWindow()) { |
| 815 // FrameGenerator will add an appropriate reference for the new surface. | |
| 790 display->platform_display()->GetFrameGenerator()->OnSurfaceCreated( | 816 display->platform_display()->GetFrameGenerator()->OnSurfaceCreated( |
| 791 surface_info); | 817 surface_info); |
| 818 | |
| 819 display->root_window() | |
| 820 ->GetOrCreateCompositorFrameSinkManager() | |
| 821 ->ClaimTemporaryReference(surface_info.id()); | |
| 822 } else { | |
| 823 ClaimTemporaryReference(window, surface_info.id()); | |
|
Fady Samuel
2017/03/01 16:07:46
Can't we generalize this to be a single code path
Fady Samuel
2017/03/01 17:08:27
Or at least add a comment explaining why this is a
kylechar
2017/03/01 17:15:23
I'll add a comment with why. The client_id doesn't
| |
| 792 } | 824 } |
| 793 | 825 |
| 794 // This is only used for testing to observe that a window has a | 826 // This is only used for testing to observe that a window has a |
| 795 // CompositorFrame. | 827 // CompositorFrame. |
| 796 if (!window_paint_callback_.is_null()) | 828 if (!window_paint_callback_.is_null()) |
| 797 window_paint_callback_.Run(window); | 829 window_paint_callback_.Run(window); |
| 798 | 830 |
| 799 if (!window->parent()) | 831 if (!window->parent()) |
| 800 return; | 832 return; |
| 801 | 833 |
| 802 WindowTree* window_tree = GetTreeWithId(window->parent()->id().client_id); | 834 WindowTree* window_tree = GetTreeWithId(window->parent()->id().client_id); |
| 803 if (window_tree) | 835 if (window_tree) |
| 804 window_tree->ProcessWindowSurfaceChanged(window, surface_info); | 836 window_tree->ProcessWindowSurfaceChanged(window, surface_info); |
| 805 } | 837 } |
| 806 | 838 |
| 807 void WindowServer::OnActiveUserIdChanged(const UserId& previously_active_id, | 839 void WindowServer::OnActiveUserIdChanged(const UserId& previously_active_id, |
| 808 const UserId& active_id) { | 840 const UserId& active_id) { |
| 809 } | 841 } |
| 810 | 842 |
| 811 void WindowServer::OnUserIdAdded(const UserId& id) { | 843 void WindowServer::OnUserIdAdded(const UserId& id) { |
| 812 activity_monitor_map_[id] = base::MakeUnique<UserActivityMonitor>(nullptr); | 844 activity_monitor_map_[id] = base::MakeUnique<UserActivityMonitor>(nullptr); |
| 813 } | 845 } |
| 814 | 846 |
| 815 void WindowServer::OnUserIdRemoved(const UserId& id) { | 847 void WindowServer::OnUserIdRemoved(const UserId& id) { |
| 816 activity_monitor_map_.erase(id); | 848 activity_monitor_map_.erase(id); |
| 817 } | 849 } |
| 818 | 850 |
| 819 } // namespace ws | 851 } // namespace ws |
| 820 } // namespace ui | 852 } // namespace ui |
| OLD | NEW |