| 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" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 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 std::unique_ptr<cc::OutputSurface> |
| 49 RenderWidgetMusConnection::CreateOutputSurface() { |
| 49 DCHECK(thread_checker_.CalledOnValidThread()); | 50 DCHECK(thread_checker_.CalledOnValidThread()); |
| 50 DCHECK(!window_surface_binding_); | 51 DCHECK(!window_surface_binding_); |
| 51 mus::mojom::GpuPtr gpu_service; | 52 mus::mojom::GpuPtr gpu_service; |
| 52 MojoShellConnection::Get()->GetConnector()->ConnectToInterface("mojo:mus", | 53 MojoShellConnection::Get()->GetConnector()->ConnectToInterface("mojo:mus", |
| 53 &gpu_service); | 54 &gpu_service); |
| 54 mus::mojom::CommandBufferPtr cb; | 55 mus::mojom::CommandBufferPtr cb; |
| 55 gpu_service->CreateOffscreenGLES2Context(GetProxy(&cb)); | 56 gpu_service->CreateOffscreenGLES2Context(GetProxy(&cb)); |
| 56 scoped_refptr<cc::ContextProvider> context_provider( | 57 scoped_refptr<cc::ContextProvider> context_provider( |
| 57 new mus::ContextProvider(cb.PassInterface().PassHandle())); | 58 new mus::ContextProvider(cb.PassInterface().PassHandle())); |
| 58 scoped_ptr<cc::OutputSurface> surface(new mus::OutputSurface( | 59 std::unique_ptr<cc::OutputSurface> surface(new mus::OutputSurface( |
| 59 context_provider, mus::WindowSurface::Create(&window_surface_binding_))); | 60 context_provider, mus::WindowSurface::Create(&window_surface_binding_))); |
| 60 if (compositor_mus_connection_) { | 61 if (compositor_mus_connection_) { |
| 61 compositor_mus_connection_->AttachSurfaceOnMainThread( | 62 compositor_mus_connection_->AttachSurfaceOnMainThread( |
| 62 std::move(window_surface_binding_)); | 63 std::move(window_surface_binding_)); |
| 63 } | 64 } |
| 64 return surface; | 65 return surface; |
| 65 } | 66 } |
| 66 | 67 |
| 67 // static | 68 // static |
| 68 RenderWidgetMusConnection* RenderWidgetMusConnection::Get(int routing_id) { | 69 RenderWidgetMusConnection* RenderWidgetMusConnection::Get(int routing_id) { |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 void RenderWidgetMusConnection::OnDidHandleKeyEvent() { | 117 void RenderWidgetMusConnection::OnDidHandleKeyEvent() { |
| 117 NOTIMPLEMENTED(); | 118 NOTIMPLEMENTED(); |
| 118 } | 119 } |
| 119 | 120 |
| 120 void RenderWidgetMusConnection::OnDidOverscroll( | 121 void RenderWidgetMusConnection::OnDidOverscroll( |
| 121 const DidOverscrollParams& params) { | 122 const DidOverscrollParams& params) { |
| 122 NOTIMPLEMENTED(); | 123 NOTIMPLEMENTED(); |
| 123 } | 124 } |
| 124 | 125 |
| 125 void RenderWidgetMusConnection::OnInputEventAck( | 126 void RenderWidgetMusConnection::OnInputEventAck( |
| 126 scoped_ptr<InputEventAck> input_event_ack) { | 127 std::unique_ptr<InputEventAck> input_event_ack) { |
| 127 DCHECK(!pending_ack_.is_null()); | 128 DCHECK(!pending_ack_.is_null()); |
| 128 pending_ack_.Run(input_event_ack->state == | 129 pending_ack_.Run(input_event_ack->state == |
| 129 InputEventAckState::INPUT_EVENT_ACK_STATE_CONSUMED); | 130 InputEventAckState::INPUT_EVENT_ACK_STATE_CONSUMED); |
| 130 pending_ack_.Reset(); | 131 pending_ack_.Reset(); |
| 131 } | 132 } |
| 132 | 133 |
| 133 void RenderWidgetMusConnection::NotifyInputEventHandled( | 134 void RenderWidgetMusConnection::NotifyInputEventHandled( |
| 134 blink::WebInputEvent::Type handled_type) { | 135 blink::WebInputEvent::Type handled_type) { |
| 135 NOTIMPLEMENTED(); | 136 NOTIMPLEMENTED(); |
| 136 } | 137 } |
| (...skipping 23 matching lines...) Expand all Loading... |
| 160 return false; | 161 return false; |
| 161 } | 162 } |
| 162 | 163 |
| 163 void RenderWidgetMusConnection::OnConnectionLost() { | 164 void RenderWidgetMusConnection::OnConnectionLost() { |
| 164 DCHECK(thread_checker_.CalledOnValidThread()); | 165 DCHECK(thread_checker_.CalledOnValidThread()); |
| 165 g_connections.Get().erase(routing_id_); | 166 g_connections.Get().erase(routing_id_); |
| 166 delete this; | 167 delete this; |
| 167 } | 168 } |
| 168 | 169 |
| 169 void RenderWidgetMusConnection::OnWindowInputEvent( | 170 void RenderWidgetMusConnection::OnWindowInputEvent( |
| 170 scoped_ptr<blink::WebInputEvent> input_event, | 171 std::unique_ptr<blink::WebInputEvent> input_event, |
| 171 const base::Callback<void(bool)>& ack) { | 172 const base::Callback<void(bool)>& ack) { |
| 172 DCHECK(thread_checker_.CalledOnValidThread()); | 173 DCHECK(thread_checker_.CalledOnValidThread()); |
| 173 // If we don't yet have a RenderWidgetInputHandler then we don't yet have | 174 // If we don't yet have a RenderWidgetInputHandler then we don't yet have |
| 174 // an initialized RenderWidget. | 175 // an initialized RenderWidget. |
| 175 if (!input_handler_) { | 176 if (!input_handler_) { |
| 176 ack.Run(false); | 177 ack.Run(false); |
| 177 return; | 178 return; |
| 178 } | 179 } |
| 179 // TODO(fsamuel): It would be nice to add this DCHECK but the reality is an | 180 // TODO(fsamuel): It would be nice to add this DCHECK but the reality is an |
| 180 // event could timeout and we could receive the next event before we ack the | 181 // event could timeout and we could receive the next event before we ack the |
| 181 // previous event. | 182 // previous event. |
| 182 // DCHECK(pending_ack_.is_null()); | 183 // DCHECK(pending_ack_.is_null()); |
| 183 pending_ack_ = ack; | 184 pending_ack_ = ack; |
| 184 // TODO(fsamuel, sadrul): Track real latency info. | 185 // TODO(fsamuel, sadrul): Track real latency info. |
| 185 ui::LatencyInfo latency_info; | 186 ui::LatencyInfo latency_info; |
| 186 input_handler_->HandleInputEvent(*input_event, latency_info, | 187 input_handler_->HandleInputEvent(*input_event, latency_info, |
| 187 DISPATCH_TYPE_BLOCKING); | 188 DISPATCH_TYPE_BLOCKING); |
| 188 } | 189 } |
| 189 | 190 |
| 190 } // namespace content | 191 } // namespace content |
| OLD | NEW |