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" |
(...skipping 14 matching lines...) Expand all Loading... |
25 bool enable_surface_synchronization) | 25 bool enable_surface_synchronization) |
26 : cc::CompositorFrameSink(std::move(context_provider), | 26 : cc::CompositorFrameSink(std::move(context_provider), |
27 std::move(worker_context_provider), | 27 std::move(worker_context_provider), |
28 gpu_memory_buffer_manager, | 28 gpu_memory_buffer_manager, |
29 shared_bitmap_manager), | 29 shared_bitmap_manager), |
30 local_surface_id_provider_(std::move(local_surface_id_provider)), | 30 local_surface_id_provider_(std::move(local_surface_id_provider)), |
31 synthetic_begin_frame_source_(std::move(synthetic_begin_frame_source)), | 31 synthetic_begin_frame_source_(std::move(synthetic_begin_frame_source)), |
32 compositor_frame_sink_info_(std::move(compositor_frame_sink_info)), | 32 compositor_frame_sink_info_(std::move(compositor_frame_sink_info)), |
33 client_request_(std::move(client_request)), | 33 client_request_(std::move(client_request)), |
34 client_binding_(this), | 34 client_binding_(this), |
35 enable_surface_synchronization_(enable_surface_synchronization) { | 35 enable_surface_synchronization_(enable_surface_synchronization), |
| 36 weak_factory_(this) { |
36 DETACH_FROM_THREAD(thread_checker_); | 37 DETACH_FROM_THREAD(thread_checker_); |
37 } | 38 } |
38 | 39 |
39 ClientCompositorFrameSink::ClientCompositorFrameSink( | 40 ClientCompositorFrameSink::ClientCompositorFrameSink( |
40 scoped_refptr<cc::VulkanContextProvider> vulkan_context_provider, | 41 scoped_refptr<cc::VulkanContextProvider> vulkan_context_provider, |
41 std::unique_ptr<cc::SyntheticBeginFrameSource> synthetic_begin_frame_source, | 42 std::unique_ptr<cc::SyntheticBeginFrameSource> synthetic_begin_frame_source, |
42 cc::mojom::MojoCompositorFrameSinkPtrInfo compositor_frame_sink_info, | 43 cc::mojom::MojoCompositorFrameSinkPtrInfo compositor_frame_sink_info, |
43 cc::mojom::MojoCompositorFrameSinkClientRequest client_request, | 44 cc::mojom::MojoCompositorFrameSinkClientRequest client_request, |
44 std::unique_ptr<LocalSurfaceIdProvider> local_surface_id_provider, | 45 std::unique_ptr<LocalSurfaceIdProvider> local_surface_id_provider, |
45 bool enable_surface_synchronization) | 46 bool enable_surface_synchronization) |
46 : cc::CompositorFrameSink(std::move(vulkan_context_provider)), | 47 : cc::CompositorFrameSink(std::move(vulkan_context_provider)), |
47 local_surface_id_provider_(std::move(local_surface_id_provider)), | 48 local_surface_id_provider_(std::move(local_surface_id_provider)), |
48 synthetic_begin_frame_source_(std::move(synthetic_begin_frame_source)), | 49 synthetic_begin_frame_source_(std::move(synthetic_begin_frame_source)), |
49 compositor_frame_sink_info_(std::move(compositor_frame_sink_info)), | 50 compositor_frame_sink_info_(std::move(compositor_frame_sink_info)), |
50 client_request_(std::move(client_request)), | 51 client_request_(std::move(client_request)), |
51 client_binding_(this), | 52 client_binding_(this), |
52 enable_surface_synchronization_(enable_surface_synchronization) { | 53 enable_surface_synchronization_(enable_surface_synchronization), |
| 54 weak_factory_(this) { |
53 DETACH_FROM_THREAD(thread_checker_); | 55 DETACH_FROM_THREAD(thread_checker_); |
54 } | 56 } |
55 | 57 |
56 ClientCompositorFrameSink::~ClientCompositorFrameSink() {} | 58 ClientCompositorFrameSink::~ClientCompositorFrameSink() {} |
57 | 59 |
| 60 base::WeakPtr<ClientCompositorFrameSink> |
| 61 ClientCompositorFrameSink::GetWeakPtr() { |
| 62 DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); |
| 63 return weak_factory_.GetWeakPtr(); |
| 64 } |
| 65 |
58 bool ClientCompositorFrameSink::BindToClient( | 66 bool ClientCompositorFrameSink::BindToClient( |
59 cc::CompositorFrameSinkClient* client) { | 67 cc::CompositorFrameSinkClient* client) { |
60 DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); | 68 DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); |
61 | 69 |
62 if (!cc::CompositorFrameSink::BindToClient(client)) | 70 if (!cc::CompositorFrameSink::BindToClient(client)) |
63 return false; | 71 return false; |
64 | 72 |
65 compositor_frame_sink_.Bind(std::move(compositor_frame_sink_info_)); | 73 compositor_frame_sink_.Bind(std::move(compositor_frame_sink_info_)); |
66 client_binding_.Bind(std::move(client_request_)); | 74 client_binding_.Bind(std::move(client_request_)); |
67 | 75 |
(...skipping 12 matching lines...) Expand all Loading... |
80 client_->SetBeginFrameSource(nullptr); | 88 client_->SetBeginFrameSource(nullptr); |
81 begin_frame_source_.reset(); | 89 begin_frame_source_.reset(); |
82 synthetic_begin_frame_source_.reset(); | 90 synthetic_begin_frame_source_.reset(); |
83 client_binding_.Close(); | 91 client_binding_.Close(); |
84 compositor_frame_sink_.reset(); | 92 compositor_frame_sink_.reset(); |
85 cc::CompositorFrameSink::DetachFromClient(); | 93 cc::CompositorFrameSink::DetachFromClient(); |
86 } | 94 } |
87 | 95 |
88 void ClientCompositorFrameSink::SetLocalSurfaceId( | 96 void ClientCompositorFrameSink::SetLocalSurfaceId( |
89 const cc::LocalSurfaceId& local_surface_id) { | 97 const cc::LocalSurfaceId& local_surface_id) { |
| 98 DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); |
90 DCHECK(local_surface_id.is_valid()); | 99 DCHECK(local_surface_id.is_valid()); |
91 DCHECK(enable_surface_synchronization_); | 100 DCHECK(enable_surface_synchronization_); |
92 local_surface_id_ = local_surface_id; | 101 local_surface_id_ = local_surface_id; |
93 } | 102 } |
94 | 103 |
95 void ClientCompositorFrameSink::SubmitCompositorFrame( | 104 void ClientCompositorFrameSink::SubmitCompositorFrame( |
96 cc::CompositorFrame frame) { | 105 cc::CompositorFrame frame) { |
97 DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); | 106 DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); |
98 DCHECK(frame.metadata.begin_frame_ack.has_damage); | 107 DCHECK(frame.metadata.begin_frame_ack.has_damage); |
99 DCHECK_LE(cc::BeginFrameArgs::kStartingFrameNumber, | 108 DCHECK_LE(cc::BeginFrameArgs::kStartingFrameNumber, |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 const cc::ReturnedResourceArray& resources) { | 140 const cc::ReturnedResourceArray& resources) { |
132 DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); | 141 DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); |
133 client_->ReclaimResources(resources); | 142 client_->ReclaimResources(resources); |
134 } | 143 } |
135 | 144 |
136 void ClientCompositorFrameSink::OnNeedsBeginFrames(bool needs_begin_frames) { | 145 void ClientCompositorFrameSink::OnNeedsBeginFrames(bool needs_begin_frames) { |
137 compositor_frame_sink_->SetNeedsBeginFrame(needs_begin_frames); | 146 compositor_frame_sink_->SetNeedsBeginFrame(needs_begin_frames); |
138 } | 147 } |
139 | 148 |
140 } // namespace viz | 149 } // namespace viz |
OLD | NEW |