Index: content/renderer/render_widget_view_mus.cc |
diff --git a/content/renderer/render_widget_view_mus.cc b/content/renderer/render_widget_view_mus.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..8fa7f9d1e9190eb187879b4c9b1e283af9abda71 |
--- /dev/null |
+++ b/content/renderer/render_widget_view_mus.cc |
@@ -0,0 +1,84 @@ |
+// Copyright 2015 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "content/renderer/render_widget_view_mus.h" |
+ |
+#include "components/mus/public/interfaces/compositor_frame.mojom.h" |
+#include "components/mus/public/interfaces/window_tree.mojom.h" |
+#include "content/common/render_process_client.mojom.h" |
+#include "content/public/common/mojo_shell_connection.h" |
+#include "mojo/application/public/cpp/application_impl.h" |
+#include "mojo/converters/geometry/geometry_type_converters.h" |
+#include "mojo/converters/surfaces/surfaces_utils.h" |
+ |
+namespace content { |
+ |
+RenderWidgetViewMus::RenderWidgetViewMus(int routing_id) { |
+ mojom::RenderProcessClientPtr process_client; |
+ // TODO(fsamuel): Maybe we should only connect to one of these per render |
+ // process? |
+ MojoShellConnection::Get()->GetApplication()->ConnectToService( |
+ "exe:chrome", &process_client); |
+ mus::mojom::WindowTreeClientPtr tree_client; |
+ mojo::InterfaceRequest<mus::mojom::WindowTreeClient> request = |
+ GetProxy(&tree_client); |
+ process_client->OnRenderWidgetViewCreated(routing_id, tree_client.Pass()); |
+ mus::WindowTreeConnection::Create( |
+ this, request.Pass(), |
+ mus::WindowTreeConnection::CreateType::DONT_WAIT_FOR_EMBED); |
+} |
+ |
+RenderWidgetViewMus::~RenderWidgetViewMus() {} |
+ |
+void RenderWidgetViewMus::OnConnectionLost( |
+ mus::WindowTreeConnection* connection) { |
+ delete this; |
+} |
+ |
+void RenderWidgetViewMus::OnEmbed(mus::Window* root) { |
+ root->AddObserver(this); |
+ surface_ = root->RequestSurface(mus::mojom::SURFACE_TYPE_DEFAULT); |
+ surface_->BindToThread(); |
+ |
+ const gfx::Rect bounds(root->bounds()); |
+ mus::mojom::PassPtr pass = mojo::CreateDefaultPass(1, bounds); |
+ mus::mojom::CompositorFramePtr frame = mus::mojom::CompositorFrame::New(); |
+ |
+ mus::mojom::CompositorFrameMetadataPtr meta = |
+ mus::mojom::CompositorFrameMetadata::New(); |
+ meta->device_scale_factor = 1.0f; |
+ frame->metadata = meta.Pass(); |
+ |
+ frame->resources.resize(0u); |
+ |
+ pass->quads.resize(0u); |
+ pass->shared_quad_states.push_back(mojo::CreateDefaultSQS(bounds.size())); |
+ |
+ mus::mojom::QuadPtr quad = mus::mojom::Quad::New(); |
+ quad->material = mus::mojom::MATERIAL_SOLID_COLOR; |
+ quad->rect = mojo::Rect::From(bounds); |
+ quad->opaque_rect = mojo::Rect::New(); |
+ quad->visible_rect = mojo::Rect::From(bounds); |
+ quad->needs_blending = false; |
+ quad->shared_quad_state_index = 0u; |
+ |
+ mus::mojom::SolidColorQuadStatePtr color_state = |
+ mus::mojom::SolidColorQuadState::New(); |
+ color_state->color = mus::mojom::Color::New(); |
+ color_state->color->rgba = 0xff00ff00; |
+ color_state->force_anti_aliasing_off = false; |
+ |
+ quad->solid_color_quad_state = color_state.Pass(); |
+ pass->quads.push_back(quad.Pass()); |
+ frame->passes.push_back(pass.Pass()); |
+ surface_->SubmitCompositorFrame(frame.Pass(), mojo::Closure()); |
+} |
+ |
+void RenderWidgetViewMus::OnUnembed() {} |
+ |
+void RenderWidgetViewMus::OnWindowBoundsChanged(mus::Window* window, |
+ const gfx::Rect& old_bounds, |
+ const gfx::Rect& new_bounds) {} |
+ |
+} // namespace content |