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