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

Side by Side Diff: content/renderer/render_widget_mus_connection.cc

Issue 1476643002: mustash: Enable connections to mus from the Chrome renderer [take 2] (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Don't create a RenderWidgetWindowTreeeClientFactory in tests 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_mus_connection.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/public/common/mojo_shell_connection.h"
10 #include "mojo/application/public/cpp/application_impl.h"
11 #include "mojo/converters/geometry/geometry_type_converters.h"
12 #include "mojo/converters/surfaces/surfaces_utils.h"
13
14 namespace content {
15
16 RenderWidgetMusConnection::RenderWidgetMusConnection(
17 int routing_id,
18 mojo::InterfaceRequest<mus::mojom::WindowTreeClient> request)
19 : routing_id_(routing_id), root_(nullptr) {
20 // TODO(fsamuel): We should probably introduce a
21 // RenderWidgetMusConnection::FromRoutingID that's usable from RenderWidget.
22 // TODO(fsamuel): We probably want to pause processing of incoming
23 // messages until we have an associated RenderWidget.
24 mus::WindowTreeConnection::Create(
25 this, request.Pass(),
26 mus::WindowTreeConnection::CreateType::DONT_WAIT_FOR_EMBED);
27 }
28
29 RenderWidgetMusConnection::~RenderWidgetMusConnection() {}
30
31 void RenderWidgetMusConnection::SubmitCompositorFrame() {
32 const gfx::Rect bounds(root_->bounds());
33 mus::mojom::PassPtr pass = mojo::CreateDefaultPass(1, bounds);
34 mus::mojom::CompositorFramePtr frame = mus::mojom::CompositorFrame::New();
35
36 mus::mojom::CompositorFrameMetadataPtr meta =
37 mus::mojom::CompositorFrameMetadata::New();
38 meta->device_scale_factor = 1.0f;
39 frame->metadata = meta.Pass();
40
41 frame->resources.resize(0u);
42
43 pass->quads.resize(0u);
44 pass->shared_quad_states.push_back(mojo::CreateDefaultSQS(bounds.size()));
45
46 mus::mojom::QuadPtr quad = mus::mojom::Quad::New();
47 quad->material = mus::mojom::MATERIAL_SOLID_COLOR;
48 quad->rect = mojo::Rect::From(bounds);
49 quad->opaque_rect = mojo::Rect::New();
50 quad->visible_rect = mojo::Rect::From(bounds);
51 quad->needs_blending = false;
52 quad->shared_quad_state_index = 0u;
53
54 mus::mojom::SolidColorQuadStatePtr color_state =
55 mus::mojom::SolidColorQuadState::New();
56 color_state->color = mus::mojom::Color::New();
57 color_state->color->rgba = 0xff00ff00;
58 color_state->force_anti_aliasing_off = false;
59
60 quad->solid_color_quad_state = color_state.Pass();
61 pass->quads.push_back(quad.Pass());
62 frame->passes.push_back(pass.Pass());
63 surface_->SubmitCompositorFrame(frame.Pass(), mojo::Closure());
64 }
65
66 void RenderWidgetMusConnection::OnConnectionLost(
67 mus::WindowTreeConnection* connection) {
68 delete this;
69 }
70
71 void RenderWidgetMusConnection::OnEmbed(mus::Window* root) {
72 root_ = root;
73 root_->AddObserver(this);
74 surface_ = root_->RequestSurface(mus::mojom::SURFACE_TYPE_DEFAULT);
75 surface_->BindToThread();
76 SubmitCompositorFrame();
77 }
78
79 void RenderWidgetMusConnection::OnUnembed() {}
80
81 void RenderWidgetMusConnection::OnWindowBoundsChanged(
82 mus::Window* window,
83 const gfx::Rect& old_bounds,
84 const gfx::Rect& new_bounds) {
85 SubmitCompositorFrame();
86 }
87
88 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698