Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(944)

Side by Side Diff: services/ui/ws/window_server.cc

Issue 2715663007: Implement temporary reference assignment with DisplayCompositor. (Closed)
Patch Set: Rebase. Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « services/ui/ws/window_server.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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::HandleTemporaryReferenceForNewSurface(
610 const cc::SurfaceId& surface_id,
611 ServerWindow* window) {
612 // TODO(kylechar): Investigate adding tests for this.
613 const ClientSpecificId window_client_id = window->id().client_id;
614
615 // Find the root ServerWindow for the client that embeds |window|, which is
616 // the root of the client that embeds |surface_id|. The client that embeds
617 // |surface_id| created |window|, so |window| will have the client id of the
618 // embedder. The root window of the embedder will have been created by it's
619 // embedder, so the first ServerWindow with a different client id will be the
620 // root of the embedder.
621 ServerWindow* current = window->parent();
622 while (current && current->id().client_id == window_client_id)
623 current = current->parent();
624
625 // The client that embeds |window| is expected to submit a CompositorFrame
626 // that references |surface_id|. Have the parent claim ownership of the
627 // temporary reference to |surface_id|. If the parent client crashes before it
628 // adds a surface reference then the GPU can cleanup temporary references. If
629 // no parent client embeds |window| then tell the GPU to drop the temporary
630 // reference immediately.
631 if (current) {
632 current->GetOrCreateCompositorFrameSinkManager()->ClaimTemporaryReference(
633 surface_id);
634 } else {
635 display_compositor_->DropTemporaryReference(surface_id);
636 }
637 }
638
609 ServerWindow* WindowServer::GetRootWindow(const ServerWindow* window) { 639 ServerWindow* WindowServer::GetRootWindow(const ServerWindow* window) {
610 Display* display = display_manager_->GetDisplayContaining(window); 640 Display* display = display_manager_->GetDisplayContaining(window);
611 return display ? display->root_window() : nullptr; 641 return display ? display->root_window() : nullptr;
612 } 642 }
613 643
614 void WindowServer::OnWindowDestroyed(ServerWindow* window) { 644 void WindowServer::OnWindowDestroyed(ServerWindow* window) {
615 ProcessWindowDeleted(window); 645 ProcessWindowDeleted(window);
616 } 646 }
617 647
618 void WindowServer::OnWillChangeWindowHierarchy(ServerWindow* window, 648 void WindowServer::OnWillChangeWindowHierarchy(ServerWindow* window,
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
763 // If we're deleting a window, then this is a superfluous message. 793 // If we're deleting a window, then this is a superfluous message.
764 if (current_operation_type() == OperationType::DELETE_WINDOW) 794 if (current_operation_type() == OperationType::DELETE_WINDOW)
765 return; 795 return;
766 for (auto& pair : tree_map_) { 796 for (auto& pair : tree_map_) {
767 pair.second->ProcessTransientWindowRemoved(window, transient_child, 797 pair.second->ProcessTransientWindowRemoved(window, transient_child,
768 IsOperationSource(pair.first)); 798 IsOperationSource(pair.first));
769 } 799 }
770 } 800 }
771 801
772 void WindowServer::OnGpuServiceInitialized() { 802 void WindowServer::OnGpuServiceInitialized() {
773 // TODO(kylechar): When gpu channel is removed, this can instead happen
774 // earlier, after GpuHost::OnInitialized().
775 delegate_->StartDisplayInit(); 803 delegate_->StartDisplayInit();
776 } 804 }
777 805
778 void WindowServer::OnSurfaceCreated(const cc::SurfaceInfo& surface_info) { 806 void WindowServer::OnSurfaceCreated(const cc::SurfaceInfo& surface_info) {
779 WindowId window_id( 807 WindowId window_id(
780 WindowIdFromTransportId(surface_info.id().frame_sink_id().client_id())); 808 WindowIdFromTransportId(surface_info.id().frame_sink_id().client_id()));
781 ServerWindow* window = GetWindow(window_id); 809 ServerWindow* window = GetWindow(window_id);
782 // If the window doesn't have a parent then we have nothing to propagate. 810
783 if (!window) 811 // If the window doesn't exist then we have nothing to propagate.
812 if (!window) {
813 display_compositor_->DropTemporaryReference(surface_info.id());
784 return; 814 return;
785
786 // FrameGenerator will add an appropriate reference for the new surface.
787 DCHECK(display_manager_->GetDisplayContaining(window));
788 auto* display = display_manager_->GetDisplayContaining(window);
789 if (window == display->GetActiveRootWindow()) {
790 display->platform_display()->GetFrameGenerator()->OnSurfaceCreated(
791 surface_info);
792 } 815 }
793 816
794 // This is only used for testing to observe that a window has a 817 // This is only used for testing to observe that a window has a
795 // CompositorFrame. 818 // CompositorFrame.
796 if (!window_paint_callback_.is_null()) 819 if (!window_paint_callback_.is_null())
797 window_paint_callback_.Run(window); 820 window_paint_callback_.Run(window);
798 821
822 auto* display = display_manager_->GetDisplayContaining(window);
823 if (display && window == display->GetActiveRootWindow()) {
824 // A new surface for a WindowManager root has been created. This is a
825 // special case because ServerWindows created by the WindowServer are not
826 // part of a WindowTree. Send the SurfaceId directly to FrameGenerator and
827 // claim the temporary reference for the display root.
828 display->platform_display()->GetFrameGenerator()->OnSurfaceCreated(
829 surface_info);
830 display->root_window()
831 ->GetOrCreateCompositorFrameSinkManager()
832 ->ClaimTemporaryReference(surface_info.id());
833 return;
834 }
835
836 HandleTemporaryReferenceForNewSurface(surface_info.id(), window);
837
799 if (!window->parent()) 838 if (!window->parent())
800 return; 839 return;
801 840
802 WindowTree* window_tree = GetTreeWithId(window->parent()->id().client_id); 841 WindowTree* window_tree = GetTreeWithId(window->parent()->id().client_id);
803 if (window_tree) 842 if (window_tree)
804 window_tree->ProcessWindowSurfaceChanged(window, surface_info); 843 window_tree->ProcessWindowSurfaceChanged(window, surface_info);
805 } 844 }
806 845
807 void WindowServer::OnActiveUserIdChanged(const UserId& previously_active_id, 846 void WindowServer::OnActiveUserIdChanged(const UserId& previously_active_id,
808 const UserId& active_id) { 847 const UserId& active_id) {
809 } 848 }
810 849
811 void WindowServer::OnUserIdAdded(const UserId& id) { 850 void WindowServer::OnUserIdAdded(const UserId& id) {
812 activity_monitor_map_[id] = base::MakeUnique<UserActivityMonitor>(nullptr); 851 activity_monitor_map_[id] = base::MakeUnique<UserActivityMonitor>(nullptr);
813 } 852 }
814 853
815 void WindowServer::OnUserIdRemoved(const UserId& id) { 854 void WindowServer::OnUserIdRemoved(const UserId& id) {
816 activity_monitor_map_.erase(id); 855 activity_monitor_map_.erase(id);
817 } 856 }
818 857
819 } // namespace ws 858 } // namespace ws
820 } // namespace ui 859 } // namespace ui
OLDNEW
« no previous file with comments | « services/ui/ws/window_server.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698