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 "services/ui/public/cpp/window_surface.h" | 5 #include "services/ui/public/cpp/window_surface.h" |
6 | 6 |
7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
8 #include "services/ui/public/cpp/window_surface_client.h" | 8 #include "services/ui/public/cpp/window_surface_client.h" |
9 | 9 |
10 namespace ui { | 10 namespace ui { |
11 | 11 |
12 // static | 12 // static |
13 std::unique_ptr<WindowSurface> WindowSurface::Create( | 13 std::unique_ptr<WindowSurface> WindowSurface::Create( |
14 std::unique_ptr<WindowSurfaceBinding>* surface_binding) { | 14 std::unique_ptr<WindowSurfaceBinding>* surface_binding) { |
15 mojom::SurfacePtr surface; | 15 cc::mojom::MojoCompositorFrameSinkPtr surface; |
16 mojom::SurfaceClientPtr surface_client; | 16 cc::mojom::MojoCompositorFrameSinkClientPtr surface_client; |
17 mojo::InterfaceRequest<mojom::SurfaceClient> surface_client_request = | 17 mojo::InterfaceRequest<cc::mojom::MojoCompositorFrameSinkClient> |
18 GetProxy(&surface_client); | 18 surface_client_request = GetProxy(&surface_client); |
19 | 19 |
20 surface_binding->reset(new WindowSurfaceBinding( | 20 surface_binding->reset(new WindowSurfaceBinding( |
21 GetProxy(&surface), surface_client.PassInterface())); | 21 GetProxy(&surface), surface_client.PassInterface())); |
22 return base::WrapUnique(new WindowSurface(surface.PassInterface(), | 22 return base::WrapUnique(new WindowSurface(surface.PassInterface(), |
23 std::move(surface_client_request))); | 23 std::move(surface_client_request))); |
24 } | 24 } |
25 | 25 |
26 WindowSurface::~WindowSurface() {} | 26 WindowSurface::~WindowSurface() {} |
27 | 27 |
28 void WindowSurface::BindToThread() { | 28 void WindowSurface::BindToThread() { |
29 DCHECK(!thread_checker_); | 29 DCHECK(!thread_checker_); |
30 thread_checker_.reset(new base::ThreadChecker()); | 30 thread_checker_.reset(new base::ThreadChecker()); |
31 surface_.Bind(std::move(surface_info_)); | 31 surface_.Bind(std::move(surface_info_)); |
32 client_binding_.reset(new mojo::Binding<mojom::SurfaceClient>( | 32 client_binding_.reset( |
33 this, std::move(client_request_))); | 33 new mojo::Binding<cc::mojom::MojoCompositorFrameSinkClient>( |
| 34 this, std::move(client_request_))); |
34 } | 35 } |
35 | 36 |
36 void WindowSurface::SubmitCompositorFrame(cc::CompositorFrame frame, | 37 void WindowSurface::SubmitCompositorFrame(cc::CompositorFrame frame) { |
37 const base::Closure& callback) { | |
38 DCHECK(thread_checker_); | 38 DCHECK(thread_checker_); |
39 DCHECK(thread_checker_->CalledOnValidThread()); | 39 DCHECK(thread_checker_->CalledOnValidThread()); |
40 if (!surface_) | 40 if (!surface_) |
41 return; | 41 return; |
42 surface_->SubmitCompositorFrame(std::move(frame), callback); | 42 surface_->SubmitCompositorFrame(std::move(frame)); |
43 } | 43 } |
44 | 44 |
45 WindowSurface::WindowSurface( | 45 WindowSurface::WindowSurface( |
46 mojo::InterfacePtrInfo<mojom::Surface> surface_info, | 46 mojo::InterfacePtrInfo<cc::mojom::MojoCompositorFrameSink> surface_info, |
47 mojo::InterfaceRequest<mojom::SurfaceClient> client_request) | 47 mojo::InterfaceRequest<cc::mojom::MojoCompositorFrameSinkClient> |
| 48 client_request) |
48 : client_(nullptr), | 49 : client_(nullptr), |
49 surface_info_(std::move(surface_info)), | 50 surface_info_(std::move(surface_info)), |
50 client_request_(std::move(client_request)) {} | 51 client_request_(std::move(client_request)) {} |
51 | 52 |
52 void WindowSurface::ReturnResources( | 53 void WindowSurface::DidReceiveCompositorFrameAck() { |
| 54 DCHECK(thread_checker_); |
| 55 DCHECK(thread_checker_->CalledOnValidThread()); |
| 56 if (!client_) |
| 57 return; |
| 58 client_->DidReceiveCompositorFrameAck(); |
| 59 } |
| 60 |
| 61 void WindowSurface::ReclaimResources( |
53 const cc::ReturnedResourceArray& resources) { | 62 const cc::ReturnedResourceArray& resources) { |
54 DCHECK(thread_checker_); | 63 DCHECK(thread_checker_); |
55 DCHECK(thread_checker_->CalledOnValidThread()); | 64 DCHECK(thread_checker_->CalledOnValidThread()); |
56 if (!client_) | 65 if (!client_) |
57 return; | 66 return; |
58 client_->OnResourcesReturned(this, std::move(resources)); | 67 client_->ReclaimResources(std::move(resources)); |
59 } | 68 } |
60 | 69 |
61 WindowSurfaceBinding::~WindowSurfaceBinding() {} | 70 WindowSurfaceBinding::~WindowSurfaceBinding() {} |
62 | 71 |
63 WindowSurfaceBinding::WindowSurfaceBinding( | 72 WindowSurfaceBinding::WindowSurfaceBinding( |
64 mojo::InterfaceRequest<mojom::Surface> surface_request, | 73 mojo::InterfaceRequest<cc::mojom::MojoCompositorFrameSink> surface_request, |
65 mojo::InterfacePtrInfo<mojom::SurfaceClient> surface_client) | 74 mojo::InterfacePtrInfo<cc::mojom::MojoCompositorFrameSinkClient> |
| 75 surface_client) |
66 : surface_request_(std::move(surface_request)), | 76 : surface_request_(std::move(surface_request)), |
67 surface_client_(std::move(surface_client)) {} | 77 surface_client_(std::move(surface_client)) {} |
68 | 78 |
69 } // namespace ui | 79 } // namespace ui |
OLD | NEW |