| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/public/cpp/window_surface.h" | 5 #include "components/mus/public/cpp/window_surface.h" |
| 6 | 6 |
| 7 #include "components/mus/public/cpp/window_surface_client.h" | 7 #include "components/mus/public/cpp/window_surface_client.h" |
| 8 #include "mojo/converters/surfaces/surfaces_type_converters.h" | 8 #include "mojo/converters/surfaces/surfaces_type_converters.h" |
| 9 | 9 |
| 10 namespace mus { | 10 namespace mus { |
| 11 | 11 |
| 12 WindowSurface::~WindowSurface() {} | 12 WindowSurface::~WindowSurface() {} |
| 13 | 13 |
| 14 void WindowSurface::BindToThread() { | 14 void WindowSurface::BindToThread() { |
| 15 DCHECK(!bound_to_thread_); | 15 DCHECK(!bound_to_thread_); |
| 16 bound_to_thread_ = true; | 16 bound_to_thread_ = true; |
| 17 surface_.Bind(surface_info_.Pass()); | 17 surface_.Bind(surface_info_.Pass()); |
| 18 client_binding_.reset( | 18 client_binding_.reset( |
| 19 new mojo::Binding<mojo::SurfaceClient>(this, client_request_.Pass())); | 19 new mojo::Binding<mojom::SurfaceClient>(this, client_request_.Pass())); |
| 20 } | 20 } |
| 21 | 21 |
| 22 void WindowSurface::SubmitCompositorFrame(mojo::CompositorFramePtr frame, | 22 void WindowSurface::SubmitCompositorFrame(mojom::CompositorFramePtr frame, |
| 23 const mojo::Closure& callback) { | 23 const mojo::Closure& callback) { |
| 24 DCHECK(bound_to_thread_); | 24 DCHECK(bound_to_thread_); |
| 25 if (!surface_) | 25 if (!surface_) |
| 26 return; | 26 return; |
| 27 surface_->SubmitCompositorFrame(frame.Pass(), callback); | 27 surface_->SubmitCompositorFrame(frame.Pass(), callback); |
| 28 } | 28 } |
| 29 | 29 |
| 30 WindowSurface::WindowSurface( | 30 WindowSurface::WindowSurface( |
| 31 mojo::InterfacePtrInfo<mojo::Surface> surface_info, | 31 mojo::InterfacePtrInfo<mojom::Surface> surface_info, |
| 32 mojo::InterfaceRequest<mojo::SurfaceClient> client_request) | 32 mojo::InterfaceRequest<mojom::SurfaceClient> client_request) |
| 33 : client_(nullptr), | 33 : client_(nullptr), |
| 34 surface_info_(surface_info.Pass()), | 34 surface_info_(surface_info.Pass()), |
| 35 client_request_(client_request.Pass()), | 35 client_request_(client_request.Pass()), |
| 36 bound_to_thread_(false) {} | 36 bound_to_thread_(false) {} |
| 37 | 37 |
| 38 void WindowSurface::ReturnResources( | 38 void WindowSurface::ReturnResources( |
| 39 mojo::Array<mojo::ReturnedResourcePtr> resources) { | 39 mojo::Array<mojom::ReturnedResourcePtr> resources) { |
| 40 if (!client_) | 40 if (!client_) |
| 41 return; | 41 return; |
| 42 client_->OnResourcesReturned(this, resources.Pass()); | 42 client_->OnResourcesReturned(this, resources.Pass()); |
| 43 } | 43 } |
| 44 | 44 |
| 45 } // namespace mus | 45 } // namespace mus |
| OLD | NEW |