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 "sky/compositor/surface_holder.h" | 5 #include "sky/compositor/surface_holder.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "mojo/converters/geometry/geometry_type_converters.h" | 9 #include "mojo/converters/geometry/geometry_type_converters.h" |
10 #include "mojo/public/cpp/application/connect.h" | 10 #include "mojo/public/cpp/application/connect.h" |
11 #include "mojo/public/interfaces/application/shell.mojom.h" | 11 #include "mojo/public/interfaces/application/shell.mojom.h" |
12 #include "sky/compositor/surface_allocator.h" | 12 #include "sky/compositor/surface_allocator.h" |
13 | 13 |
14 namespace sky { | 14 namespace sky { |
15 | 15 |
16 SurfaceHolder::Client::~Client() { | 16 SurfaceHolder::Client::~Client() { |
17 } | 17 } |
18 | 18 |
19 SurfaceHolder::SurfaceHolder(Client* client, mojo::Shell* shell) | 19 SurfaceHolder::SurfaceHolder(Client* client, mojo::Shell* shell) |
20 : client_(client), weak_factory_(this) { | 20 : client_(client), weak_factory_(this) { |
21 mojo::ServiceProviderPtr service_provider; | 21 mojo::ServiceProviderPtr service_provider; |
22 shell->ConnectToApplication("mojo:surfaces_service", | 22 shell->ConnectToApplication("mojo:surfaces_service", |
23 mojo::GetProxy(&service_provider)); | 23 mojo::GetProxy(&service_provider), |
| 24 mojo::ServiceProviderPtr()); |
24 mojo::ConnectToService(service_provider.get(), &surfaces_service_); | 25 mojo::ConnectToService(service_provider.get(), &surfaces_service_); |
25 | 26 |
26 surfaces_service_->CreateSurfaceConnection(base::Bind( | 27 surfaces_service_->CreateSurfaceConnection(base::Bind( |
27 &SurfaceHolder::OnSurfaceConnectionCreated, weak_factory_.GetWeakPtr())); | 28 &SurfaceHolder::OnSurfaceConnectionCreated, weak_factory_.GetWeakPtr())); |
28 } | 29 } |
29 | 30 |
30 SurfaceHolder::~SurfaceHolder() { | 31 SurfaceHolder::~SurfaceHolder() { |
31 if (surface_ && surface_id_) | 32 if (surface_ && surface_id_) |
32 surface_->DestroySurface(surface_id_.Clone()); | 33 surface_->DestroySurface(surface_id_.Clone()); |
33 } | 34 } |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 | 72 |
72 void SurfaceHolder::OnSurfaceConnectionCreated(mojo::SurfacePtr surface, | 73 void SurfaceHolder::OnSurfaceConnectionCreated(mojo::SurfacePtr surface, |
73 uint32_t id_namespace) { | 74 uint32_t id_namespace) { |
74 surface_ = surface.Pass(); | 75 surface_ = surface.Pass(); |
75 surface_.set_client(this); | 76 surface_.set_client(this); |
76 surface_allocator_.reset(new SurfaceAllocator(id_namespace)); | 77 surface_allocator_.reset(new SurfaceAllocator(id_namespace)); |
77 client_->OnSurfaceConnectionCreated(); | 78 client_->OnSurfaceConnectionCreated(); |
78 } | 79 } |
79 | 80 |
80 } // namespace sky | 81 } // namespace sky |
OLD | NEW |