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_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 RenderWidgetMus::RenderWidgetMus(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 RenderWidgetMus::~RenderWidgetMus() {} |
| 33 |
| 34 void RenderWidgetMus::OnConnectionLost(mus::WindowTreeConnection* connection) { |
| 35 delete this; |
| 36 } |
| 37 |
| 38 void RenderWidgetMus::OnEmbed(mus::Window* root) { |
| 39 root->AddObserver(this); |
| 40 surface_ = root->RequestSurface(mus::mojom::SURFACE_TYPE_DEFAULT); |
| 41 surface_->BindToThread(); |
| 42 |
| 43 const gfx::Rect bounds(root->bounds()); |
| 44 mus::mojom::PassPtr pass = mojo::CreateDefaultPass(1, bounds); |
| 45 mus::mojom::CompositorFramePtr frame = mus::mojom::CompositorFrame::New(); |
| 46 |
| 47 mus::mojom::CompositorFrameMetadataPtr meta = |
| 48 mus::mojom::CompositorFrameMetadata::New(); |
| 49 meta->device_scale_factor = 1.0f; |
| 50 frame->metadata = meta.Pass(); |
| 51 |
| 52 frame->resources.resize(0u); |
| 53 |
| 54 pass->quads.resize(0u); |
| 55 pass->shared_quad_states.push_back(mojo::CreateDefaultSQS(bounds.size())); |
| 56 |
| 57 mus::mojom::QuadPtr quad = mus::mojom::Quad::New(); |
| 58 quad->material = mus::mojom::MATERIAL_SOLID_COLOR; |
| 59 quad->rect = mojo::Rect::From(bounds); |
| 60 quad->opaque_rect = mojo::Rect::New(); |
| 61 quad->visible_rect = mojo::Rect::From(bounds); |
| 62 quad->needs_blending = false; |
| 63 quad->shared_quad_state_index = 0u; |
| 64 |
| 65 mus::mojom::SolidColorQuadStatePtr color_state = |
| 66 mus::mojom::SolidColorQuadState::New(); |
| 67 color_state->color = mus::mojom::Color::New(); |
| 68 color_state->color->rgba = 0xff00ff00; |
| 69 color_state->force_anti_aliasing_off = false; |
| 70 |
| 71 quad->solid_color_quad_state = color_state.Pass(); |
| 72 pass->quads.push_back(quad.Pass()); |
| 73 frame->passes.push_back(pass.Pass()); |
| 74 surface_->SubmitCompositorFrame(frame.Pass(), mojo::Closure()); |
| 75 } |
| 76 |
| 77 void RenderWidgetMus::OnUnembed() {} |
| 78 |
| 79 void RenderWidgetMus::OnWindowBoundsChanged(mus::Window* window, |
| 80 const gfx::Rect& old_bounds, |
| 81 const gfx::Rect& new_bounds) {} |
| 82 |
| 83 } // namespace content |
OLD | NEW |