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

Unified 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, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: content/renderer/render_widget_mus_connection.cc
diff --git a/content/renderer/render_widget_mus_connection.cc b/content/renderer/render_widget_mus_connection.cc
index 297e0f226e08fdac531d99642ad617ba1a39444b..d83b5ac0f8e928d09ce2f3dc9c8afc4f69a7084a 100644
--- a/content/renderer/render_widget_mus_connection.cc
+++ b/content/renderer/render_widget_mus_connection.cc
@@ -4,7 +4,11 @@
#include "content/renderer/render_widget_mus_connection.h"
+#include <map>
+
+#include "components/mus/public/cpp/context_provider.h"
#include "components/mus/public/interfaces/compositor_frame.mojom.h"
+#include "components/mus/public/interfaces/gpu.mojom.h"
#include "components/mus/public/interfaces/window_tree.mojom.h"
#include "content/public/common/mojo_shell_connection.h"
#include "mojo/application/public/cpp/application_impl.h"
@@ -13,10 +17,17 @@
namespace content {
+namespace {
+
+std::map<int, RenderWidgetMusConnection*>* g_connections = nullptr;
+
+}
+
RenderWidgetMusConnection::RenderWidgetMusConnection(
int routing_id,
mojo::InterfaceRequest<mus::mojom::WindowTreeClient> request)
: routing_id_(routing_id), root_(nullptr) {
+ fprintf(stderr, "EEE %s\n", __func__);
// TODO(fsamuel): We should probably introduce a
// RenderWidgetMusConnection::FromRoutingID that's usable from RenderWidget.
// TODO(fsamuel): We probably want to pause processing of incoming
@@ -24,11 +35,47 @@ RenderWidgetMusConnection::RenderWidgetMusConnection(
mus::WindowTreeConnection::Create(
this, request.Pass(),
mus::WindowTreeConnection::CreateType::DONT_WAIT_FOR_EMBED);
+ if (!g_connections)
+ g_connections = new std::map<int, RenderWidgetMusConnection*>();
+
+ CHECK(g_connections->count(routing_id) == 0);
+ g_connections->insert(std::make_pair(routing_id, this));
+}
+
+RenderWidgetMusConnection::~RenderWidgetMusConnection() {
+ fprintf(stderr, "EEE %s\n", __func__);
+ CHECK(g_connections->erase(routing_id_) == 1);
+}
+
+scoped_ptr<cc::OutputSurface> RenderWidgetMusConnection::CreateOutputSurface() {
+ fprintf(stderr, "EEE %s\n", __func__);
+ mus::mojom::GpuPtr gpu_service;
+ MojoShellConnection::Get()->GetApplication()->ConnectToService(
+ "mojo:mus", &gpu_service);
+ mus::mojom::CommandBufferPtr cb;
+ gpu_service->CreateOffscreenGLES2Context(GetProxy(&cb));
+ scoped_refptr<cc::ContextProvider> context_provider(
+ new mus::ContextProvider(cb.PassInterface().PassHandle()));
+ return make_scoped_ptr(new mus::OutputSurface(
+ context_provider,
+ root_->RequestSurface(mus::mojom::SURFACE_TYPE_DEFAULT)));
}
-RenderWidgetMusConnection::~RenderWidgetMusConnection() {}
+RenderWidgetMusConnection* RenderWidgetMusConnection::Get(int routing_id) {
+ fprintf(stderr, "EEE %s\n", __func__);
+ if (!g_connections)
+ return nullptr;
+
+ auto it = g_connections->find(routing_id);
+ if (it == g_connections->end())
+ return nullptr;
+
+ return it->second;
+
+}
void RenderWidgetMusConnection::SubmitCompositorFrame() {
+#if 0
const gfx::Rect bounds(root_->bounds());
mus::mojom::PassPtr pass = mojo::CreateDefaultPass(1, bounds);
mus::mojom::CompositorFramePtr frame = mus::mojom::CompositorFrame::New();
@@ -61,6 +108,7 @@ void RenderWidgetMusConnection::SubmitCompositorFrame() {
pass->quads.push_back(quad.Pass());
frame->passes.push_back(pass.Pass());
surface_->SubmitCompositorFrame(frame.Pass(), mojo::Closure());
+#endif
}
void RenderWidgetMusConnection::OnConnectionLost(

Powered by Google App Engine
This is Rietveld 408576698