| 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" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/memory/ptr_util.h" | 13 #include "base/memory/ptr_util.h" |
| 14 #include "base/single_thread_task_runner.h" | 14 #include "base/single_thread_task_runner.h" |
| 15 #include "base/threading/thread_task_runner_handle.h" | 15 #include "base/threading/thread_task_runner_handle.h" |
| 16 #include "cc/output/compositor_frame.h" | 16 #include "cc/output/compositor_frame.h" |
| 17 #include "cc/output/compositor_frame_sink_client.h" | 17 #include "cc/output/compositor_frame_sink_client.h" |
| 18 #include "cc/output/context_provider.h" | 18 #include "cc/output/context_provider.h" |
| 19 #include "cc/output/output_surface.h" | 19 #include "cc/output/output_surface.h" |
| 20 #include "cc/output/output_surface_frame.h" | 20 #include "cc/output/output_surface_frame.h" |
| 21 #include "cc/output/renderer_settings.h" | 21 #include "cc/output/renderer_settings.h" |
| 22 #include "cc/output/software_output_device.h" | 22 #include "cc/output/software_output_device.h" |
| 23 #include "cc/output/texture_mailbox_deleter.h" | 23 #include "cc/output/texture_mailbox_deleter.h" |
| 24 #include "cc/quads/render_pass.h" | 24 #include "cc/quads/render_pass.h" |
| 25 #include "cc/quads/surface_draw_quad.h" | 25 #include "cc/quads/surface_draw_quad.h" |
| 26 #include "cc/surfaces/compositor_frame_sink_support.h" | 26 #include "cc/surfaces/compositor_frame_sink_support.h" |
| 27 #include "cc/surfaces/display.h" | 27 #include "cc/surfaces/display.h" |
| 28 #include "cc/surfaces/surface_id_allocator.h" | 28 #include "cc/surfaces/local_surface_id_allocator.h" |
| 29 #include "cc/surfaces/surface_manager.h" | 29 #include "cc/surfaces/surface_manager.h" |
| 30 #include "content/common/android/sync_compositor_messages.h" | 30 #include "content/common/android/sync_compositor_messages.h" |
| 31 #include "content/renderer/android/synchronous_compositor_filter.h" | 31 #include "content/renderer/android/synchronous_compositor_filter.h" |
| 32 #include "content/renderer/android/synchronous_compositor_registry.h" | 32 #include "content/renderer/android/synchronous_compositor_registry.h" |
| 33 #include "content/renderer/gpu/frame_swap_message_queue.h" | 33 #include "content/renderer/gpu/frame_swap_message_queue.h" |
| 34 #include "content/renderer/render_thread_impl.h" | 34 #include "content/renderer/render_thread_impl.h" |
| 35 #include "gpu/command_buffer/client/context_support.h" | 35 #include "gpu/command_buffer/client/context_support.h" |
| 36 #include "gpu/command_buffer/client/gles2_interface.h" | 36 #include "gpu/command_buffer/client/gles2_interface.h" |
| 37 #include "gpu/command_buffer/common/gpu_memory_allocation.h" | 37 #include "gpu/command_buffer/common/gpu_memory_allocation.h" |
| 38 #include "ipc/ipc_message.h" | 38 #include "ipc/ipc_message.h" |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 gpu_memory_buffer_manager, | 118 gpu_memory_buffer_manager, |
| 119 nullptr), | 119 nullptr), |
| 120 routing_id_(routing_id), | 120 routing_id_(routing_id), |
| 121 compositor_frame_sink_id_(compositor_frame_sink_id), | 121 compositor_frame_sink_id_(compositor_frame_sink_id), |
| 122 registry_(registry), | 122 registry_(registry), |
| 123 shared_bitmap_manager_(shared_bitmap_manager), | 123 shared_bitmap_manager_(shared_bitmap_manager), |
| 124 sender_(RenderThreadImpl::current()->sync_compositor_message_filter()), | 124 sender_(RenderThreadImpl::current()->sync_compositor_message_filter()), |
| 125 memory_policy_(0u), | 125 memory_policy_(0u), |
| 126 frame_swap_message_queue_(frame_swap_message_queue), | 126 frame_swap_message_queue_(frame_swap_message_queue), |
| 127 surface_manager_(new cc::SurfaceManager), | 127 surface_manager_(new cc::SurfaceManager), |
| 128 surface_id_allocator_(new cc::SurfaceIdAllocator()), | 128 local_surface_id_allocator_(new cc::LocalSurfaceIdAllocator()), |
| 129 begin_frame_source_(std::move(begin_frame_source)) { | 129 begin_frame_source_(std::move(begin_frame_source)) { |
| 130 DCHECK(registry_); | 130 DCHECK(registry_); |
| 131 DCHECK(sender_); | 131 DCHECK(sender_); |
| 132 DCHECK(begin_frame_source_); | 132 DCHECK(begin_frame_source_); |
| 133 thread_checker_.DetachFromThread(); | 133 thread_checker_.DetachFromThread(); |
| 134 memory_policy_.priority_cutoff_when_visible = | 134 memory_policy_.priority_cutoff_when_visible = |
| 135 gpu::MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE; | 135 gpu::MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE; |
| 136 } | 136 } |
| 137 | 137 |
| 138 SynchronousCompositorFrameSink::~SynchronousCompositorFrameSink() = default; | 138 SynchronousCompositorFrameSink::~SynchronousCompositorFrameSink() = default; |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 DCHECK(CalledOnValidThread()); | 208 DCHECK(CalledOnValidThread()); |
| 209 client_->SetBeginFrameSource(nullptr); | 209 client_->SetBeginFrameSource(nullptr); |
| 210 // Destroy the begin frame source on the same thread it was bound on. | 210 // Destroy the begin frame source on the same thread it was bound on. |
| 211 begin_frame_source_ = nullptr; | 211 begin_frame_source_ = nullptr; |
| 212 registry_->UnregisterCompositorFrameSink(routing_id_, this); | 212 registry_->UnregisterCompositorFrameSink(routing_id_, this); |
| 213 client_->SetTreeActivationCallback(base::Closure()); | 213 client_->SetTreeActivationCallback(base::Closure()); |
| 214 root_support_.reset(); | 214 root_support_.reset(); |
| 215 child_support_.reset(); | 215 child_support_.reset(); |
| 216 software_output_surface_ = nullptr; | 216 software_output_surface_ = nullptr; |
| 217 display_ = nullptr; | 217 display_ = nullptr; |
| 218 surface_id_allocator_ = nullptr; | 218 local_surface_id_allocator_ = nullptr; |
| 219 surface_manager_ = nullptr; | 219 surface_manager_ = nullptr; |
| 220 cc::CompositorFrameSink::DetachFromClient(); | 220 cc::CompositorFrameSink::DetachFromClient(); |
| 221 CancelFallbackTick(); | 221 CancelFallbackTick(); |
| 222 } | 222 } |
| 223 | 223 |
| 224 void SynchronousCompositorFrameSink::SubmitCompositorFrame( | 224 void SynchronousCompositorFrameSink::SubmitCompositorFrame( |
| 225 cc::CompositorFrame frame) { | 225 cc::CompositorFrame frame) { |
| 226 DCHECK(CalledOnValidThread()); | 226 DCHECK(CalledOnValidThread()); |
| 227 DCHECK(sync_client_); | 227 DCHECK(sync_client_); |
| 228 | 228 |
| 229 if (fallback_tick_running_) { | 229 if (fallback_tick_running_) { |
| 230 DCHECK(frame.resource_list.empty()); | 230 DCHECK(frame.resource_list.empty()); |
| 231 cc::ReturnedResourceArray return_resources; | 231 cc::ReturnedResourceArray return_resources; |
| 232 ReclaimResources(return_resources); | 232 ReclaimResources(return_resources); |
| 233 did_submit_frame_ = true; | 233 did_submit_frame_ = true; |
| 234 return; | 234 return; |
| 235 } | 235 } |
| 236 | 236 |
| 237 cc::CompositorFrame submit_frame; | 237 cc::CompositorFrame submit_frame; |
| 238 | 238 |
| 239 if (in_software_draw_) { | 239 if (in_software_draw_) { |
| 240 // The frame we send to the client is actually just the metadata. Preserve | 240 // The frame we send to the client is actually just the metadata. Preserve |
| 241 // the |frame| for the software path below. | 241 // the |frame| for the software path below. |
| 242 submit_frame.metadata = frame.metadata.Clone(); | 242 submit_frame.metadata = frame.metadata.Clone(); |
| 243 | 243 |
| 244 if (!root_local_surface_id_.is_valid()) { | 244 if (!root_local_surface_id_.is_valid()) { |
| 245 root_local_surface_id_ = surface_id_allocator_->GenerateId(); | 245 root_local_surface_id_ = local_surface_id_allocator_->GenerateId(); |
| 246 child_local_surface_id_ = surface_id_allocator_->GenerateId(); | 246 child_local_surface_id_ = local_surface_id_allocator_->GenerateId(); |
| 247 } | 247 } |
| 248 | 248 |
| 249 display_->SetLocalSurfaceId(root_local_surface_id_, | 249 display_->SetLocalSurfaceId(root_local_surface_id_, |
| 250 frame.metadata.device_scale_factor); | 250 frame.metadata.device_scale_factor); |
| 251 | 251 |
| 252 // The layer compositor should be giving a frame that covers the | 252 // The layer compositor should be giving a frame that covers the |
| 253 // |sw_viewport_for_current_draw_| but at 0,0. | 253 // |sw_viewport_for_current_draw_| but at 0,0. |
| 254 gfx::Size child_size = sw_viewport_for_current_draw_.size(); | 254 gfx::Size child_size = sw_viewport_for_current_draw_.size(); |
| 255 DCHECK(gfx::Rect(child_size) == frame.render_pass_list.back()->output_rect); | 255 DCHECK(gfx::Rect(child_size) == frame.render_pass_list.back()->output_rect); |
| 256 | 256 |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 469 const cc::ReturnedResourceArray& resources) { | 469 const cc::ReturnedResourceArray& resources) { |
| 470 DCHECK(resources.empty()); | 470 DCHECK(resources.empty()); |
| 471 client_->ReclaimResources(resources); | 471 client_->ReclaimResources(resources); |
| 472 } | 472 } |
| 473 | 473 |
| 474 void SynchronousCompositorFrameSink::WillDrawSurface( | 474 void SynchronousCompositorFrameSink::WillDrawSurface( |
| 475 const cc::LocalSurfaceId& local_surface_id, | 475 const cc::LocalSurfaceId& local_surface_id, |
| 476 const gfx::Rect& damage_rect) {} | 476 const gfx::Rect& damage_rect) {} |
| 477 | 477 |
| 478 } // namespace content | 478 } // namespace content |
| OLD | NEW |