OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/render_widget_mus_connection.h" | 5 #include "content/renderer/mus/render_widget_mus_connection.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 | 8 |
9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "content/renderer/mus/compositor_mus_connection.h" | 11 #include "content/renderer/mus/compositor_mus_connection.h" |
12 #include "content/renderer/render_thread_impl.h" | 12 #include "content/renderer/render_thread_impl.h" |
13 #include "content/renderer/render_view_impl.h" | 13 #include "content/renderer/render_view_impl.h" |
14 #include "services/ui/public/cpp/context_provider.h" | |
15 #include "services/ui/public/cpp/window_compositor_frame_sink.h" | 14 #include "services/ui/public/cpp/window_compositor_frame_sink.h" |
16 #include "services/ui/public/interfaces/window_tree.mojom.h" | 15 #include "services/ui/public/interfaces/window_tree.mojom.h" |
17 | 16 |
18 namespace content { | 17 namespace content { |
19 | 18 |
20 namespace { | 19 namespace { |
21 | 20 |
22 typedef std::map<int, RenderWidgetMusConnection*> ConnectionMap; | 21 typedef std::map<int, RenderWidgetMusConnection*> ConnectionMap; |
23 base::LazyInstance<ConnectionMap>::Leaky g_connections = | 22 base::LazyInstance<ConnectionMap>::Leaky g_connections = |
24 LAZY_INSTANCE_INITIALIZER; | 23 LAZY_INSTANCE_INITIALIZER; |
25 } | 24 } |
26 | 25 |
27 void RenderWidgetMusConnection::Bind( | 26 void RenderWidgetMusConnection::Bind( |
28 mojo::InterfaceRequest<ui::mojom::WindowTreeClient> request) { | 27 mojo::InterfaceRequest<ui::mojom::WindowTreeClient> request) { |
29 DCHECK(thread_checker_.CalledOnValidThread()); | 28 DCHECK(thread_checker_.CalledOnValidThread()); |
30 RenderThreadImpl* render_thread = RenderThreadImpl::current(); | 29 RenderThreadImpl* render_thread = RenderThreadImpl::current(); |
31 compositor_mus_connection_ = new CompositorMusConnection( | 30 compositor_mus_connection_ = new CompositorMusConnection( |
32 routing_id_, render_thread->GetCompositorMainThreadTaskRunner(), | 31 routing_id_, render_thread->GetCompositorMainThreadTaskRunner(), |
33 render_thread->compositor_task_runner(), std::move(request), | 32 render_thread->compositor_task_runner(), std::move(request), |
34 render_thread->input_handler_manager()); | 33 render_thread->input_handler_manager()); |
35 if (window_compositor_frame_sink_binding_) { | 34 if (window_compositor_frame_sink_binding_) { |
36 compositor_mus_connection_->AttachCompositorFrameSinkOnMainThread( | 35 compositor_mus_connection_->AttachCompositorFrameSinkOnMainThread( |
37 std::move(window_compositor_frame_sink_binding_)); | 36 std::move(window_compositor_frame_sink_binding_)); |
38 } | 37 } |
39 } | 38 } |
40 | 39 |
41 std::unique_ptr<cc::CompositorFrameSink> | 40 std::unique_ptr<cc::CompositorFrameSink> |
42 RenderWidgetMusConnection::CreateCompositorFrameSink( | 41 RenderWidgetMusConnection::CreateCompositorFrameSink( |
43 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host, | 42 scoped_refptr<cc::ContextProvider> context_provider, |
44 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager) { | 43 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager) { |
45 DCHECK(thread_checker_.CalledOnValidThread()); | 44 DCHECK(thread_checker_.CalledOnValidThread()); |
46 DCHECK(!window_compositor_frame_sink_binding_); | 45 DCHECK(!window_compositor_frame_sink_binding_); |
47 | 46 |
48 std::unique_ptr<cc::CompositorFrameSink> compositor_frame_sink( | 47 std::unique_ptr<cc::CompositorFrameSink> compositor_frame_sink( |
49 ui::WindowCompositorFrameSink::Create( | 48 ui::WindowCompositorFrameSink::Create( |
50 make_scoped_refptr( | 49 std::move(context_provider), gpu_memory_buffer_manager, |
51 new ui::ContextProvider(std::move(gpu_channel_host))), | 50 &window_compositor_frame_sink_binding_)); |
52 gpu_memory_buffer_manager, &window_compositor_frame_sink_binding_)); | |
53 if (compositor_mus_connection_) { | 51 if (compositor_mus_connection_) { |
54 compositor_mus_connection_->AttachCompositorFrameSinkOnMainThread( | 52 compositor_mus_connection_->AttachCompositorFrameSinkOnMainThread( |
55 std::move(window_compositor_frame_sink_binding_)); | 53 std::move(window_compositor_frame_sink_binding_)); |
56 } | 54 } |
57 return compositor_frame_sink; | 55 return compositor_frame_sink; |
58 } | 56 } |
59 | 57 |
60 // static | 58 // static |
61 RenderWidgetMusConnection* RenderWidgetMusConnection::Get(int routing_id) { | 59 RenderWidgetMusConnection* RenderWidgetMusConnection::Get(int routing_id) { |
62 auto it = g_connections.Get().find(routing_id); | 60 auto it = g_connections.Get().find(routing_id); |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 // previous event. | 168 // previous event. |
171 // DCHECK(pending_ack_.is_null()); | 169 // DCHECK(pending_ack_.is_null()); |
172 pending_ack_ = ack; | 170 pending_ack_ = ack; |
173 // TODO(fsamuel, sadrul): Track real latency info. | 171 // TODO(fsamuel, sadrul): Track real latency info. |
174 ui::LatencyInfo latency_info; | 172 ui::LatencyInfo latency_info; |
175 input_handler_->HandleInputEvent(*input_event, latency_info, | 173 input_handler_->HandleInputEvent(*input_event, latency_info, |
176 DISPATCH_TYPE_BLOCKING); | 174 DISPATCH_TYPE_BLOCKING); |
177 } | 175 } |
178 | 176 |
179 } // namespace content | 177 } // namespace content |
OLD | NEW |