| Index: content/renderer/render_widget_mus_connection.cc
|
| diff --git a/content/renderer/render_widget_mus_connection.cc b/content/renderer/render_widget_mus_connection.cc
|
| index e0e81a565ce3eb7ca3d19cd69846872d36f11647..479eebc94a9a1fa6163a3d3d9f8dc6df758dbe92 100644
|
| --- a/content/renderer/render_widget_mus_connection.cc
|
| +++ b/content/renderer/render_widget_mus_connection.cc
|
| @@ -7,6 +7,7 @@
|
| #include <map>
|
|
|
| #include "base/lazy_instance.h"
|
| +#include "base/macros.h"
|
| #include "components/mus/public/cpp/context_provider.h"
|
| #include "components/mus/public/cpp/output_surface.h"
|
| #include "components/mus/public/interfaces/command_buffer.mojom.h"
|
| @@ -14,6 +15,9 @@
|
| #include "components/mus/public/interfaces/gpu.mojom.h"
|
| #include "components/mus/public/interfaces/window_tree.mojom.h"
|
| #include "content/public/common/mojo_shell_connection.h"
|
| +#include "content/renderer/compositor_mus_connection.h"
|
| +#include "content/renderer/render_thread_impl.h"
|
| +#include "content/renderer/render_view_impl.h"
|
| #include "mojo/application/public/cpp/application_impl.h"
|
| #include "mojo/converters/geometry/geometry_type_converters.h"
|
| #include "mojo/converters/surfaces/surfaces_utils.h"
|
| @@ -27,22 +31,22 @@ base::LazyInstance<ConnectionMap>::Leaky g_connections =
|
| LAZY_INSTANCE_INITIALIZER;
|
| }
|
|
|
| -RenderWidgetMusConnection::RenderWidgetMusConnection(int routing_id)
|
| - : routing_id_(routing_id), root_(nullptr) {
|
| - DCHECK(routing_id);
|
| -}
|
| -
|
| -RenderWidgetMusConnection::~RenderWidgetMusConnection() {}
|
| -
|
| void RenderWidgetMusConnection::Bind(
|
| mojo::InterfaceRequest<mus::mojom::WindowTreeClient> request) {
|
| - DCHECK(!root_);
|
| - mus::WindowTreeConnection::Create(
|
| - this, request.Pass(),
|
| - mus::WindowTreeConnection::CreateType::DONT_WAIT_FOR_EMBED);
|
| + DCHECK(thread_checker_.CalledOnValidThread());
|
| + RenderThreadImpl* render_thread = RenderThreadImpl::current();
|
| + compositor_mus_connection_ = new CompositorMusConnection(
|
| + routing_id_, render_thread->GetCompositorMainThreadTaskRunner(),
|
| + render_thread->compositor_task_runner(), request.Pass(),
|
| + render_thread->input_handler_manager());
|
| + if (window_surface_binding_) {
|
| + compositor_mus_connection_->AttachSurfaceOnMainThread(
|
| + window_surface_binding_.Pass());
|
| + }
|
| }
|
|
|
| scoped_ptr<cc::OutputSurface> RenderWidgetMusConnection::CreateOutputSurface() {
|
| + DCHECK(thread_checker_.CalledOnValidThread());
|
| DCHECK(!window_surface_binding_);
|
| mus::mojom::GpuPtr gpu_service;
|
| MojoShellConnection::Get()->GetApplication()->ConnectToService("mojo:mus",
|
| @@ -51,49 +55,57 @@ scoped_ptr<cc::OutputSurface> RenderWidgetMusConnection::CreateOutputSurface() {
|
| gpu_service->CreateOffscreenGLES2Context(GetProxy(&cb));
|
| scoped_refptr<cc::ContextProvider> context_provider(
|
| new mus::ContextProvider(cb.PassInterface().PassHandle()));
|
| - scoped_ptr<cc::OutputSurface> output_surface(new mus::OutputSurface(
|
| + scoped_ptr<cc::OutputSurface> surface(new mus::OutputSurface(
|
| context_provider, mus::WindowSurface::Create(&window_surface_binding_)));
|
| - if (root_) {
|
| - root_->AttachSurface(mus::mojom::SURFACE_TYPE_DEFAULT,
|
| - window_surface_binding_.Pass());
|
| + if (compositor_mus_connection_) {
|
| + compositor_mus_connection_->AttachSurfaceOnMainThread(
|
| + window_surface_binding_.Pass());
|
| }
|
| - return output_surface.Pass();
|
| + return surface;
|
| }
|
|
|
| // static
|
| -RenderWidgetMusConnection* RenderWidgetMusConnection::GetOrCreate(
|
| - int routing_id) {
|
| +RenderWidgetMusConnection* RenderWidgetMusConnection::Get(int routing_id) {
|
| auto it = g_connections.Get().find(routing_id);
|
| if (it != g_connections.Get().end())
|
| return it->second;
|
| + return nullptr;
|
| +}
|
|
|
| - RenderWidgetMusConnection* connection =
|
| - new RenderWidgetMusConnection(routing_id);
|
| - g_connections.Get().insert(std::make_pair(routing_id, connection));
|
| +// static
|
| +RenderWidgetMusConnection* RenderWidgetMusConnection::GetOrCreate(
|
| + int routing_id) {
|
| + RenderWidgetMusConnection* connection = Get(routing_id);
|
| + if (!connection) {
|
| + connection = new RenderWidgetMusConnection(routing_id);
|
| + g_connections.Get().insert(std::make_pair(routing_id, connection));
|
| + }
|
| return connection;
|
| }
|
|
|
| -void RenderWidgetMusConnection::OnConnectionLost(
|
| - mus::WindowTreeConnection* connection) {
|
| - g_connections.Get().erase(routing_id_);
|
| - delete this;
|
| +RenderWidgetMusConnection::RenderWidgetMusConnection(int routing_id)
|
| + : routing_id_(routing_id) {
|
| + DCHECK(routing_id);
|
| }
|
|
|
| -void RenderWidgetMusConnection::OnEmbed(mus::Window* root) {
|
| - root_ = root;
|
| - root_->AddObserver(this);
|
| - if (window_surface_binding_) {
|
| - root->AttachSurface(mus::mojom::SURFACE_TYPE_DEFAULT,
|
| - window_surface_binding_.Pass());
|
| - }
|
| -}
|
| +RenderWidgetMusConnection::~RenderWidgetMusConnection() {}
|
|
|
| -void RenderWidgetMusConnection::OnUnembed() {}
|
| +void RenderWidgetMusConnection::OnConnectionLost() {
|
| + DCHECK(thread_checker_.CalledOnValidThread());
|
| + g_connections.Get().erase(routing_id_);
|
| + delete this;
|
| +}
|
|
|
| -void RenderWidgetMusConnection::OnWindowBoundsChanged(
|
| - mus::Window* window,
|
| - const gfx::Rect& old_bounds,
|
| - const gfx::Rect& new_bounds) {
|
| +void RenderWidgetMusConnection::OnWindowInputEvent(
|
| + scoped_ptr<blink::WebInputEvent> input_event,
|
| + const base::Closure& ack) {
|
| + DCHECK(thread_checker_.CalledOnValidThread());
|
| + // TODO(fsamuel): Implement this once the following is complete:
|
| + // 1. The Mus client lib support manual event ACKing.
|
| + // 2. Mus supports event coalescing.
|
| + // 3. RenderWidget is refactored so that we don't send ACKs to the browser
|
| + // process.
|
| + ack.Run();
|
| }
|
|
|
| } // namespace content
|
|
|