| 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_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 Loading... |
| 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<ViewManagerRoot>(this); | 70 connection->AddService<ViewManagerRoot>(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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 } | 124 } |
| 133 | 125 |
| 134 void ViewManagerApp::Create( | 126 void ViewManagerApp::Create( |
| 135 mojo::ApplicationConnection* connection, | 127 mojo::ApplicationConnection* connection, |
| 136 mojo::InterfaceRequest<Gpu> request) { | 128 mojo::InterfaceRequest<Gpu> request) { |
| 137 if (!gpu_state_.get()) | 129 if (!gpu_state_.get()) |
| 138 gpu_state_ = new gles2::GpuState; | 130 gpu_state_ = new gles2::GpuState; |
| 139 new gles2::GpuImpl(request.Pass(), gpu_state_); | 131 new gles2::GpuImpl(request.Pass(), gpu_state_); |
| 140 } | 132 } |
| 141 | 133 |
| 142 void ViewManagerApp::Create( | |
| 143 mojo::ApplicationConnection* connection, | |
| 144 mojo::InterfaceRequest<mojo::Surface> request) { | |
| 145 surfaces_.insert( | |
| 146 new surfaces::SurfacesImpl(this, surfaces_state_, request.Pass())); | |
| 147 } | |
| 148 | |
| 149 void ViewManagerApp::OnSurfaceConnectionClosed( | |
| 150 surfaces::SurfacesImpl* surface) { | |
| 151 surfaces_.erase(surface); | |
| 152 } | |
| 153 | |
| 154 } // namespace view_manager | 134 } // namespace view_manager |
| OLD | NEW |