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