| 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 "components/mus/public/cpp/context_provider.h" | 11 #include "components/mus/public/cpp/context_provider.h" |
| 12 #include "components/mus/public/cpp/output_surface.h" | 12 #include "components/mus/public/cpp/output_surface.h" |
| 13 #include "components/mus/public/interfaces/command_buffer.mojom.h" | 13 #include "components/mus/public/interfaces/command_buffer.mojom.h" |
| 14 #include "components/mus/public/interfaces/compositor_frame.mojom.h" | 14 #include "components/mus/public/interfaces/compositor_frame.mojom.h" |
| 15 #include "components/mus/public/interfaces/gpu.mojom.h" | 15 #include "components/mus/public/interfaces/gpu.mojom.h" |
| 16 #include "components/mus/public/interfaces/window_tree.mojom.h" | 16 #include "components/mus/public/interfaces/window_tree.mojom.h" |
| 17 #include "content/public/common/mojo_shell_connection.h" | 17 #include "content/public/common/mojo_shell_connection.h" |
| 18 #include "content/renderer/mus/compositor_mus_connection.h" | 18 #include "content/renderer/mus/compositor_mus_connection.h" |
| 19 #include "content/renderer/render_thread_impl.h" | 19 #include "content/renderer/render_thread_impl.h" |
| 20 #include "content/renderer/render_view_impl.h" | 20 #include "content/renderer/render_view_impl.h" |
| 21 #include "mojo/converters/geometry/geometry_type_converters.h" | 21 #include "mojo/converters/geometry/geometry_type_converters.h" |
| 22 #include "mojo/converters/surfaces/surfaces_utils.h" | 22 #include "mojo/converters/surfaces/surfaces_utils.h" |
| 23 #include "mojo/shell/public/cpp/shell.h" | 23 #include "mojo/shell/public/cpp/connector.h" |
| 24 | 24 |
| 25 namespace content { | 25 namespace content { |
| 26 | 26 |
| 27 namespace { | 27 namespace { |
| 28 | 28 |
| 29 typedef std::map<int, RenderWidgetMusConnection*> ConnectionMap; | 29 typedef std::map<int, RenderWidgetMusConnection*> ConnectionMap; |
| 30 base::LazyInstance<ConnectionMap>::Leaky g_connections = | 30 base::LazyInstance<ConnectionMap>::Leaky g_connections = |
| 31 LAZY_INSTANCE_INITIALIZER; | 31 LAZY_INSTANCE_INITIALIZER; |
| 32 } | 32 } |
| 33 | 33 |
| 34 void RenderWidgetMusConnection::Bind( | 34 void RenderWidgetMusConnection::Bind( |
| 35 mojo::InterfaceRequest<mus::mojom::WindowTreeClient> request) { | 35 mojo::InterfaceRequest<mus::mojom::WindowTreeClient> request) { |
| 36 DCHECK(thread_checker_.CalledOnValidThread()); | 36 DCHECK(thread_checker_.CalledOnValidThread()); |
| 37 RenderThreadImpl* render_thread = RenderThreadImpl::current(); | 37 RenderThreadImpl* render_thread = RenderThreadImpl::current(); |
| 38 compositor_mus_connection_ = new CompositorMusConnection( | 38 compositor_mus_connection_ = new CompositorMusConnection( |
| 39 routing_id_, render_thread->GetCompositorMainThreadTaskRunner(), | 39 routing_id_, render_thread->GetCompositorMainThreadTaskRunner(), |
| 40 render_thread->compositor_task_runner(), std::move(request), | 40 render_thread->compositor_task_runner(), std::move(request), |
| 41 render_thread->input_handler_manager()); | 41 render_thread->input_handler_manager()); |
| 42 if (window_surface_binding_) { | 42 if (window_surface_binding_) { |
| 43 compositor_mus_connection_->AttachSurfaceOnMainThread( | 43 compositor_mus_connection_->AttachSurfaceOnMainThread( |
| 44 std::move(window_surface_binding_)); | 44 std::move(window_surface_binding_)); |
| 45 } | 45 } |
| 46 } | 46 } |
| 47 | 47 |
| 48 scoped_ptr<cc::OutputSurface> RenderWidgetMusConnection::CreateOutputSurface() { | 48 scoped_ptr<cc::OutputSurface> RenderWidgetMusConnection::CreateOutputSurface() { |
| 49 DCHECK(thread_checker_.CalledOnValidThread()); | 49 DCHECK(thread_checker_.CalledOnValidThread()); |
| 50 DCHECK(!window_surface_binding_); | 50 DCHECK(!window_surface_binding_); |
| 51 mus::mojom::GpuPtr gpu_service; | 51 mus::mojom::GpuPtr gpu_service; |
| 52 MojoShellConnection::Get()->GetShell()->ConnectToInterface("mojo:mus", | 52 MojoShellConnection::Get()->GetConnector()->ConnectToInterface("mojo:mus", |
| 53 &gpu_service); | 53 &gpu_service); |
| 54 mus::mojom::CommandBufferPtr cb; | 54 mus::mojom::CommandBufferPtr cb; |
| 55 gpu_service->CreateOffscreenGLES2Context(GetProxy(&cb)); | 55 gpu_service->CreateOffscreenGLES2Context(GetProxy(&cb)); |
| 56 scoped_refptr<cc::ContextProvider> context_provider( | 56 scoped_refptr<cc::ContextProvider> context_provider( |
| 57 new mus::ContextProvider(cb.PassInterface().PassHandle())); | 57 new mus::ContextProvider(cb.PassInterface().PassHandle())); |
| 58 scoped_ptr<cc::OutputSurface> surface(new mus::OutputSurface( | 58 scoped_ptr<cc::OutputSurface> surface(new mus::OutputSurface( |
| 59 context_provider, mus::WindowSurface::Create(&window_surface_binding_))); | 59 context_provider, mus::WindowSurface::Create(&window_surface_binding_))); |
| 60 if (compositor_mus_connection_) { | 60 if (compositor_mus_connection_) { |
| 61 compositor_mus_connection_->AttachSurfaceOnMainThread( | 61 compositor_mus_connection_->AttachSurfaceOnMainThread( |
| 62 std::move(window_surface_binding_)); | 62 std::move(window_surface_binding_)); |
| 63 } | 63 } |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 // previous event. | 174 // previous event. |
| 175 // DCHECK(pending_ack_.is_null()); | 175 // DCHECK(pending_ack_.is_null()); |
| 176 pending_ack_ = ack; | 176 pending_ack_ = ack; |
| 177 // TODO(fsamuel, sadrul): Track real latency info. | 177 // TODO(fsamuel, sadrul): Track real latency info. |
| 178 ui::LatencyInfo latency_info; | 178 ui::LatencyInfo latency_info; |
| 179 input_handler_->HandleInputEvent(*input_event, latency_info, | 179 input_handler_->HandleInputEvent(*input_event, latency_info, |
| 180 DISPATCH_TYPE_NORMAL); | 180 DISPATCH_TYPE_NORMAL); |
| 181 } | 181 } |
| 182 | 182 |
| 183 } // namespace content | 183 } // namespace content |
| OLD | NEW |