OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "content/renderer/android/synchronous_compositor_frame_sink.h" | 5 #include "content/renderer/android/synchronous_compositor_frame_sink.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
10 #include "base/location.h" | 10 #include "base/location.h" |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 gpu_memory_buffer_manager, | 115 gpu_memory_buffer_manager, |
116 nullptr), | 116 nullptr), |
117 routing_id_(routing_id), | 117 routing_id_(routing_id), |
118 compositor_frame_sink_id_(compositor_frame_sink_id), | 118 compositor_frame_sink_id_(compositor_frame_sink_id), |
119 registry_(registry), | 119 registry_(registry), |
120 sender_(RenderThreadImpl::current()->sync_compositor_message_filter()), | 120 sender_(RenderThreadImpl::current()->sync_compositor_message_filter()), |
121 memory_policy_(0u), | 121 memory_policy_(0u), |
122 frame_swap_message_queue_(frame_swap_message_queue), | 122 frame_swap_message_queue_(frame_swap_message_queue), |
123 surface_manager_(new cc::SurfaceManager), | 123 surface_manager_(new cc::SurfaceManager), |
124 surface_id_allocator_(new cc::SurfaceIdAllocator()), | 124 surface_id_allocator_(new cc::SurfaceIdAllocator()), |
125 surface_factory_( | 125 root_factory_( |
| 126 new cc::SurfaceFactory(kFrameSinkId, surface_manager_.get(), this)), |
| 127 child_factory_( |
126 new cc::SurfaceFactory(kFrameSinkId, surface_manager_.get(), this)), | 128 new cc::SurfaceFactory(kFrameSinkId, surface_manager_.get(), this)), |
127 begin_frame_source_(std::move(begin_frame_source)) { | 129 begin_frame_source_(std::move(begin_frame_source)) { |
128 DCHECK(registry_); | 130 DCHECK(registry_); |
129 DCHECK(sender_); | 131 DCHECK(sender_); |
130 DCHECK(begin_frame_source_); | 132 DCHECK(begin_frame_source_); |
131 thread_checker_.DetachFromThread(); | 133 thread_checker_.DetachFromThread(); |
132 memory_policy_.priority_cutoff_when_visible = | 134 memory_policy_.priority_cutoff_when_visible = |
133 gpu::MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE; | 135 gpu::MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE; |
134 } | 136 } |
135 | 137 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 return true; | 193 return true; |
192 } | 194 } |
193 | 195 |
194 void SynchronousCompositorFrameSink::DetachFromClient() { | 196 void SynchronousCompositorFrameSink::DetachFromClient() { |
195 DCHECK(CalledOnValidThread()); | 197 DCHECK(CalledOnValidThread()); |
196 client_->SetBeginFrameSource(nullptr); | 198 client_->SetBeginFrameSource(nullptr); |
197 // Destroy the begin frame source on the same thread it was bound on. | 199 // Destroy the begin frame source on the same thread it was bound on. |
198 begin_frame_source_ = nullptr; | 200 begin_frame_source_ = nullptr; |
199 registry_->UnregisterCompositorFrameSink(routing_id_, this); | 201 registry_->UnregisterCompositorFrameSink(routing_id_, this); |
200 client_->SetTreeActivationCallback(base::Closure()); | 202 client_->SetTreeActivationCallback(base::Closure()); |
201 if (root_local_frame_id_.is_valid()) { | 203 root_factory_->Reset(); |
202 surface_factory_->Destroy(root_local_frame_id_); | 204 child_factory_->Reset(); |
203 surface_factory_->Destroy(child_local_frame_id_); | |
204 } | |
205 surface_manager_->UnregisterSurfaceFactoryClient(kFrameSinkId); | 205 surface_manager_->UnregisterSurfaceFactoryClient(kFrameSinkId); |
206 surface_manager_->InvalidateFrameSinkId(kFrameSinkId); | 206 surface_manager_->InvalidateFrameSinkId(kFrameSinkId); |
207 software_output_surface_ = nullptr; | 207 software_output_surface_ = nullptr; |
208 display_ = nullptr; | 208 display_ = nullptr; |
209 surface_factory_ = nullptr; | 209 child_factory_ = nullptr; |
| 210 root_factory_ = nullptr; |
210 surface_id_allocator_ = nullptr; | 211 surface_id_allocator_ = nullptr; |
211 surface_manager_ = nullptr; | 212 surface_manager_ = nullptr; |
212 cc::CompositorFrameSink::DetachFromClient(); | 213 cc::CompositorFrameSink::DetachFromClient(); |
213 CancelFallbackTick(); | 214 CancelFallbackTick(); |
214 } | 215 } |
215 | 216 |
216 static void NoOpDrawCallback() {} | 217 static void NoOpDrawCallback() {} |
217 | 218 |
218 void SynchronousCompositorFrameSink::SubmitCompositorFrame( | 219 void SynchronousCompositorFrameSink::SubmitCompositorFrame( |
219 cc::CompositorFrame frame) { | 220 cc::CompositorFrame frame) { |
(...skipping 10 matching lines...) Expand all Loading... |
230 | 231 |
231 cc::CompositorFrame submit_frame; | 232 cc::CompositorFrame submit_frame; |
232 | 233 |
233 if (in_software_draw_) { | 234 if (in_software_draw_) { |
234 // The frame we send to the client is actually just the metadata. Preserve | 235 // The frame we send to the client is actually just the metadata. Preserve |
235 // the |frame| for the software path below. | 236 // the |frame| for the software path below. |
236 submit_frame.metadata = frame.metadata.Clone(); | 237 submit_frame.metadata = frame.metadata.Clone(); |
237 | 238 |
238 if (!root_local_frame_id_.is_valid()) { | 239 if (!root_local_frame_id_.is_valid()) { |
239 root_local_frame_id_ = surface_id_allocator_->GenerateId(); | 240 root_local_frame_id_ = surface_id_allocator_->GenerateId(); |
240 surface_factory_->Create(root_local_frame_id_); | |
241 child_local_frame_id_ = surface_id_allocator_->GenerateId(); | 241 child_local_frame_id_ = surface_id_allocator_->GenerateId(); |
242 surface_factory_->Create(child_local_frame_id_); | |
243 } | 242 } |
244 | 243 |
245 display_->SetLocalFrameId(root_local_frame_id_, | 244 display_->SetLocalFrameId(root_local_frame_id_, |
246 frame.metadata.device_scale_factor); | 245 frame.metadata.device_scale_factor); |
247 | 246 |
248 // The layer compositor should be giving a frame that covers the | 247 // The layer compositor should be giving a frame that covers the |
249 // |sw_viewport_for_current_draw_| but at 0,0. | 248 // |sw_viewport_for_current_draw_| but at 0,0. |
250 gfx::Size child_size = sw_viewport_for_current_draw_.size(); | 249 gfx::Size child_size = sw_viewport_for_current_draw_.size(); |
251 DCHECK(gfx::Rect(child_size) == frame.render_pass_list.back()->output_rect); | 250 DCHECK(gfx::Rect(child_size) == frame.render_pass_list.back()->output_rect); |
252 | 251 |
(...skipping 28 matching lines...) Expand all Loading... |
281 auto* surface_quad = | 280 auto* surface_quad = |
282 embed_render_pass->CreateAndAppendDrawQuad<cc::SurfaceDrawQuad>(); | 281 embed_render_pass->CreateAndAppendDrawQuad<cc::SurfaceDrawQuad>(); |
283 shared_quad_state->SetAll( | 282 shared_quad_state->SetAll( |
284 child_transform, child_size, gfx::Rect(child_size), | 283 child_transform, child_size, gfx::Rect(child_size), |
285 gfx::Rect() /* clip_rect */, false /* is_clipped */, 1.f /* opacity */, | 284 gfx::Rect() /* clip_rect */, false /* is_clipped */, 1.f /* opacity */, |
286 SkXfermode::kSrcOver_Mode, 0 /* sorting_context_id */); | 285 SkXfermode::kSrcOver_Mode, 0 /* sorting_context_id */); |
287 surface_quad->SetNew(shared_quad_state, gfx::Rect(child_size), | 286 surface_quad->SetNew(shared_quad_state, gfx::Rect(child_size), |
288 gfx::Rect(child_size), | 287 gfx::Rect(child_size), |
289 cc::SurfaceId(kFrameSinkId, child_local_frame_id_)); | 288 cc::SurfaceId(kFrameSinkId, child_local_frame_id_)); |
290 | 289 |
291 surface_factory_->SubmitCompositorFrame( | 290 child_factory_->SubmitCompositorFrame( |
292 child_local_frame_id_, std::move(frame), base::Bind(&NoOpDrawCallback)); | 291 child_local_frame_id_, std::move(frame), base::Bind(&NoOpDrawCallback)); |
293 surface_factory_->SubmitCompositorFrame(root_local_frame_id_, | 292 root_factory_->SubmitCompositorFrame(root_local_frame_id_, |
294 std::move(embed_frame), | 293 std::move(embed_frame), |
295 base::Bind(&NoOpDrawCallback)); | 294 base::Bind(&NoOpDrawCallback)); |
296 display_->DrawAndSwap(); | 295 display_->DrawAndSwap(); |
297 } else { | 296 } else { |
298 // For hardware draws we send the whole frame to the client so it can draw | 297 // For hardware draws we send the whole frame to the client so it can draw |
299 // the content in it. | 298 // the content in it. |
300 submit_frame = std::move(frame); | 299 submit_frame = std::move(frame); |
301 } | 300 } |
302 | 301 |
303 sync_client_->SubmitCompositorFrame(compositor_frame_sink_id_, | 302 sync_client_->SubmitCompositorFrame(compositor_frame_sink_id_, |
304 std::move(submit_frame)); | 303 std::move(submit_frame)); |
305 DeliverMessages(); | 304 DeliverMessages(); |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
462 client_->ReclaimResources(resources); | 461 client_->ReclaimResources(resources); |
463 } | 462 } |
464 | 463 |
465 void SynchronousCompositorFrameSink::SetBeginFrameSource( | 464 void SynchronousCompositorFrameSink::SetBeginFrameSource( |
466 cc::BeginFrameSource* begin_frame_source) { | 465 cc::BeginFrameSource* begin_frame_source) { |
467 // Software output is synchronous and doesn't use a BeginFrameSource. | 466 // Software output is synchronous and doesn't use a BeginFrameSource. |
468 NOTREACHED(); | 467 NOTREACHED(); |
469 } | 468 } |
470 | 469 |
471 } // namespace content | 470 } // namespace content |
OLD | NEW |