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

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

Issue 1472063007: mustash: enable GPU Compositing in renderer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/renderer/render_widget_mus_connection.h" 5 #include "content/renderer/render_widget_mus_connection.h"
6 6
7 #include <map>
8
9 #include "components/mus/public/cpp/context_provider.h"
7 #include "components/mus/public/interfaces/compositor_frame.mojom.h" 10 #include "components/mus/public/interfaces/compositor_frame.mojom.h"
11 #include "components/mus/public/interfaces/gpu.mojom.h"
8 #include "components/mus/public/interfaces/window_tree.mojom.h" 12 #include "components/mus/public/interfaces/window_tree.mojom.h"
9 #include "content/public/common/mojo_shell_connection.h" 13 #include "content/public/common/mojo_shell_connection.h"
10 #include "mojo/application/public/cpp/application_impl.h" 14 #include "mojo/application/public/cpp/application_impl.h"
11 #include "mojo/converters/geometry/geometry_type_converters.h" 15 #include "mojo/converters/geometry/geometry_type_converters.h"
12 #include "mojo/converters/surfaces/surfaces_utils.h" 16 #include "mojo/converters/surfaces/surfaces_utils.h"
13 17
14 namespace content { 18 namespace content {
15 19
20 namespace {
21
22 std::map<int, RenderWidgetMusConnection*>* g_connections = nullptr;
23
24 }
25
16 RenderWidgetMusConnection::RenderWidgetMusConnection( 26 RenderWidgetMusConnection::RenderWidgetMusConnection(
17 int routing_id, 27 int routing_id,
18 mojo::InterfaceRequest<mus::mojom::WindowTreeClient> request) 28 mojo::InterfaceRequest<mus::mojom::WindowTreeClient> request)
19 : routing_id_(routing_id), root_(nullptr) { 29 : routing_id_(routing_id), root_(nullptr) {
30 fprintf(stderr, "EEE %s\n", __func__);
20 // TODO(fsamuel): We should probably introduce a 31 // TODO(fsamuel): We should probably introduce a
21 // RenderWidgetMusConnection::FromRoutingID that's usable from RenderWidget. 32 // RenderWidgetMusConnection::FromRoutingID that's usable from RenderWidget.
22 // TODO(fsamuel): We probably want to pause processing of incoming 33 // TODO(fsamuel): We probably want to pause processing of incoming
23 // messages until we have an associated RenderWidget. 34 // messages until we have an associated RenderWidget.
24 mus::WindowTreeConnection::Create( 35 mus::WindowTreeConnection::Create(
25 this, request.Pass(), 36 this, request.Pass(),
26 mus::WindowTreeConnection::CreateType::DONT_WAIT_FOR_EMBED); 37 mus::WindowTreeConnection::CreateType::DONT_WAIT_FOR_EMBED);
38 if (!g_connections)
39 g_connections = new std::map<int, RenderWidgetMusConnection*>();
40
41 CHECK(g_connections->count(routing_id) == 0);
42 g_connections->insert(std::make_pair(routing_id, this));
27 } 43 }
28 44
29 RenderWidgetMusConnection::~RenderWidgetMusConnection() {} 45 RenderWidgetMusConnection::~RenderWidgetMusConnection() {
46 fprintf(stderr, "EEE %s\n", __func__);
47 CHECK(g_connections->erase(routing_id_) == 1);
48 }
49
50 scoped_ptr<cc::OutputSurface> RenderWidgetMusConnection::CreateOutputSurface() {
51 fprintf(stderr, "EEE %s\n", __func__);
52 mus::mojom::GpuPtr gpu_service;
53 MojoShellConnection::Get()->GetApplication()->ConnectToService(
54 "mojo:mus", &gpu_service);
55 mus::mojom::CommandBufferPtr cb;
56 gpu_service->CreateOffscreenGLES2Context(GetProxy(&cb));
57 scoped_refptr<cc::ContextProvider> context_provider(
58 new mus::ContextProvider(cb.PassInterface().PassHandle()));
59 return make_scoped_ptr(new mus::OutputSurface(
60 context_provider,
61 root_->RequestSurface(mus::mojom::SURFACE_TYPE_DEFAULT)));
62 }
63
64 RenderWidgetMusConnection* RenderWidgetMusConnection::Get(int routing_id) {
65 fprintf(stderr, "EEE %s\n", __func__);
66 if (!g_connections)
67 return nullptr;
68
69 auto it = g_connections->find(routing_id);
70 if (it == g_connections->end())
71 return nullptr;
72
73 return it->second;
74
75 }
30 76
31 void RenderWidgetMusConnection::SubmitCompositorFrame() { 77 void RenderWidgetMusConnection::SubmitCompositorFrame() {
78 #if 0
32 const gfx::Rect bounds(root_->bounds()); 79 const gfx::Rect bounds(root_->bounds());
33 mus::mojom::PassPtr pass = mojo::CreateDefaultPass(1, bounds); 80 mus::mojom::PassPtr pass = mojo::CreateDefaultPass(1, bounds);
34 mus::mojom::CompositorFramePtr frame = mus::mojom::CompositorFrame::New(); 81 mus::mojom::CompositorFramePtr frame = mus::mojom::CompositorFrame::New();
35 82
36 mus::mojom::CompositorFrameMetadataPtr meta = 83 mus::mojom::CompositorFrameMetadataPtr meta =
37 mus::mojom::CompositorFrameMetadata::New(); 84 mus::mojom::CompositorFrameMetadata::New();
38 meta->device_scale_factor = 1.0f; 85 meta->device_scale_factor = 1.0f;
39 frame->metadata = meta.Pass(); 86 frame->metadata = meta.Pass();
40 87
41 frame->resources.resize(0u); 88 frame->resources.resize(0u);
(...skipping 12 matching lines...) Expand all
54 mus::mojom::SolidColorQuadStatePtr color_state = 101 mus::mojom::SolidColorQuadStatePtr color_state =
55 mus::mojom::SolidColorQuadState::New(); 102 mus::mojom::SolidColorQuadState::New();
56 color_state->color = mus::mojom::Color::New(); 103 color_state->color = mus::mojom::Color::New();
57 color_state->color->rgba = 0xff00ff00; 104 color_state->color->rgba = 0xff00ff00;
58 color_state->force_anti_aliasing_off = false; 105 color_state->force_anti_aliasing_off = false;
59 106
60 quad->solid_color_quad_state = color_state.Pass(); 107 quad->solid_color_quad_state = color_state.Pass();
61 pass->quads.push_back(quad.Pass()); 108 pass->quads.push_back(quad.Pass());
62 frame->passes.push_back(pass.Pass()); 109 frame->passes.push_back(pass.Pass());
63 surface_->SubmitCompositorFrame(frame.Pass(), mojo::Closure()); 110 surface_->SubmitCompositorFrame(frame.Pass(), mojo::Closure());
111 #endif
64 } 112 }
65 113
66 void RenderWidgetMusConnection::OnConnectionLost( 114 void RenderWidgetMusConnection::OnConnectionLost(
67 mus::WindowTreeConnection* connection) { 115 mus::WindowTreeConnection* connection) {
68 delete this; 116 delete this;
69 } 117 }
70 118
71 void RenderWidgetMusConnection::OnEmbed(mus::Window* root) { 119 void RenderWidgetMusConnection::OnEmbed(mus::Window* root) {
72 root_ = root; 120 root_ = root;
73 root_->AddObserver(this); 121 root_->AddObserver(this);
74 surface_ = root_->RequestSurface(mus::mojom::SURFACE_TYPE_DEFAULT); 122 surface_ = root_->RequestSurface(mus::mojom::SURFACE_TYPE_DEFAULT);
75 surface_->BindToThread(); 123 surface_->BindToThread();
76 SubmitCompositorFrame(); 124 SubmitCompositorFrame();
77 } 125 }
78 126
79 void RenderWidgetMusConnection::OnUnembed() {} 127 void RenderWidgetMusConnection::OnUnembed() {}
80 128
81 void RenderWidgetMusConnection::OnWindowBoundsChanged( 129 void RenderWidgetMusConnection::OnWindowBoundsChanged(
82 mus::Window* window, 130 mus::Window* window,
83 const gfx::Rect& old_bounds, 131 const gfx::Rect& old_bounds,
84 const gfx::Rect& new_bounds) { 132 const gfx::Rect& new_bounds) {
85 SubmitCompositorFrame(); 133 SubmitCompositorFrame();
86 } 134 }
87 135
88 } // namespace content 136 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698