OLD | NEW |
---|---|
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/viz/client/client_compositor_frame_sink.h" | 5 #include "components/viz/client/client_compositor_frame_sink.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
9 #include "cc/output/begin_frame_args.h" | 9 #include "cc/output/begin_frame_args.h" |
10 #include "cc/output/compositor_frame.h" | 10 #include "cc/output/compositor_frame.h" |
11 #include "cc/output/compositor_frame_sink_client.h" | 11 #include "cc/output/compositor_frame_sink_client.h" |
12 | 12 |
13 namespace viz { | 13 namespace viz { |
14 | 14 |
15 ClientCompositorFrameSink::ClientCompositorFrameSink( | 15 ClientCompositorFrameSink::ClientCompositorFrameSink( |
16 scoped_refptr<cc::ContextProvider> context_provider, | 16 scoped_refptr<cc::ContextProvider> context_provider, |
17 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, | 17 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, |
18 cc::mojom::MojoCompositorFrameSinkPtrInfo compositor_frame_sink_info, | 18 cc::mojom::MojoCompositorFrameSinkPtrInfo compositor_frame_sink_info, |
19 cc::mojom::MojoCompositorFrameSinkClientRequest client_request, | 19 cc::mojom::MojoCompositorFrameSinkClientRequest client_request, |
20 bool enable_surface_synchronization) | 20 bool enable_surface_synchronization) |
21 : cc::CompositorFrameSink(std::move(context_provider), | 21 : cc::CompositorFrameSink(std::move(context_provider), |
22 nullptr, | 22 nullptr, |
23 gpu_memory_buffer_manager, | 23 gpu_memory_buffer_manager, |
24 nullptr), | 24 nullptr), |
25 compositor_frame_sink_info_(std::move(compositor_frame_sink_info)), | 25 compositor_frame_sink_info_(std::move(compositor_frame_sink_info)), |
26 client_request_(std::move(client_request)), | 26 client_request_(std::move(client_request)), |
27 enable_surface_synchronization_(enable_surface_synchronization) { | 27 enable_surface_synchronization_(enable_surface_synchronization), |
28 weak_factory_(this) { | |
28 DETACH_FROM_THREAD(thread_checker_); | 29 DETACH_FROM_THREAD(thread_checker_); |
29 } | 30 } |
30 | 31 |
31 ClientCompositorFrameSink::~ClientCompositorFrameSink() {} | 32 ClientCompositorFrameSink::~ClientCompositorFrameSink() {} |
32 | 33 |
34 base::WeakPtr<ClientCompositorFrameSink> | |
35 ClientCompositorFrameSink::GetWeakPtr() { | |
Fady Samuel
2017/06/07 17:36:26
DCHECK_CALLED_ON_VALID_THREAD too?
Peng
2017/06/07 19:30:29
Done.
| |
36 return weak_factory_.GetWeakPtr(); | |
37 } | |
38 | |
33 bool ClientCompositorFrameSink::BindToClient( | 39 bool ClientCompositorFrameSink::BindToClient( |
34 cc::CompositorFrameSinkClient* client) { | 40 cc::CompositorFrameSinkClient* client) { |
35 if (!cc::CompositorFrameSink::BindToClient(client)) | 41 if (!cc::CompositorFrameSink::BindToClient(client)) |
36 return false; | 42 return false; |
37 | 43 |
38 DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); | 44 DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); |
39 compositor_frame_sink_.Bind(std::move(compositor_frame_sink_info_)); | 45 compositor_frame_sink_.Bind(std::move(compositor_frame_sink_info_)); |
40 client_binding_.reset( | 46 client_binding_.reset( |
41 new mojo::Binding<cc::mojom::MojoCompositorFrameSinkClient>( | 47 new mojo::Binding<cc::mojom::MojoCompositorFrameSinkClient>( |
42 this, std::move(client_request_))); | 48 this, std::move(client_request_))); |
43 | 49 |
44 begin_frame_source_ = base::MakeUnique<cc::ExternalBeginFrameSource>(this); | 50 begin_frame_source_ = base::MakeUnique<cc::ExternalBeginFrameSource>(this); |
45 | 51 |
46 client->SetBeginFrameSource(begin_frame_source_.get()); | 52 client->SetBeginFrameSource(begin_frame_source_.get()); |
47 return true; | 53 return true; |
48 } | 54 } |
49 | 55 |
50 void ClientCompositorFrameSink::DetachFromClient() { | 56 void ClientCompositorFrameSink::DetachFromClient() { |
51 client_->SetBeginFrameSource(nullptr); | 57 client_->SetBeginFrameSource(nullptr); |
52 begin_frame_source_.reset(); | 58 begin_frame_source_.reset(); |
53 client_binding_.reset(); | 59 client_binding_.reset(); |
54 compositor_frame_sink_.reset(); | 60 compositor_frame_sink_.reset(); |
55 cc::CompositorFrameSink::DetachFromClient(); | 61 cc::CompositorFrameSink::DetachFromClient(); |
56 } | 62 } |
57 | 63 |
58 void ClientCompositorFrameSink::SetLocalSurfaceId( | 64 void ClientCompositorFrameSink::SetLocalSurfaceId( |
59 const cc::LocalSurfaceId& local_surface_id) { | 65 const cc::LocalSurfaceId& local_surface_id) { |
66 DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); | |
60 DCHECK(local_surface_id.is_valid()); | 67 DCHECK(local_surface_id.is_valid()); |
61 DCHECK(enable_surface_synchronization_); | 68 DCHECK(enable_surface_synchronization_); |
62 local_surface_id_ = local_surface_id; | 69 local_surface_id_ = local_surface_id; |
63 } | 70 } |
64 | 71 |
65 void ClientCompositorFrameSink::SubmitCompositorFrame( | 72 void ClientCompositorFrameSink::SubmitCompositorFrame( |
66 cc::CompositorFrame frame) { | 73 cc::CompositorFrame frame) { |
67 DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); | 74 DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); |
68 if (!compositor_frame_sink_) | 75 if (!compositor_frame_sink_) |
69 return; | 76 return; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
110 if (!client_) | 117 if (!client_) |
111 return; | 118 return; |
112 client_->ReclaimResources(resources); | 119 client_->ReclaimResources(resources); |
113 } | 120 } |
114 | 121 |
115 void ClientCompositorFrameSink::OnNeedsBeginFrames(bool needs_begin_frames) { | 122 void ClientCompositorFrameSink::OnNeedsBeginFrames(bool needs_begin_frames) { |
116 compositor_frame_sink_->SetNeedsBeginFrame(needs_begin_frames); | 123 compositor_frame_sink_->SetNeedsBeginFrame(needs_begin_frames); |
117 } | 124 } |
118 | 125 |
119 } // namespace viz | 126 } // namespace viz |
OLD | NEW |