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