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" |
(...skipping 10 matching lines...) Expand all Loading... |
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::ConnectToService(service_provider.get(), &surfaces_service_); | 24 mojo::ConnectToService(service_provider.get(), &surfaces_service_); |
25 | 25 |
26 surfaces_service_->CreateSurfaceConnection(base::Bind( | 26 surfaces_service_->CreateSurfaceConnection(base::Bind( |
27 &SurfaceHolder::OnSurfaceConnectionCreated, weak_factory_.GetWeakPtr())); | 27 &SurfaceHolder::OnSurfaceConnectionCreated, weak_factory_.GetWeakPtr())); |
28 } | 28 } |
29 | 29 |
30 SurfaceHolder::~SurfaceHolder() { | 30 SurfaceHolder::~SurfaceHolder() { |
31 if (surface_id_) | 31 if (surface_ && surface_id_) |
32 surface_->DestroySurface(surface_id_.Clone()); | 32 surface_->DestroySurface(surface_id_.Clone()); |
33 } | 33 } |
34 | 34 |
| 35 bool SurfaceHolder::IsReadyForFrame() const { |
| 36 return surface_; |
| 37 } |
| 38 |
35 void SurfaceHolder::SubmitFrame(mojo::FramePtr frame) { | 39 void SurfaceHolder::SubmitFrame(mojo::FramePtr frame) { |
36 surface_->SubmitFrame(surface_id_.Clone(), frame.Pass()); | 40 surface_->SubmitFrame(surface_id_.Clone(), frame.Pass()); |
37 } | 41 } |
38 | 42 |
39 void SurfaceHolder::SetSize(const gfx::Size& size) { | 43 void SurfaceHolder::SetSize(const gfx::Size& size) { |
40 if (surface_id_ && size_ == size) | 44 if (surface_id_ && size_ == size) |
41 return; | 45 return; |
42 | 46 |
43 if (surface_id_) { | 47 if (surface_id_) { |
44 surface_->DestroySurface(surface_id_.Clone()); | 48 surface_->DestroySurface(surface_id_.Clone()); |
(...skipping 17 matching lines...) Expand all Loading... |
62 } | 66 } |
63 | 67 |
64 void SurfaceHolder::OnSurfaceConnectionCreated(mojo::SurfacePtr surface, | 68 void SurfaceHolder::OnSurfaceConnectionCreated(mojo::SurfacePtr surface, |
65 uint32_t id_namespace) { | 69 uint32_t id_namespace) { |
66 surface_ = surface.Pass(); | 70 surface_ = surface.Pass(); |
67 surface_.set_client(this); | 71 surface_.set_client(this); |
68 surface_allocator_.reset(new SurfaceAllocator(id_namespace)); | 72 surface_allocator_.reset(new SurfaceAllocator(id_namespace)); |
69 } | 73 } |
70 | 74 |
71 } // namespace sky | 75 } // namespace sky |
OLD | NEW |