| 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 "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_manager_root_connection.h" | 14 #include "components/view_manager/view_manager_root_connection.h" |
| 16 #include "components/view_manager/view_manager_root_impl.h" | 15 #include "components/view_manager/view_manager_root_impl.h" |
| 17 #include "components/view_manager/view_manager_service_impl.h" | 16 #include "components/view_manager/view_manager_service_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 11 matching lines...) Expand all Loading... |
| 35 namespace view_manager { | 34 namespace view_manager { |
| 36 | 35 |
| 37 ViewManagerApp::ViewManagerApp() | 36 ViewManagerApp::ViewManagerApp() |
| 38 : app_impl_(nullptr), | 37 : app_impl_(nullptr), |
| 39 is_headless_(false) { | 38 is_headless_(false) { |
| 40 } | 39 } |
| 41 | 40 |
| 42 ViewManagerApp::~ViewManagerApp() { | 41 ViewManagerApp::~ViewManagerApp() { |
| 43 if (gpu_state_) | 42 if (gpu_state_) |
| 44 gpu_state_->StopControlThread(); | 43 gpu_state_->StopControlThread(); |
| 45 | |
| 46 auto surfaces = surfaces_; | |
| 47 for (auto& surface : surfaces) | |
| 48 surface->CloseConnection(); | |
| 49 } | 44 } |
| 50 | 45 |
| 51 void ViewManagerApp::Initialize(ApplicationImpl* app) { | 46 void ViewManagerApp::Initialize(ApplicationImpl* app) { |
| 52 app_impl_ = app; | 47 app_impl_ = app; |
| 53 tracing_.Initialize(app); | 48 tracing_.Initialize(app); |
| 54 surfaces_state_ = new surfaces::SurfacesState; | 49 surfaces_state_ = new surfaces::SurfacesState; |
| 55 | 50 |
| 56 #if !defined(OS_ANDROID) | 51 #if !defined(OS_ANDROID) |
| 57 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 52 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| 58 is_headless_ = command_line->HasSwitch(mojo::kUseHeadlessConfig); | 53 is_headless_ = command_line->HasSwitch(mojo::kUseHeadlessConfig); |
| 59 if (!is_headless_) { | 54 if (!is_headless_) { |
| 60 event_source_ = ui::PlatformEventSource::CreateDefault(); | 55 event_source_ = ui::PlatformEventSource::CreateDefault(); |
| 61 if (command_line->HasSwitch(mojo::kUseTestConfig)) | 56 if (command_line->HasSwitch(mojo::kUseTestConfig)) |
| 62 gfx::GLSurfaceTestSupport::InitializeOneOff(); | 57 gfx::GLSurfaceTestSupport::InitializeOneOff(); |
| 63 else | 58 else |
| 64 gfx::GLSurface::InitializeOneOff(); | 59 gfx::GLSurface::InitializeOneOff(); |
| 65 } | 60 } |
| 66 #endif | 61 #endif |
| 67 | 62 |
| 68 if (!gpu_state_.get()) | 63 if (!gpu_state_.get()) |
| 69 gpu_state_ = new gles2::GpuState; | 64 gpu_state_ = new gles2::GpuState; |
| 70 connection_manager_.reset(new ConnectionManager(this)); | 65 connection_manager_.reset(new ConnectionManager(this, surfaces_state_)); |
| 71 } | 66 } |
| 72 | 67 |
| 73 bool ViewManagerApp::ConfigureIncomingConnection( | 68 bool ViewManagerApp::ConfigureIncomingConnection( |
| 74 ApplicationConnection* connection) { | 69 ApplicationConnection* connection) { |
| 75 // ViewManager | 70 // ViewManager |
| 76 connection->AddService<ViewManagerRoot>(this); | 71 connection->AddService<ViewManagerRoot>(this); |
| 77 // Surfaces | |
| 78 // TODO(fsamuel): This should go away soon. | |
| 79 connection->AddService<mojo::Surface>(this); | |
| 80 // GPU | 72 // GPU |
| 81 connection->AddService<Gpu>(this); | 73 connection->AddService<Gpu>(this); |
| 82 return true; | 74 return true; |
| 83 } | 75 } |
| 84 | 76 |
| 85 void ViewManagerApp::OnNoMoreRootConnections() { | 77 void ViewManagerApp::OnNoMoreRootConnections() { |
| 86 app_impl_->Quit(); | 78 app_impl_->Quit(); |
| 87 } | 79 } |
| 88 | 80 |
| 89 ClientConnection* ViewManagerApp::CreateClientConnectionForEmbedAtView( | 81 ClientConnection* ViewManagerApp::CreateClientConnectionForEmbedAtView( |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 } | 125 } |
| 134 | 126 |
| 135 void ViewManagerApp::Create( | 127 void ViewManagerApp::Create( |
| 136 mojo::ApplicationConnection* connection, | 128 mojo::ApplicationConnection* connection, |
| 137 mojo::InterfaceRequest<Gpu> request) { | 129 mojo::InterfaceRequest<Gpu> request) { |
| 138 if (!gpu_state_.get()) | 130 if (!gpu_state_.get()) |
| 139 gpu_state_ = new gles2::GpuState; | 131 gpu_state_ = new gles2::GpuState; |
| 140 new gles2::GpuImpl(request.Pass(), gpu_state_); | 132 new gles2::GpuImpl(request.Pass(), gpu_state_); |
| 141 } | 133 } |
| 142 | 134 |
| 143 void ViewManagerApp::Create( | |
| 144 mojo::ApplicationConnection* connection, | |
| 145 mojo::InterfaceRequest<mojo::Surface> request) { | |
| 146 surfaces_.insert( | |
| 147 new surfaces::SurfacesImpl(this, surfaces_state_, request.Pass())); | |
| 148 } | |
| 149 | |
| 150 void ViewManagerApp::OnSurfaceConnectionClosed( | |
| 151 surfaces::SurfacesImpl* surface) { | |
| 152 surfaces_.erase(surface); | |
| 153 } | |
| 154 | |
| 155 } // namespace view_manager | 135 } // namespace view_manager |
| OLD | NEW |