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

Side by Side Diff: content/renderer/render_widget_view_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 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 unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "content/renderer/render_widget_view_mus.h"
6
7 #include "components/mus/public/interfaces/compositor_frame.mojom.h"
8 #include "components/mus/public/interfaces/window_tree.mojom.h"
9 #include "content/common/render_process_client.mojom.h"
10 #include "content/public/common/mojo_shell_connection.h"
11 #include "mojo/application/public/cpp/application_impl.h"
12 #include "mojo/converters/geometry/geometry_type_converters.h"
13 #include "mojo/converters/surfaces/surfaces_utils.h"
14
15 namespace content {
16
17 RenderWidgetViewMus::RenderWidgetViewMus(int routing_id) {
18 mojom::RenderProcessClientPtr process_client;
19 // TODO(fsamuel): Maybe we should only connect to one of these per render
20 // process?
21 MojoShellConnection::Get()->GetApplication()->ConnectToService(
22 "exe:chrome", &process_client);
23 mus::mojom::WindowTreeClientPtr tree_client;
24 mojo::InterfaceRequest<mus::mojom::WindowTreeClient> request =
25 GetProxy(&tree_client);
26 process_client->OnRenderWidgetViewCreated(routing_id, tree_client.Pass());
27 mus::WindowTreeConnection::Create(
28 this, request.Pass(),
29 mus::WindowTreeConnection::CreateType::DONT_WAIT_FOR_EMBED);
30 }
31
32 RenderWidgetViewMus::~RenderWidgetViewMus() {}
33
34 void RenderWidgetViewMus::OnConnectionLost(
35 mus::WindowTreeConnection* connection) {
36 delete this;
37 }
38
39 void RenderWidgetViewMus::OnEmbed(mus::Window* root) {
40 root->AddObserver(this);
41 surface_ = root->RequestSurface(mus::mojom::SURFACE_TYPE_DEFAULT);
42 surface_->BindToThread();
43
44 const gfx::Rect bounds(root->bounds());
45 mus::mojom::PassPtr pass = mojo::CreateDefaultPass(1, bounds);
46 mus::mojom::CompositorFramePtr frame = mus::mojom::CompositorFrame::New();
47
48 mus::mojom::CompositorFrameMetadataPtr meta =
49 mus::mojom::CompositorFrameMetadata::New();
50 meta->device_scale_factor = 1.0f;
51 frame->metadata = meta.Pass();
52
53 frame->resources.resize(0u);
54
55 pass->quads.resize(0u);
56 pass->shared_quad_states.push_back(mojo::CreateDefaultSQS(bounds.size()));
57
58 mus::mojom::QuadPtr quad = mus::mojom::Quad::New();
59 quad->material = mus::mojom::MATERIAL_SOLID_COLOR;
60 quad->rect = mojo::Rect::From(bounds);
61 quad->opaque_rect = mojo::Rect::New();
62 quad->visible_rect = mojo::Rect::From(bounds);
63 quad->needs_blending = false;
64 quad->shared_quad_state_index = 0u;
65
66 mus::mojom::SolidColorQuadStatePtr color_state =
67 mus::mojom::SolidColorQuadState::New();
68 color_state->color = mus::mojom::Color::New();
69 color_state->color->rgba = 0xff00ff00;
70 color_state->force_anti_aliasing_off = false;
71
72 quad->solid_color_quad_state = color_state.Pass();
73 pass->quads.push_back(quad.Pass());
74 frame->passes.push_back(pass.Pass());
75 surface_->SubmitCompositorFrame(frame.Pass(), mojo::Closure());
76 }
77
78 void RenderWidgetViewMus::OnUnembed() {}
79
80 void RenderWidgetViewMus::OnWindowBoundsChanged(mus::Window* window,
81 const gfx::Rect& old_bounds,
82 const gfx::Rect& new_bounds) {}
83
84 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698