Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(399)

Unified Diff: content/renderer/render_widget_mus.cc

Issue 1461243002: [OLD ATTEMPT, DO NOT REVIEW] mustash: Enable connections to mus from the Chrome renderer Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed Ben's comments Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/renderer/render_widget_mus.h ('k') | ui/views/mus/native_widget_mus.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/render_widget_mus.cc
diff --git a/content/renderer/render_widget_mus.cc b/content/renderer/render_widget_mus.cc
new file mode 100644
index 0000000000000000000000000000000000000000..fd865d9708dbfd9f04b4f7bb8ffdb35b07b22553
--- /dev/null
+++ b/content/renderer/render_widget_mus.cc
@@ -0,0 +1,83 @@
+// 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_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 {
+
+RenderWidgetMus::RenderWidgetMus(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);
+}
+
+RenderWidgetMus::~RenderWidgetMus() {}
+
+void RenderWidgetMus::OnConnectionLost(mus::WindowTreeConnection* connection) {
+ delete this;
+}
+
+void RenderWidgetMus::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 RenderWidgetMus::OnUnembed() {}
+
+void RenderWidgetMus::OnWindowBoundsChanged(mus::Window* window,
+ const gfx::Rect& old_bounds,
+ const gfx::Rect& new_bounds) {}
+
+} // namespace content
« no previous file with comments | « content/renderer/render_widget_mus.h ('k') | ui/views/mus/native_widget_mus.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698