| 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/mus/mus_app.h" | 5 #include "components/mus/mus_app.h" |
| 6 | 6 |
| 7 #include "base/stl_util.h" | 7 #include "base/stl_util.h" |
| 8 #include "components/mus/gles2/gpu_impl.h" | 8 #include "components/mus/gles2/gpu_impl.h" |
| 9 #include "components/mus/public/cpp/args.h" | 9 #include "components/mus/public/cpp/args.h" |
| 10 #include "components/mus/surfaces/surfaces_scheduler.h" | 10 #include "components/mus/surfaces/surfaces_scheduler.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 #include "ui/gl/gl_surface.h" | 23 #include "ui/gl/gl_surface.h" |
| 24 | 24 |
| 25 #if defined(USE_X11) | 25 #if defined(USE_X11) |
| 26 #include <X11/Xlib.h> | 26 #include <X11/Xlib.h> |
| 27 #include "base/command_line.h" | 27 #include "base/command_line.h" |
| 28 #include "ui/platform_window/x11/x11_window.h" | 28 #include "ui/platform_window/x11/x11_window.h" |
| 29 #endif | 29 #endif |
| 30 | 30 |
| 31 using mojo::ApplicationConnection; | 31 using mojo::ApplicationConnection; |
| 32 using mojo::ApplicationImpl; | 32 using mojo::ApplicationImpl; |
| 33 using mojo::Gpu; | |
| 34 using mojo::InterfaceRequest; | 33 using mojo::InterfaceRequest; |
| 35 using mojo::ViewTreeHostFactory; | 34 using mus::mojom::WindowTreeHostFactory; |
| 35 using mus::mojom::Gpu; |
| 36 | 36 |
| 37 namespace mus { | 37 namespace mus { |
| 38 | 38 |
| 39 MandolineUIServicesApp::MandolineUIServicesApp() | 39 MandolineUIServicesApp::MandolineUIServicesApp() |
| 40 : app_impl_(nullptr) {} | 40 : app_impl_(nullptr) {} |
| 41 | 41 |
| 42 MandolineUIServicesApp::~MandolineUIServicesApp() { | 42 MandolineUIServicesApp::~MandolineUIServicesApp() { |
| 43 if (gpu_state_) | 43 if (gpu_state_) |
| 44 gpu_state_->StopControlThread(); | 44 gpu_state_->StopControlThread(); |
| 45 // Destroy |connection_manager_| first, since it depends on |event_source_|. | 45 // Destroy |connection_manager_| first, since it depends on |event_source_|. |
| (...skipping 18 matching lines...) Expand all Loading... |
| 64 event_source_ = ui::PlatformEventSource::CreateDefault(); | 64 event_source_ = ui::PlatformEventSource::CreateDefault(); |
| 65 #endif | 65 #endif |
| 66 | 66 |
| 67 if (!gpu_state_.get()) | 67 if (!gpu_state_.get()) |
| 68 gpu_state_ = new GpuState; | 68 gpu_state_ = new GpuState; |
| 69 connection_manager_.reset(new ConnectionManager(this, surfaces_state_)); | 69 connection_manager_.reset(new ConnectionManager(this, surfaces_state_)); |
| 70 } | 70 } |
| 71 | 71 |
| 72 bool MandolineUIServicesApp::ConfigureIncomingConnection( | 72 bool MandolineUIServicesApp::ConfigureIncomingConnection( |
| 73 ApplicationConnection* connection) { | 73 ApplicationConnection* connection) { |
| 74 connection->AddService<ViewTreeHostFactory>(this); | 74 connection->AddService<WindowTreeHostFactory>(this); |
| 75 connection->AddService<Gpu>(this); | 75 connection->AddService<Gpu>(this); |
| 76 return true; | 76 return true; |
| 77 } | 77 } |
| 78 | 78 |
| 79 void MandolineUIServicesApp::OnNoMoreRootConnections() { | 79 void MandolineUIServicesApp::OnNoMoreRootConnections() { |
| 80 app_impl_->Quit(); | 80 app_impl_->Quit(); |
| 81 } | 81 } |
| 82 | 82 |
| 83 ClientConnection* MandolineUIServicesApp::CreateClientConnectionForEmbedAtView( | 83 ClientConnection* MandolineUIServicesApp::CreateClientConnectionForEmbedAtView( |
| 84 ConnectionManager* connection_manager, | 84 ConnectionManager* connection_manager, |
| 85 mojo::InterfaceRequest<mojo::ViewTree> tree_request, | 85 mojo::InterfaceRequest<mojom::WindowTree> tree_request, |
| 86 ConnectionSpecificId creator_id, | 86 ConnectionSpecificId creator_id, |
| 87 mojo::URLRequestPtr request, | 87 mojo::URLRequestPtr request, |
| 88 const ViewId& root_id, | 88 const ViewId& root_id, |
| 89 uint32_t policy_bitmask) { | 89 uint32_t policy_bitmask) { |
| 90 mojo::ViewTreeClientPtr client; | 90 mojom::WindowTreeClientPtr client; |
| 91 app_impl_->ConnectToService(request.Pass(), &client); | 91 app_impl_->ConnectToService(request.Pass(), &client); |
| 92 | 92 |
| 93 scoped_ptr<ViewTreeImpl> service(new ViewTreeImpl( | 93 scoped_ptr<ViewTreeImpl> service(new ViewTreeImpl( |
| 94 connection_manager, creator_id, root_id, policy_bitmask)); | 94 connection_manager, creator_id, root_id, policy_bitmask)); |
| 95 return new DefaultClientConnection(service.Pass(), connection_manager, | 95 return new DefaultClientConnection(service.Pass(), connection_manager, |
| 96 tree_request.Pass(), client.Pass()); | 96 tree_request.Pass(), client.Pass()); |
| 97 } | 97 } |
| 98 | 98 |
| 99 ClientConnection* MandolineUIServicesApp::CreateClientConnectionForEmbedAtView( | 99 ClientConnection* MandolineUIServicesApp::CreateClientConnectionForEmbedAtView( |
| 100 ConnectionManager* connection_manager, | 100 ConnectionManager* connection_manager, |
| 101 mojo::InterfaceRequest<mojo::ViewTree> tree_request, | 101 mojo::InterfaceRequest<mojom::WindowTree> tree_request, |
| 102 ConnectionSpecificId creator_id, | 102 ConnectionSpecificId creator_id, |
| 103 const ViewId& root_id, | 103 const ViewId& root_id, |
| 104 uint32_t policy_bitmask, | 104 uint32_t policy_bitmask, |
| 105 mojo::ViewTreeClientPtr client) { | 105 mojom::WindowTreeClientPtr client) { |
| 106 scoped_ptr<ViewTreeImpl> service(new ViewTreeImpl( | 106 scoped_ptr<ViewTreeImpl> service(new ViewTreeImpl( |
| 107 connection_manager, creator_id, root_id, policy_bitmask)); | 107 connection_manager, creator_id, root_id, policy_bitmask)); |
| 108 return new DefaultClientConnection(service.Pass(), connection_manager, | 108 return new DefaultClientConnection(service.Pass(), connection_manager, |
| 109 tree_request.Pass(), client.Pass()); | 109 tree_request.Pass(), client.Pass()); |
| 110 } | 110 } |
| 111 | 111 |
| 112 void MandolineUIServicesApp::Create( | 112 void MandolineUIServicesApp::Create( |
| 113 ApplicationConnection* connection, | 113 ApplicationConnection* connection, |
| 114 InterfaceRequest<ViewTreeHostFactory> request) { | 114 InterfaceRequest<WindowTreeHostFactory> request) { |
| 115 factory_bindings_.AddBinding(this, request.Pass()); | 115 factory_bindings_.AddBinding(this, request.Pass()); |
| 116 } | 116 } |
| 117 | 117 |
| 118 void MandolineUIServicesApp::Create(mojo::ApplicationConnection* connection, | 118 void MandolineUIServicesApp::Create(mojo::ApplicationConnection* connection, |
| 119 mojo::InterfaceRequest<Gpu> request) { | 119 mojo::InterfaceRequest<Gpu> request) { |
| 120 if (!gpu_state_.get()) | 120 if (!gpu_state_.get()) |
| 121 gpu_state_ = new GpuState; | 121 gpu_state_ = new GpuState; |
| 122 new GpuImpl(request.Pass(), gpu_state_); | 122 new GpuImpl(request.Pass(), gpu_state_); |
| 123 } | 123 } |
| 124 | 124 |
| 125 void MandolineUIServicesApp::CreateWindowTreeHost( | 125 void MandolineUIServicesApp::CreateWindowTreeHost( |
| 126 mojo::InterfaceRequest<mojo::ViewTreeHost> host, | 126 mojo::InterfaceRequest<mojom::WindowTreeHost> host, |
| 127 mojo::ViewTreeHostClientPtr host_client, | 127 mojom::WindowTreeHostClientPtr host_client, |
| 128 mojo::ViewTreeClientPtr tree_client) { | 128 mojom::WindowTreeClientPtr tree_client) { |
| 129 DCHECK(connection_manager_.get()); | 129 DCHECK(connection_manager_.get()); |
| 130 | 130 |
| 131 // TODO(fsamuel): We need to make sure that only the window manager can create | 131 // TODO(fsamuel): We need to make sure that only the window manager can create |
| 132 // new roots. | 132 // new roots. |
| 133 ViewTreeHostImpl* host_impl = new ViewTreeHostImpl( | 133 ViewTreeHostImpl* host_impl = new ViewTreeHostImpl( |
| 134 host_client.Pass(), connection_manager_.get(), app_impl_, | 134 host_client.Pass(), connection_manager_.get(), app_impl_, |
| 135 gpu_state_, surfaces_state_); | 135 gpu_state_, surfaces_state_); |
| 136 | 136 |
| 137 // ViewTreeHostConnection manages its own lifetime. | 137 // ViewTreeHostConnection manages its own lifetime. |
| 138 host_impl->Init(new ViewTreeHostConnectionImpl( | 138 host_impl->Init(new ViewTreeHostConnectionImpl( |
| 139 host.Pass(), make_scoped_ptr(host_impl), tree_client.Pass(), | 139 host.Pass(), make_scoped_ptr(host_impl), tree_client.Pass(), |
| 140 connection_manager_.get())); | 140 connection_manager_.get())); |
| 141 } | 141 } |
| 142 | 142 |
| 143 } // namespace mus | 143 } // namespace mus |
| OLD | NEW |