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/delegated_output_surface.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 "cc/output/compositor_frame.h" | 13 #include "cc/output/compositor_frame.h" |
14 #include "cc/output/output_surface_client.h" | |
15 #include "cc/scheduler/begin_frame_source.h" | |
16 #include "cc/scheduler/delay_based_time_source.h" | |
13 | 17 |
14 namespace blimp { | 18 namespace blimp { |
15 namespace client { | 19 namespace client { |
16 | 20 |
17 DelegatedOutputSurface::DelegatedOutputSurface( | 21 DelegatedOutputSurface::DelegatedOutputSurface( |
18 scoped_refptr<cc::ContextProvider> compositor_context_provider, | 22 scoped_refptr<cc::ContextProvider> compositor_context_provider, |
19 scoped_refptr<cc::ContextProvider> worker_context_provider, | 23 scoped_refptr<cc::ContextProvider> worker_context_provider, |
20 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, | 24 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
21 base::WeakPtr<BlimpOutputSurfaceClient> client) | 25 base::WeakPtr<BlimpOutputSurfaceClient> client) |
22 : cc::OutputSurface(std::move(compositor_context_provider), | 26 : cc::OutputSurface(std::move(compositor_context_provider), |
(...skipping 16 matching lines...) Expand all Loading... | |
39 } | 43 } |
40 | 44 |
41 uint32_t DelegatedOutputSurface::GetFramebufferCopyTextureFormat() { | 45 uint32_t DelegatedOutputSurface::GetFramebufferCopyTextureFormat() { |
42 NOTREACHED() << "Should not be called on delegated output surface"; | 46 NOTREACHED() << "Should not be called on delegated output surface"; |
43 return 0; | 47 return 0; |
44 } | 48 } |
45 | 49 |
46 bool DelegatedOutputSurface::BindToClient(cc::OutputSurfaceClient* client) { | 50 bool DelegatedOutputSurface::BindToClient(cc::OutputSurfaceClient* client) { |
47 bool success = cc::OutputSurface::BindToClient(client); | 51 bool success = cc::OutputSurface::BindToClient(client); |
48 if (success) { | 52 if (success) { |
53 begin_frame_source_ = base::MakeUnique<cc::DelayBasedBeginFrameSource>( | |
54 base::MakeUnique<cc::DelayBasedTimeSource>( | |
55 base::ThreadTaskRunnerHandle::Get().get())); | |
56 client->SetBeginFrameSource(begin_frame_source_.get()); | |
Khushal
2016/09/03 16:04:31
Woops. Also destroy the |begin_frame_source_| and
| |
57 | |
49 main_task_runner_->PostTask( | 58 main_task_runner_->PostTask( |
50 FROM_HERE, base::Bind(&BlimpOutputSurfaceClient::BindToOutputSurface, | 59 FROM_HERE, base::Bind(&BlimpOutputSurfaceClient::BindToOutputSurface, |
51 client_, weak_factory_.GetWeakPtr())); | 60 client_, weak_factory_.GetWeakPtr())); |
52 } | 61 } |
53 return success; | 62 return success; |
54 } | 63 } |
55 | 64 |
56 void DelegatedOutputSurface::SwapBuffers(cc::CompositorFrame frame) { | 65 void DelegatedOutputSurface::SwapBuffers(cc::CompositorFrame frame) { |
57 DCHECK(client_thread_checker_.CalledOnValidThread()); | 66 DCHECK(client_thread_checker_.CalledOnValidThread()); |
58 | 67 |
(...skipping 11 matching lines...) Expand all Loading... | |
70 main_task_runner_->PostTask( | 79 main_task_runner_->PostTask( |
71 FROM_HERE, | 80 FROM_HERE, |
72 base::Bind(&BlimpOutputSurfaceClient::UnbindOutputSurface, client_)); | 81 base::Bind(&BlimpOutputSurfaceClient::UnbindOutputSurface, client_)); |
73 } | 82 } |
74 | 83 |
75 weak_factory_.InvalidateWeakPtrs(); | 84 weak_factory_.InvalidateWeakPtrs(); |
76 } | 85 } |
77 | 86 |
78 } // namespace client | 87 } // namespace client |
79 } // namespace blimp | 88 } // namespace blimp |
OLD | NEW |