OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 "content/renderer/mus/renderer_window_tree_client.h" | 5 #include "content/renderer/mus/renderer_window_tree_client.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 void RendererWindowTreeClient::Bind( | 46 void RendererWindowTreeClient::Bind( |
47 ui::mojom::WindowTreeClientRequest request) { | 47 ui::mojom::WindowTreeClientRequest request) { |
48 binding_.Bind(std::move(request)); | 48 binding_.Bind(std::move(request)); |
49 } | 49 } |
50 | 50 |
51 void RendererWindowTreeClient::RequestCompositorFrameSink( | 51 void RendererWindowTreeClient::RequestCompositorFrameSink( |
52 scoped_refptr<cc::ContextProvider> context_provider, | 52 scoped_refptr<cc::ContextProvider> context_provider, |
53 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, | 53 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, |
54 const CompositorFrameSinkCallback& callback) { | 54 const CompositorFrameSinkCallback& callback) { |
55 DCHECK(pending_compositor_frame_sink_callback_.is_null()); | 55 DCHECK(pending_compositor_frame_sink_callback_.is_null()); |
56 if (frame_sink_id_.is_valid()) { | 56 if (tree_) { |
57 RequestCompositorFrameSinkInternal(std::move(context_provider), | 57 RequestCompositorFrameSinkInternal(std::move(context_provider), |
58 gpu_memory_buffer_manager, callback); | 58 gpu_memory_buffer_manager, callback); |
59 return; | 59 return; |
60 } | 60 } |
61 | 61 |
62 pending_context_provider_ = std::move(context_provider); | 62 pending_context_provider_ = std::move(context_provider); |
63 pending_gpu_memory_buffer_manager_ = gpu_memory_buffer_manager; | 63 pending_gpu_memory_buffer_manager_ = gpu_memory_buffer_manager; |
64 pending_compositor_frame_sink_callback_ = callback; | 64 pending_compositor_frame_sink_callback_ = callback; |
65 } | 65 } |
66 | 66 |
67 RendererWindowTreeClient::RendererWindowTreeClient(int routing_id) | 67 RendererWindowTreeClient::RendererWindowTreeClient(int routing_id) |
68 : routing_id_(routing_id), binding_(this) { | 68 : routing_id_(routing_id), binding_(this) { |
69 } | 69 } |
70 | 70 |
71 RendererWindowTreeClient::~RendererWindowTreeClient() { | 71 RendererWindowTreeClient::~RendererWindowTreeClient() { |
72 g_connections.Get().erase(routing_id_); | 72 g_connections.Get().erase(routing_id_); |
73 } | 73 } |
74 | 74 |
75 void RendererWindowTreeClient::RequestCompositorFrameSinkInternal( | 75 void RendererWindowTreeClient::RequestCompositorFrameSinkInternal( |
76 scoped_refptr<cc::ContextProvider> context_provider, | 76 scoped_refptr<cc::ContextProvider> context_provider, |
77 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, | 77 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, |
78 const CompositorFrameSinkCallback& callback) { | 78 const CompositorFrameSinkCallback& callback) { |
79 std::unique_ptr<ui::ClientCompositorFrameSinkBinding> frame_sink_binding; | 79 std::unique_ptr<ui::ClientCompositorFrameSinkBinding> frame_sink_binding; |
| 80 bool enable_surface_synchronization = |
| 81 base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 82 cc::switches::kEnableSurfaceSynchronization); |
80 auto frame_sink = ui::ClientCompositorFrameSink::Create( | 83 auto frame_sink = ui::ClientCompositorFrameSink::Create( |
81 frame_sink_id_, std::move(context_provider), gpu_memory_buffer_manager, | 84 std::move(context_provider), gpu_memory_buffer_manager, |
82 &frame_sink_binding); | 85 &frame_sink_binding, enable_surface_synchronization); |
83 tree_->AttachCompositorFrameSink( | 86 tree_->AttachCompositorFrameSink( |
84 root_window_id_, frame_sink_binding->TakeFrameSinkRequest(), | 87 root_window_id_, frame_sink_binding->TakeFrameSinkRequest(), |
85 mojo::MakeProxy(frame_sink_binding->TakeFrameSinkClient())); | 88 mojo::MakeProxy(frame_sink_binding->TakeFrameSinkClient())); |
86 callback.Run(std::move(frame_sink)); | 89 callback.Run(std::move(frame_sink)); |
87 } | 90 } |
88 | 91 |
89 void RendererWindowTreeClient::DestroySelf() { | 92 void RendererWindowTreeClient::DestroySelf() { |
90 delete this; | 93 delete this; |
91 } | 94 } |
92 | 95 |
93 void RendererWindowTreeClient::OnEmbed( | 96 void RendererWindowTreeClient::OnEmbed( |
94 ui::ClientSpecificId client_id, | 97 ui::ClientSpecificId client_id, |
95 ui::mojom::WindowDataPtr root, | 98 ui::mojom::WindowDataPtr root, |
96 ui::mojom::WindowTreePtr tree, | 99 ui::mojom::WindowTreePtr tree, |
97 int64_t display_id, | 100 int64_t display_id, |
98 ui::Id focused_window_id, | 101 ui::Id focused_window_id, |
99 bool drawn, | 102 bool drawn, |
100 const cc::FrameSinkId& frame_sink_id, | |
101 const base::Optional<cc::LocalSurfaceId>& local_surface_id) { | 103 const base::Optional<cc::LocalSurfaceId>& local_surface_id) { |
102 frame_sink_id_ = frame_sink_id; | |
103 root_window_id_ = root->window_id; | 104 root_window_id_ = root->window_id; |
104 tree_ = std::move(tree); | 105 tree_ = std::move(tree); |
105 if (!pending_compositor_frame_sink_callback_.is_null()) { | 106 if (!pending_compositor_frame_sink_callback_.is_null()) { |
106 RequestCompositorFrameSinkInternal(std::move(pending_context_provider_), | 107 RequestCompositorFrameSinkInternal(std::move(pending_context_provider_), |
107 pending_gpu_memory_buffer_manager_, | 108 pending_gpu_memory_buffer_manager_, |
108 pending_compositor_frame_sink_callback_); | 109 pending_compositor_frame_sink_callback_); |
109 pending_context_provider_ = nullptr; | 110 pending_context_provider_ = nullptr; |
110 pending_gpu_memory_buffer_manager_ = nullptr; | 111 pending_gpu_memory_buffer_manager_ = nullptr; |
111 pending_compositor_frame_sink_callback_.Reset(); | 112 pending_compositor_frame_sink_callback_.Reset(); |
112 } | 113 } |
(...skipping 16 matching lines...) Expand all Loading... |
129 const cc::FrameSinkId& frame_sink_id) { | 130 const cc::FrameSinkId& frame_sink_id) { |
130 // TODO(fsamuel): OOPIF's |frame_sink_id| is ready. The OOPIF can now be | 131 // TODO(fsamuel): OOPIF's |frame_sink_id| is ready. The OOPIF can now be |
131 // embedded by the parent. | 132 // embedded by the parent. |
132 } | 133 } |
133 | 134 |
134 void RendererWindowTreeClient::OnTopLevelCreated( | 135 void RendererWindowTreeClient::OnTopLevelCreated( |
135 uint32_t change_id, | 136 uint32_t change_id, |
136 ui::mojom::WindowDataPtr data, | 137 ui::mojom::WindowDataPtr data, |
137 int64_t display_id, | 138 int64_t display_id, |
138 bool drawn, | 139 bool drawn, |
139 const cc::FrameSinkId& frame_sink_id, | |
140 const base::Optional<cc::LocalSurfaceId>& local_surface_id) { | 140 const base::Optional<cc::LocalSurfaceId>& local_surface_id) { |
141 NOTREACHED(); | 141 NOTREACHED(); |
142 } | 142 } |
143 | 143 |
144 void RendererWindowTreeClient::OnWindowBoundsChanged( | 144 void RendererWindowTreeClient::OnWindowBoundsChanged( |
145 ui::Id window_id, | 145 ui::Id window_id, |
146 const gfx::Rect& old_bounds, | 146 const gfx::Rect& old_bounds, |
147 const gfx::Rect& new_bounds, | 147 const gfx::Rect& new_bounds, |
148 const base::Optional<cc::LocalSurfaceId>& local_surface_id) { | 148 const base::Optional<cc::LocalSurfaceId>& local_surface_id) { |
149 } | 149 } |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 bool success) {} | 257 bool success) {} |
258 | 258 |
259 void RendererWindowTreeClient::RequestClose(uint32_t window_id) {} | 259 void RendererWindowTreeClient::RequestClose(uint32_t window_id) {} |
260 | 260 |
261 void RendererWindowTreeClient::GetWindowManager( | 261 void RendererWindowTreeClient::GetWindowManager( |
262 mojo::AssociatedInterfaceRequest<ui::mojom::WindowManager> internal) { | 262 mojo::AssociatedInterfaceRequest<ui::mojom::WindowManager> internal) { |
263 NOTREACHED(); | 263 NOTREACHED(); |
264 } | 264 } |
265 | 265 |
266 } // namespace content | 266 } // namespace content |
OLD | NEW |