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

Side by Side Diff: components/view_manager/view_manager_app.cc

Issue 1281663002: Mandoline: Allow submitting CompositorFrames directly to mojo::Views (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 5 years, 3 months 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
« no previous file with comments | « components/view_manager/view_manager_app.h ('k') | components/view_manager/view_tree_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "components/view_manager/view_manager_app.h" 5 #include "components/view_manager/view_manager_app.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/stl_util.h" 8 #include "base/stl_util.h"
9 #include "components/view_manager/client_connection.h" 9 #include "components/view_manager/client_connection.h"
10 #include "components/view_manager/connection_manager.h" 10 #include "components/view_manager/connection_manager.h"
11 #include "components/view_manager/gles2/gpu_impl.h" 11 #include "components/view_manager/gles2/gpu_impl.h"
12 #include "components/view_manager/public/cpp/args.h" 12 #include "components/view_manager/public/cpp/args.h"
13 #include "components/view_manager/surfaces/surfaces_impl.h"
14 #include "components/view_manager/surfaces/surfaces_scheduler.h" 13 #include "components/view_manager/surfaces/surfaces_scheduler.h"
15 #include "components/view_manager/view_tree_host_connection.h" 14 #include "components/view_manager/view_tree_host_connection.h"
16 #include "components/view_manager/view_tree_host_impl.h" 15 #include "components/view_manager/view_tree_host_impl.h"
17 #include "components/view_manager/view_tree_impl.h" 16 #include "components/view_manager/view_tree_impl.h"
18 #include "mojo/application/public/cpp/application_connection.h" 17 #include "mojo/application/public/cpp/application_connection.h"
19 #include "mojo/application/public/cpp/application_impl.h" 18 #include "mojo/application/public/cpp/application_impl.h"
20 #include "mojo/application/public/cpp/application_runner.h" 19 #include "mojo/application/public/cpp/application_runner.h"
21 #include "mojo/common/tracing_impl.h" 20 #include "mojo/common/tracing_impl.h"
22 #include "third_party/mojo/src/mojo/public/c/system/main.h" 21 #include "third_party/mojo/src/mojo/public/c/system/main.h"
23 #include "ui/events/event_switches.h" 22 #include "ui/events/event_switches.h"
(...skipping 10 matching lines...) Expand all
34 namespace view_manager { 33 namespace view_manager {
35 34
36 ViewManagerApp::ViewManagerApp() 35 ViewManagerApp::ViewManagerApp()
37 : app_impl_(nullptr), 36 : app_impl_(nullptr),
38 is_headless_(false) { 37 is_headless_(false) {
39 } 38 }
40 39
41 ViewManagerApp::~ViewManagerApp() { 40 ViewManagerApp::~ViewManagerApp() {
42 if (gpu_state_) 41 if (gpu_state_)
43 gpu_state_->StopControlThread(); 42 gpu_state_->StopControlThread();
44
45 auto surfaces = surfaces_;
46 for (auto& surface : surfaces)
47 surface->CloseConnection();
48 } 43 }
49 44
50 void ViewManagerApp::Initialize(ApplicationImpl* app) { 45 void ViewManagerApp::Initialize(ApplicationImpl* app) {
51 app_impl_ = app; 46 app_impl_ = app;
52 tracing_.Initialize(app); 47 tracing_.Initialize(app);
53 surfaces_state_ = new surfaces::SurfacesState; 48 surfaces_state_ = new surfaces::SurfacesState;
54 49
55 #if !defined(OS_ANDROID) 50 #if !defined(OS_ANDROID)
56 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); 51 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
57 is_headless_ = command_line->HasSwitch(mojo::kUseHeadlessConfig); 52 is_headless_ = command_line->HasSwitch(mojo::kUseHeadlessConfig);
58 if (!is_headless_) { 53 if (!is_headless_) {
59 event_source_ = ui::PlatformEventSource::CreateDefault(); 54 event_source_ = ui::PlatformEventSource::CreateDefault();
60 if (command_line->HasSwitch(mojo::kUseTestConfig)) 55 if (command_line->HasSwitch(mojo::kUseTestConfig))
61 gfx::GLSurfaceTestSupport::InitializeOneOff(); 56 gfx::GLSurfaceTestSupport::InitializeOneOff();
62 else 57 else
63 gfx::GLSurface::InitializeOneOff(); 58 gfx::GLSurface::InitializeOneOff();
64 } 59 }
65 #endif 60 #endif
66 61
67 if (!gpu_state_.get()) 62 if (!gpu_state_.get())
68 gpu_state_ = new gles2::GpuState; 63 gpu_state_ = new gles2::GpuState;
69 connection_manager_.reset(new ConnectionManager(this)); 64 connection_manager_.reset(new ConnectionManager(this, surfaces_state_));
70 } 65 }
71 66
72 bool ViewManagerApp::ConfigureIncomingConnection( 67 bool ViewManagerApp::ConfigureIncomingConnection(
73 ApplicationConnection* connection) { 68 ApplicationConnection* connection) {
74 // ViewManager 69 // ViewManager
75 connection->AddService<ViewTreeHostFactory>(this); 70 connection->AddService<ViewTreeHostFactory>(this);
76 // Surfaces
77 // TODO(fsamuel): This should go away soon.
78 connection->AddService<mojo::Surface>(this);
79 // GPU 71 // GPU
80 connection->AddService<Gpu>(this); 72 connection->AddService<Gpu>(this);
81 return true; 73 return true;
82 } 74 }
83 75
84 void ViewManagerApp::OnNoMoreRootConnections() { 76 void ViewManagerApp::OnNoMoreRootConnections() {
85 app_impl_->Quit(); 77 app_impl_->Quit();
86 } 78 }
87 79
88 ClientConnection* ViewManagerApp::CreateClientConnectionForEmbedAtView( 80 ClientConnection* ViewManagerApp::CreateClientConnectionForEmbedAtView(
(...skipping 30 matching lines...) Expand all
119 } 111 }
120 112
121 void ViewManagerApp::Create( 113 void ViewManagerApp::Create(
122 mojo::ApplicationConnection* connection, 114 mojo::ApplicationConnection* connection,
123 mojo::InterfaceRequest<Gpu> request) { 115 mojo::InterfaceRequest<Gpu> request) {
124 if (!gpu_state_.get()) 116 if (!gpu_state_.get())
125 gpu_state_ = new gles2::GpuState; 117 gpu_state_ = new gles2::GpuState;
126 new gles2::GpuImpl(request.Pass(), gpu_state_); 118 new gles2::GpuImpl(request.Pass(), gpu_state_);
127 } 119 }
128 120
129 void ViewManagerApp::Create(
130 mojo::ApplicationConnection* connection,
131 mojo::InterfaceRequest<mojo::Surface> request) {
132 surfaces_.insert(
133 new surfaces::SurfacesImpl(this, surfaces_state_, request.Pass()));
134 }
135
136 void ViewManagerApp::OnSurfaceConnectionClosed(
137 surfaces::SurfacesImpl* surface) {
138 surfaces_.erase(surface);
139 }
140
141 void ViewManagerApp::CreateViewTreeHost( 121 void ViewManagerApp::CreateViewTreeHost(
142 mojo::InterfaceRequest<mojo::ViewTreeHost> host, 122 mojo::InterfaceRequest<mojo::ViewTreeHost> host,
143 mojo::ViewTreeHostClientPtr host_client, 123 mojo::ViewTreeHostClientPtr host_client,
144 mojo::ViewTreeClientPtr tree_client) { 124 mojo::ViewTreeClientPtr tree_client) {
145 DCHECK(connection_manager_.get()); 125 DCHECK(connection_manager_.get());
146 126
147 // TODO(fsamuel): We need to make sure that only the window manager can create 127 // TODO(fsamuel): We need to make sure that only the window manager can create
148 // new roots. 128 // new roots.
149 ViewTreeHostImpl* host_impl = new ViewTreeHostImpl( 129 ViewTreeHostImpl* host_impl = new ViewTreeHostImpl(
150 host_client.Pass(), connection_manager_.get(), is_headless_, app_impl_, 130 host_client.Pass(), connection_manager_.get(), is_headless_, app_impl_,
151 gpu_state_, surfaces_state_); 131 gpu_state_, surfaces_state_);
152 132
153 // ViewTreeHostConnection manages its own lifetime. 133 // ViewTreeHostConnection manages its own lifetime.
154 host_impl->Init(new ViewTreeHostConnectionImpl( 134 host_impl->Init(new ViewTreeHostConnectionImpl(
155 host.Pass(), make_scoped_ptr(host_impl), tree_client.Pass(), 135 host.Pass(), make_scoped_ptr(host_impl), tree_client.Pass(),
156 connection_manager_.get())); 136 connection_manager_.get()));
157 } 137 }
158 138
159 } // namespace view_manager 139 } // namespace view_manager
OLDNEW
« no previous file with comments | « components/view_manager/view_manager_app.h ('k') | components/view_manager/view_tree_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698