OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "blimp/client/core/compositor/delegated_output_surface.h" | 5 #include "blimp/client/core/compositor/blimp_compositor_frame_sink.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
11 #include "base/threading/thread_checker.h" | 11 #include "base/threading/thread_checker.h" |
12 #include "base/threading/thread_task_runner_handle.h" | 12 #include "base/threading/thread_task_runner_handle.h" |
13 #include "cc/output/compositor_frame.h" | 13 #include "cc/output/compositor_frame.h" |
14 #include "cc/output/output_surface_client.h" | 14 #include "cc/output/compositor_frame_sink_client.h" |
15 #include "cc/scheduler/begin_frame_source.h" | 15 #include "cc/scheduler/begin_frame_source.h" |
16 #include "cc/scheduler/delay_based_time_source.h" | 16 #include "cc/scheduler/delay_based_time_source.h" |
17 | 17 |
18 namespace blimp { | 18 namespace blimp { |
19 namespace client { | 19 namespace client { |
20 | 20 |
21 DelegatedOutputSurface::DelegatedOutputSurface( | 21 BlimpCompositorFrameSink::BlimpCompositorFrameSink( |
22 scoped_refptr<cc::ContextProvider> compositor_context_provider, | 22 scoped_refptr<cc::ContextProvider> compositor_context_provider, |
23 scoped_refptr<cc::ContextProvider> worker_context_provider, | 23 scoped_refptr<cc::ContextProvider> worker_context_provider, |
24 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, | 24 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
25 base::WeakPtr<BlimpOutputSurfaceClient> client) | 25 base::WeakPtr<BlimpCompositorFrameSinkProxy> main_thread_proxy) |
26 : cc::OutputSurface(std::move(compositor_context_provider), | 26 : cc::CompositorFrameSink(std::move(compositor_context_provider), |
27 std::move(worker_context_provider), | 27 std::move(worker_context_provider), |
28 nullptr), | 28 nullptr), |
29 main_task_runner_(std::move(main_task_runner)), | 29 main_task_runner_(std::move(main_task_runner)), |
30 blimp_client_(client), | 30 main_thread_proxy_(main_thread_proxy), |
31 bound_to_client_(false), | 31 bound_to_client_(false), |
32 weak_factory_(this) { | 32 weak_factory_(this) { |
33 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 33 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
34 capabilities_.delegated_rendering = true; | 34 capabilities_.delegated_rendering = true; |
35 } | 35 } |
36 | 36 |
37 DelegatedOutputSurface::~DelegatedOutputSurface() = default; | 37 BlimpCompositorFrameSink::~BlimpCompositorFrameSink() = default; |
38 | 38 |
39 void DelegatedOutputSurface::ReclaimCompositorResources( | 39 void BlimpCompositorFrameSink::ReclaimCompositorResources( |
40 const cc::ReturnedResourceArray& resources) { | 40 const cc::ReturnedResourceArray& resources) { |
41 DCHECK(client_thread_checker_.CalledOnValidThread()); | 41 DCHECK(client_thread_checker_.CalledOnValidThread()); |
42 client_->ReclaimResources(resources); | 42 client_->ReclaimResources(resources); |
43 } | 43 } |
44 | 44 |
45 uint32_t DelegatedOutputSurface::GetFramebufferCopyTextureFormat() { | 45 uint32_t BlimpCompositorFrameSink::GetFramebufferCopyTextureFormat() { |
46 NOTREACHED() << "Should not be called on delegated output surface"; | 46 NOTREACHED() << "Should not be called on delegated output surface"; |
47 return 0; | 47 return 0; |
48 } | 48 } |
49 | 49 |
50 bool DelegatedOutputSurface::BindToClient(cc::OutputSurfaceClient* client) { | 50 bool BlimpCompositorFrameSink::BindToClient( |
51 bool success = cc::OutputSurface::BindToClient(client); | 51 cc::CompositorFrameSinkClient* client) { |
| 52 bool success = cc::CompositorFrameSink::BindToClient(client); |
52 if (success) { | 53 if (success) { |
53 begin_frame_source_ = base::MakeUnique<cc::DelayBasedBeginFrameSource>( | 54 begin_frame_source_ = base::MakeUnique<cc::DelayBasedBeginFrameSource>( |
54 base::MakeUnique<cc::DelayBasedTimeSource>( | 55 base::MakeUnique<cc::DelayBasedTimeSource>( |
55 base::ThreadTaskRunnerHandle::Get().get())); | 56 base::ThreadTaskRunnerHandle::Get().get())); |
56 client->SetBeginFrameSource(begin_frame_source_.get()); | 57 client->SetBeginFrameSource(begin_frame_source_.get()); |
57 | 58 |
58 main_task_runner_->PostTask( | 59 main_task_runner_->PostTask( |
59 FROM_HERE, base::Bind(&BlimpOutputSurfaceClient::BindToOutputSurface, | 60 FROM_HERE, base::Bind(&BlimpCompositorFrameSinkProxy::BindToProxyClient, |
60 blimp_client_, weak_factory_.GetWeakPtr())); | 61 main_thread_proxy_, weak_factory_.GetWeakPtr())); |
61 } | 62 } |
62 return success; | 63 return success; |
63 } | 64 } |
64 | 65 |
65 void DelegatedOutputSurface::SwapBuffers(cc::CompositorFrame frame) { | 66 void BlimpCompositorFrameSink::SwapBuffers(cc::CompositorFrame frame) { |
66 DCHECK(client_thread_checker_.CalledOnValidThread()); | 67 DCHECK(client_thread_checker_.CalledOnValidThread()); |
67 | 68 |
68 main_task_runner_->PostTask( | 69 main_task_runner_->PostTask( |
69 FROM_HERE, base::Bind(&BlimpOutputSurfaceClient::SwapCompositorFrame, | 70 FROM_HERE, base::Bind(&BlimpCompositorFrameSinkProxy::SwapCompositorFrame, |
70 blimp_client_, base::Passed(&frame))); | 71 main_thread_proxy_, base::Passed(&frame))); |
71 cc::OutputSurface::PostSwapBuffersComplete(); | 72 cc::CompositorFrameSink::PostSwapBuffersComplete(); |
72 } | 73 } |
73 | 74 |
74 void DelegatedOutputSurface::DetachFromClient() { | 75 void BlimpCompositorFrameSink::DetachFromClient() { |
75 cc::OutputSurface::DetachFromClient(); | 76 cc::CompositorFrameSink::DetachFromClient(); |
76 | 77 |
77 if (bound_to_client_ == true) { | 78 if (bound_to_client_ == true) { |
78 bound_to_client_ = false; | 79 bound_to_client_ = false; |
79 main_task_runner_->PostTask( | 80 main_task_runner_->PostTask( |
80 FROM_HERE, base::Bind(&BlimpOutputSurfaceClient::UnbindOutputSurface, | 81 FROM_HERE, base::Bind(&BlimpCompositorFrameSinkProxy::UnbindProxyClient, |
81 blimp_client_)); | 82 main_thread_proxy_)); |
82 } | 83 } |
83 | 84 |
84 weak_factory_.InvalidateWeakPtrs(); | 85 weak_factory_.InvalidateWeakPtrs(); |
85 } | 86 } |
86 | 87 |
87 } // namespace client | 88 } // namespace client |
88 } // namespace blimp | 89 } // namespace blimp |
OLD | NEW |