Chromium Code Reviews| Index: services/ui/ws/window_server.cc |
| diff --git a/services/ui/ws/window_server.cc b/services/ui/ws/window_server.cc |
| index 6ca22491bff3e8bf6f985344f2a000304df293ae..bf6a7f5369d7806f2c8138bd18797aad9c9f4d0f 100644 |
| --- a/services/ui/ws/window_server.cc |
| +++ b/services/ui/ws/window_server.cc |
| @@ -606,6 +606,30 @@ bool WindowServer::IsUserInHighContrastMode(const UserId& user) const { |
| return (iter == high_contrast_mode_.end()) ? false : iter->second; |
| } |
| +ServerWindow* WindowServer::FindCompositorFrameSinkParent( |
|
Fady Samuel
2017/02/24 18:07:38
nit: TODO that we should plumb a bool to ServerWin
kylechar
2017/02/28 18:07:17
Done.
|
| + ServerWindow* window) { |
| + DCHECK(window->parent()); |
| + |
| + WindowTree* window_tree = GetTreeWithId(window->parent()->id().client_id); |
| + if (window_tree) { |
| + // If the parent of |window| is part of a WindowTree, the WindowTree root |
| + // that contains |window| should be backed by a CompositorFrameSink. |
| + for (const ServerWindow* root : window_tree->roots()) { |
| + if (root->Contains(window)) |
| + // TODO(kylechar): There must be a better way to do this. |
| + return const_cast<ServerWindow*>(root); |
| + } |
| + } |
| + |
| + // The parent of |window| might be a display root which isn't part of a |
| + // WindowTree. Display roots will always be backed by a CompositorFrameSink. |
| + Display* display = display_manager_->GetDisplayContaining(window); |
| + if (display && display->root_window() == window->parent()) |
| + return display->root_window(); |
| + |
| + return nullptr; |
| +} |
| + |
| ServerWindow* WindowServer::GetRootWindow(const ServerWindow* window) { |
| Display* display = display_manager_->GetDisplayContaining(window); |
| return display ? display->root_window() : nullptr; |
| @@ -761,8 +785,6 @@ void WindowServer::OnTransientWindowRemoved(ServerWindow* window, |
| } |
| void WindowServer::OnGpuServiceInitialized() { |
| - // TODO(kylechar): When gpu channel is removed, this can instead happen |
| - // earlier, after GpuHost::OnInitialized(). |
| delegate_->StartDisplayInit(); |
| } |
| @@ -771,8 +793,10 @@ void WindowServer::OnSurfaceCreated(const cc::SurfaceInfo& surface_info) { |
| WindowIdFromTransportId(surface_info.id().frame_sink_id().client_id())); |
| ServerWindow* window = GetWindow(window_id); |
| // If the window doesn't have a parent then we have nothing to propagate. |
| - if (!window) |
| + if (!window) { |
| + display_compositor_->DropTemporaryReference(surface_info.id()); |
| return; |
| + } |
| // FrameGenerator will add an appropriate reference for the new surface. |
| DCHECK(display_manager_->GetDisplayContaining(window)); |
| @@ -787,12 +811,24 @@ void WindowServer::OnSurfaceCreated(const cc::SurfaceInfo& surface_info) { |
| if (!window_paint_callback_.is_null()) |
| window_paint_callback_.Run(window); |
| - if (!window->parent()) |
| + if (!window->parent()) { |
| + // If |window| is a display root then a surface reference has already been |
| + // added by the DisplayCompositor. |
| + display_compositor_->DropTemporaryReference(surface_info.id()); |
| return; |
| + } |
| WindowTree* window_tree = GetTreeWithId(window->parent()->id().client_id); |
| if (window_tree) |
| window_tree->ProcessWindowSurfaceChanged(window, surface_info); |
| + |
| + ServerWindow* parent = FindCompositorFrameSinkParent(window); |
|
Fady Samuel
2017/02/24 18:07:38
nit: compositing_parent
kylechar
2017/02/28 18:07:16
Done.
|
| + if (parent) { |
| + auto* frame_sink_manager = parent->GetOrCreateCompositorFrameSinkManager(); |
| + frame_sink_manager->ClaimTemporaryReference(surface_info.id()); |
|
Fady Samuel
2017/02/24 18:07:38
Add a comment here about what this is doing.
kylechar
2017/02/28 18:07:15
Done.
|
| + } else { |
| + display_compositor_->DropTemporaryReference(surface_info.id()); |
| + } |
| } |
| void WindowServer::OnActiveUserIdChanged(const UserId& previously_active_id, |