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), id_namespace_(0u), local_id_(0u), weak_factory_(this) { | 20 : client_(client), id_namespace_(0u), local_id_(0u), 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), nullptr); |
24 mojo::ConnectToService(service_provider.get(), &surface_); | 24 mojo::ConnectToService(service_provider.get(), &surface_); |
25 surface_.set_client(this); | 25 surface_.set_client(this); |
26 } | 26 } |
27 | 27 |
28 SurfaceHolder::~SurfaceHolder() { | 28 SurfaceHolder::~SurfaceHolder() { |
29 if (local_id_ != 0u) | 29 if (local_id_ != 0u) |
30 surface_->DestroySurface(local_id_); | 30 surface_->DestroySurface(local_id_); |
31 } | 31 } |
32 | 32 |
33 void SurfaceHolder::SubmitFrame(mojo::FramePtr frame, | 33 void SurfaceHolder::SubmitFrame(mojo::FramePtr frame, |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 | 65 |
66 void SurfaceHolder::ReturnResources( | 66 void SurfaceHolder::ReturnResources( |
67 mojo::Array<mojo::ReturnedResourcePtr> resources) { | 67 mojo::Array<mojo::ReturnedResourcePtr> resources) { |
68 // TODO(abarth): The surface service shouldn't spam us with empty calls. | 68 // TODO(abarth): The surface service shouldn't spam us with empty calls. |
69 if (!resources.size()) | 69 if (!resources.size()) |
70 return; | 70 return; |
71 client_->ReturnResources(resources.Pass()); | 71 client_->ReturnResources(resources.Pass()); |
72 } | 72 } |
73 | 73 |
74 } // namespace sky | 74 } // namespace sky |
OLD | NEW |