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 "mojo/aura/surface_binding.h" | 5 #include "mojo/aura/surface_binding.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 delete view_map; | 200 delete view_map; |
201 view_states.Pointer()->Set(nullptr); | 201 view_states.Pointer()->Set(nullptr); |
202 } | 202 } |
203 } | 203 } |
204 | 204 |
205 void SurfaceBinding::PerViewManagerState::Init() { | 205 void SurfaceBinding::PerViewManagerState::Init() { |
206 DCHECK(!surfaces_service_.get()); | 206 DCHECK(!surfaces_service_.get()); |
207 | 207 |
208 ServiceProviderPtr surfaces_service_provider; | 208 ServiceProviderPtr surfaces_service_provider; |
209 shell_->ConnectToApplication("mojo:surfaces_service", | 209 shell_->ConnectToApplication("mojo:surfaces_service", |
210 GetProxy(&surfaces_service_provider)); | 210 GetProxy(&surfaces_service_provider), |
| 211 ServiceProviderPtr()); |
211 ConnectToService(surfaces_service_provider.get(), &surfaces_service_); | 212 ConnectToService(surfaces_service_provider.get(), &surfaces_service_); |
212 // base::Unretained is ok here as we block until the call is received. | 213 // base::Unretained is ok here as we block until the call is received. |
213 surfaces_service_->CreateSurfaceConnection( | 214 surfaces_service_->CreateSurfaceConnection( |
214 base::Bind(&PerViewManagerState::OnCreatedSurfaceConnection, | 215 base::Bind(&PerViewManagerState::OnCreatedSurfaceConnection, |
215 base::Unretained(this))); | 216 base::Unretained(this))); |
216 // Block until we get the surface. This is done to make it easy for client | 217 // Block until we get the surface. This is done to make it easy for client |
217 // code. OTOH blocking is ick and leads to all sorts of problems. | 218 // code. OTOH blocking is ick and leads to all sorts of problems. |
218 // TODO(sky): ick! There needs to be a better way to deal with this. | 219 // TODO(sky): ick! There needs to be a better way to deal with this. |
219 surfaces_service_.WaitForIncomingMethodCall(); | 220 surfaces_service_.WaitForIncomingMethodCall(); |
220 DCHECK(surface_.get()); | 221 DCHECK(surface_.get()); |
221 surface_client_.reset(new SurfaceClientImpl); | 222 surface_client_.reset(new SurfaceClientImpl); |
222 surface_.set_client(surface_client_.get()); | 223 surface_.set_client(surface_client_.get()); |
223 | 224 |
224 ServiceProviderPtr gpu_service_provider; | 225 ServiceProviderPtr gpu_service_provider; |
225 // TODO(jamesr): Should be mojo:gpu_service | 226 // TODO(jamesr): Should be mojo:gpu_service |
226 shell_->ConnectToApplication("mojo:native_viewport_service", | 227 shell_->ConnectToApplication("mojo:native_viewport_service", |
227 GetProxy(&gpu_service_provider)); | 228 GetProxy(&gpu_service_provider), |
| 229 ServiceProviderPtr()); |
228 ConnectToService(gpu_service_provider.get(), &gpu_); | 230 ConnectToService(gpu_service_provider.get(), &gpu_); |
229 } | 231 } |
230 | 232 |
231 void SurfaceBinding::PerViewManagerState::OnCreatedSurfaceConnection( | 233 void SurfaceBinding::PerViewManagerState::OnCreatedSurfaceConnection( |
232 SurfacePtr surface, | 234 SurfacePtr surface, |
233 uint32_t id_namespace) { | 235 uint32_t id_namespace) { |
234 surface_id_allocator_.reset(new cc::SurfaceIdAllocator(id_namespace)); | 236 surface_id_allocator_.reset(new cc::SurfaceIdAllocator(id_namespace)); |
235 surface_ = surface.Pass(); | 237 surface_ = surface.Pass(); |
236 } | 238 } |
237 | 239 |
238 // SurfaceBinding -------------------------------------------------------------- | 240 // SurfaceBinding -------------------------------------------------------------- |
239 | 241 |
240 SurfaceBinding::SurfaceBinding(Shell* shell, View* view) | 242 SurfaceBinding::SurfaceBinding(Shell* shell, View* view) |
241 : view_(view), | 243 : view_(view), |
242 state_(PerViewManagerState::Get(shell, view->view_manager())) { | 244 state_(PerViewManagerState::Get(shell, view->view_manager())) { |
243 } | 245 } |
244 | 246 |
245 SurfaceBinding::~SurfaceBinding() { | 247 SurfaceBinding::~SurfaceBinding() { |
246 } | 248 } |
247 | 249 |
248 scoped_ptr<cc::OutputSurface> SurfaceBinding::CreateOutputSurface() { | 250 scoped_ptr<cc::OutputSurface> SurfaceBinding::CreateOutputSurface() { |
249 return state_->CreateOutputSurface(view_); | 251 return state_->CreateOutputSurface(view_); |
250 } | 252 } |
251 | 253 |
252 } // namespace mojo | 254 } // namespace mojo |
OLD | NEW |