OLD | NEW |
---|---|
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 "components/view_manager/client_connection.h" | 9 #include "components/view_manager/client_connection.h" |
9 #include "components/view_manager/connection_manager.h" | 10 #include "components/view_manager/connection_manager.h" |
10 #include "components/view_manager/public/cpp/args.h" | 11 #include "components/view_manager/public/cpp/args.h" |
12 #include "components/view_manager/surfaces/surfaces_impl.h" | |
13 #include "components/view_manager/surfaces/surfaces_scheduler.h" | |
11 #include "components/view_manager/view_manager_root_connection.h" | 14 #include "components/view_manager/view_manager_root_connection.h" |
12 #include "components/view_manager/view_manager_root_impl.h" | 15 #include "components/view_manager/view_manager_root_impl.h" |
13 #include "components/view_manager/view_manager_service_impl.h" | 16 #include "components/view_manager/view_manager_service_impl.h" |
14 #include "mojo/application/public/cpp/application_connection.h" | 17 #include "mojo/application/public/cpp/application_connection.h" |
15 #include "mojo/application/public/cpp/application_impl.h" | 18 #include "mojo/application/public/cpp/application_impl.h" |
16 #include "mojo/application/public/cpp/application_runner.h" | 19 #include "mojo/application/public/cpp/application_runner.h" |
17 #include "mojo/common/tracing_impl.h" | 20 #include "mojo/common/tracing_impl.h" |
18 #include "third_party/mojo/src/mojo/public/c/system/main.h" | 21 #include "third_party/mojo/src/mojo/public/c/system/main.h" |
19 #include "ui/events/event_switches.h" | 22 #include "ui/events/event_switches.h" |
20 #include "ui/events/platform/platform_event_source.h" | 23 #include "ui/events/platform/platform_event_source.h" |
21 #include "ui/gl/gl_surface.h" | 24 #include "ui/gl/gl_surface.h" |
22 #include "ui/gl/test/gl_surface_test_support.h" | 25 #include "ui/gl/test/gl_surface_test_support.h" |
23 | 26 |
24 using mojo::ApplicationConnection; | 27 using mojo::ApplicationConnection; |
25 using mojo::ApplicationImpl; | 28 using mojo::ApplicationImpl; |
26 using mojo::Gpu; | 29 using mojo::Gpu; |
27 using mojo::InterfaceRequest; | 30 using mojo::InterfaceRequest; |
28 using mojo::ViewManagerRoot; | 31 using mojo::ViewManagerRoot; |
29 using mojo::ViewManagerService; | 32 using mojo::ViewManagerService; |
30 | 33 |
31 namespace view_manager { | 34 namespace view_manager { |
32 | 35 |
33 ViewManagerApp::ViewManagerApp() : app_impl_(nullptr), is_headless_(false) { | 36 ViewManagerApp::ViewManagerApp() |
37 : app_impl_(nullptr), | |
38 is_headless_(false) { | |
34 } | 39 } |
35 | 40 |
36 ViewManagerApp::~ViewManagerApp() { | 41 ViewManagerApp::~ViewManagerApp() { |
37 if (gpu_state_) | 42 if (gpu_state_) |
38 gpu_state_->StopControlThread(); | 43 gpu_state_->StopControlThread(); |
39 } | 44 } |
40 | 45 |
41 void ViewManagerApp::Initialize(ApplicationImpl* app) { | 46 void ViewManagerApp::Initialize(ApplicationImpl* app) { |
42 app_impl_ = app; | 47 app_impl_ = app; |
43 tracing_.Initialize(app); | 48 tracing_.Initialize(app); |
49 surfaces_state_ = new surfaces::SurfacesState; | |
44 | 50 |
45 #if !defined(OS_ANDROID) | 51 #if !defined(OS_ANDROID) |
46 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 52 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
47 is_headless_ = command_line->HasSwitch(mojo::kUseHeadlessConfig); | 53 is_headless_ = command_line->HasSwitch(mojo::kUseHeadlessConfig); |
48 if (!is_headless_) { | 54 if (!is_headless_) { |
49 event_source_ = ui::PlatformEventSource::CreateDefault(); | 55 event_source_ = ui::PlatformEventSource::CreateDefault(); |
50 if (command_line->HasSwitch(mojo::kUseTestConfig)) | 56 if (command_line->HasSwitch(mojo::kUseTestConfig)) |
51 gfx::GLSurfaceTestSupport::InitializeOneOff(); | 57 gfx::GLSurfaceTestSupport::InitializeOneOff(); |
52 else | 58 else |
53 gfx::GLSurface::InitializeOneOff(); | 59 gfx::GLSurface::InitializeOneOff(); |
54 } | 60 } |
55 #endif | 61 #endif |
56 | 62 |
57 if (!gpu_state_.get()) | 63 if (!gpu_state_.get()) |
58 gpu_state_ = new gles2::GpuState; | 64 gpu_state_ = new gles2::GpuState; |
59 connection_manager_.reset(new ConnectionManager(this)); | 65 connection_manager_.reset(new ConnectionManager(this)); |
60 } | 66 } |
61 | 67 |
62 bool ViewManagerApp::ConfigureIncomingConnection( | 68 bool ViewManagerApp::ConfigureIncomingConnection( |
63 ApplicationConnection* connection) { | 69 ApplicationConnection* connection) { |
70 // ViewManager | |
64 connection->AddService<ViewManagerRoot>(this); | 71 connection->AddService<ViewManagerRoot>(this); |
72 // Surfaces | |
rjkroege
2015/08/06 00:16:22
you can (eventually) remove this based on today's
Fady Samuel
2015/08/06 16:48:24
Done.
| |
73 connection->AddService<mojo::Surface>(this); | |
74 // GPU | |
65 connection->AddService<Gpu>(this); | 75 connection->AddService<Gpu>(this); |
rjkroege
2015/08/06 00:16:22
why do we have a gpu service? is it still necessar
Fady Samuel
2015/08/06 16:48:24
I'm not sure yet. html_viewers still need a Comman
rjkroege
2015/08/06 22:09:02
not same. Yes, html_viewers need a CommandBuffer.
| |
66 | |
67 return true; | 76 return true; |
68 } | 77 } |
69 | 78 |
70 void ViewManagerApp::OnNoMoreRootConnections() { | 79 void ViewManagerApp::OnNoMoreRootConnections() { |
71 app_impl_->Terminate(); | 80 app_impl_->Terminate(); |
72 } | 81 } |
73 | 82 |
74 ClientConnection* ViewManagerApp::CreateClientConnectionForEmbedAtView( | 83 ClientConnection* ViewManagerApp::CreateClientConnectionForEmbedAtView( |
75 ConnectionManager* connection_manager, | 84 ConnectionManager* connection_manager, |
76 mojo::InterfaceRequest<mojo::ViewManagerService> service_request, | 85 mojo::InterfaceRequest<mojo::ViewManagerService> service_request, |
(...skipping 21 matching lines...) Expand all Loading... | |
98 service_request.Pass(), | 107 service_request.Pass(), |
99 view_manager_client.Pass()); | 108 view_manager_client.Pass()); |
100 } | 109 } |
101 | 110 |
102 void ViewManagerApp::Create(ApplicationConnection* connection, | 111 void ViewManagerApp::Create(ApplicationConnection* connection, |
103 InterfaceRequest<ViewManagerRoot> request) { | 112 InterfaceRequest<ViewManagerRoot> request) { |
104 DCHECK(connection_manager_.get()); | 113 DCHECK(connection_manager_.get()); |
105 // TODO(fsamuel): We need to make sure that only the window manager can create | 114 // TODO(fsamuel): We need to make sure that only the window manager can create |
106 // new roots. | 115 // new roots. |
107 ViewManagerRootImpl* view_manager_root = new ViewManagerRootImpl( | 116 ViewManagerRootImpl* view_manager_root = new ViewManagerRootImpl( |
108 connection_manager_.get(), is_headless_, app_impl_, gpu_state_); | 117 connection_manager_.get(), is_headless_, app_impl_, gpu_state_, |
118 surfaces_state_); | |
109 | 119 |
110 mojo::ViewManagerClientPtr client; | 120 mojo::ViewManagerClientPtr client; |
111 connection->ConnectToService(&client); | 121 connection->ConnectToService(&client); |
112 | 122 |
113 // ViewManagerRootConnection manages its own lifetime. | 123 // ViewManagerRootConnection manages its own lifetime. |
114 view_manager_root->Init(new ViewManagerRootConnectionImpl( | 124 view_manager_root->Init(new ViewManagerRootConnectionImpl( |
115 request.Pass(), make_scoped_ptr(view_manager_root), client.Pass(), | 125 request.Pass(), make_scoped_ptr(view_manager_root), client.Pass(), |
116 connection_manager_.get())); | 126 connection_manager_.get())); |
117 } | 127 } |
118 | 128 |
119 void ViewManagerApp::Create( | 129 void ViewManagerApp::Create( |
120 mojo::ApplicationConnection* connection, | 130 mojo::ApplicationConnection* connection, |
121 mojo::InterfaceRequest<Gpu> request) { | 131 mojo::InterfaceRequest<Gpu> request) { |
122 if (!gpu_state_.get()) | 132 if (!gpu_state_.get()) |
123 gpu_state_ = new gles2::GpuState; | 133 gpu_state_ = new gles2::GpuState; |
124 new gles2::GpuImpl(request.Pass(), gpu_state_); | 134 new gles2::GpuImpl(request.Pass(), gpu_state_); |
125 } | 135 } |
126 | 136 |
137 void ViewManagerApp::Create( | |
138 mojo::ApplicationConnection* connection, | |
139 mojo::InterfaceRequest<mojo::Surface> request) { | |
140 new surfaces::SurfacesImpl(surfaces_state_, request.Pass()); | |
141 } | |
142 | |
127 } // namespace view_manager | 143 } // namespace view_manager |
OLD | NEW |