OLD | NEW |
---|---|
(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_widget_view.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::RenderWidgetViewFactoryPtr factory; | |
19 MojoShellConnection::Get()->GetApplication()->ConnectToService("exe://chrome", | |
Ben Goodger (Google)
2015/11/24 06:42:40
exe:chrome is more conventional
Fady Samuel
2015/11/24 13:32:06
Done.
| |
20 &factory); | |
21 mus::mojom::WindowTreeClientPtr tree_client; | |
22 mojo::InterfaceRequest<mus::mojom::WindowTreeClient> request = | |
23 GetProxy(&tree_client); | |
24 factory->CreateRenderWidgetView(routing_id, tree_client.Pass()); | |
25 mus::WindowTreeConnection::Create( | |
26 this, request.Pass(), | |
27 mus::WindowTreeConnection::CreateType::DONT_WAIT_FOR_EMBED); | |
28 } | |
29 | |
30 RenderWidgetViewMus::~RenderWidgetViewMus() {} | |
31 | |
32 void RenderWidgetViewMus::OnConnectionLost( | |
33 mus::WindowTreeConnection* connection) { | |
34 delete this; | |
35 } | |
36 | |
37 void RenderWidgetViewMus::OnEmbed(mus::Window* root) { | |
38 root->AddObserver(this); | |
39 surface_ = root->RequestSurface(mus::mojom::SURFACE_TYPE_DEFAULT); | |
40 surface_->BindToThread(); | |
41 | |
42 const gfx::Rect bounds(root->bounds()); | |
43 mus::mojom::PassPtr pass = mojo::CreateDefaultPass(1, bounds); | |
44 mus::mojom::CompositorFramePtr frame = mus::mojom::CompositorFrame::New(); | |
45 | |
46 mus::mojom::CompositorFrameMetadataPtr meta = | |
47 mus::mojom::CompositorFrameMetadata::New(); | |
48 meta->device_scale_factor = 1.0f; | |
49 frame->metadata = meta.Pass(); | |
50 | |
51 frame->resources.resize(0u); | |
52 | |
53 pass->quads.resize(0u); | |
54 pass->shared_quad_states.push_back(mojo::CreateDefaultSQS(bounds.size())); | |
55 | |
56 mus::mojom::QuadPtr quad = mus::mojom::Quad::New(); | |
57 quad->material = mus::mojom::MATERIAL_SOLID_COLOR; | |
58 quad->rect = mojo::Rect::From(bounds); | |
59 quad->opaque_rect = mojo::Rect::New(); | |
60 quad->visible_rect = mojo::Rect::From(bounds); | |
61 quad->needs_blending = false; | |
62 quad->shared_quad_state_index = 0u; | |
63 | |
64 mus::mojom::SolidColorQuadStatePtr color_state = | |
65 mus::mojom::SolidColorQuadState::New(); | |
66 color_state->color = mus::mojom::Color::New(); | |
67 color_state->color->rgba = 0xff00ff00; | |
68 color_state->force_anti_aliasing_off = false; | |
69 | |
70 quad->solid_color_quad_state = color_state.Pass(); | |
71 pass->quads.push_back(quad.Pass()); | |
72 frame->passes.push_back(pass.Pass()); | |
73 surface_->SubmitCompositorFrame(frame.Pass(), mojo::Closure()); | |
74 } | |
75 | |
76 void RenderWidgetViewMus::OnUnembed() {} | |
77 | |
78 void RenderWidgetViewMus::OnWindowBoundsChanged(mus::Window* window, | |
79 const gfx::Rect& old_bounds, | |
80 const gfx::Rect& new_bounds) {} | |
81 | |
82 } // namespace content | |
OLD | NEW |