Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/gpu/renderer_compositor_frame_sink.h" | 5 #include "content/renderer/gpu/renderer_compositor_frame_sink.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 42 compositor_frame_sink_id_(compositor_frame_sink_id), | 42 compositor_frame_sink_id_(compositor_frame_sink_id), |
| 43 compositor_frame_sink_filter_( | 43 compositor_frame_sink_filter_( |
| 44 RenderThreadImpl::current()->compositor_message_filter()), | 44 RenderThreadImpl::current()->compositor_message_filter()), |
| 45 message_sender_(RenderThreadImpl::current()->sync_message_filter()), | 45 message_sender_(RenderThreadImpl::current()->sync_message_filter()), |
| 46 frame_swap_message_queue_(swap_frame_message_queue), | 46 frame_swap_message_queue_(swap_frame_message_queue), |
| 47 synthetic_begin_frame_source_(std::move(synthetic_begin_frame_source)), | 47 synthetic_begin_frame_source_(std::move(synthetic_begin_frame_source)), |
| 48 external_begin_frame_source_( | 48 external_begin_frame_source_( |
| 49 synthetic_begin_frame_source_ | 49 synthetic_begin_frame_source_ |
| 50 ? nullptr | 50 ? nullptr |
| 51 : base::MakeUnique<cc::ExternalBeginFrameSource>(this)), | 51 : base::MakeUnique<cc::ExternalBeginFrameSource>(this)), |
| 52 routing_id_(routing_id) { | 52 routing_id_(routing_id), |
| 53 last_used_frame_token_(compositor_frame_sink_id << 28) { | |
|
Fady Samuel
2017/03/31 16:45:14
I'd rather FrameToken be a struct with two ints li
Saman Sami
2017/04/03 19:22:28
What should those two ints be called? Frame token
| |
| 53 DCHECK(compositor_frame_sink_filter_); | 54 DCHECK(compositor_frame_sink_filter_); |
| 54 DCHECK(frame_swap_message_queue_); | 55 DCHECK(frame_swap_message_queue_); |
| 55 DCHECK(message_sender_); | 56 DCHECK(message_sender_); |
| 56 thread_checker_.DetachFromThread(); | 57 thread_checker_.DetachFromThread(); |
| 57 } | 58 } |
| 58 | 59 |
| 59 RendererCompositorFrameSink::RendererCompositorFrameSink( | 60 RendererCompositorFrameSink::RendererCompositorFrameSink( |
| 60 int32_t routing_id, | 61 int32_t routing_id, |
| 61 uint32_t compositor_frame_sink_id, | 62 uint32_t compositor_frame_sink_id, |
| 62 std::unique_ptr<cc::SyntheticBeginFrameSource> synthetic_begin_frame_source, | 63 std::unique_ptr<cc::SyntheticBeginFrameSource> synthetic_begin_frame_source, |
| 63 scoped_refptr<cc::VulkanContextProvider> vulkan_context_provider, | 64 scoped_refptr<cc::VulkanContextProvider> vulkan_context_provider, |
| 64 scoped_refptr<FrameSwapMessageQueue> swap_frame_message_queue) | 65 scoped_refptr<FrameSwapMessageQueue> swap_frame_message_queue) |
| 65 : CompositorFrameSink(std::move(vulkan_context_provider)), | 66 : CompositorFrameSink(std::move(vulkan_context_provider)), |
| 66 compositor_frame_sink_id_(compositor_frame_sink_id), | 67 compositor_frame_sink_id_(compositor_frame_sink_id), |
| 67 compositor_frame_sink_filter_( | 68 compositor_frame_sink_filter_( |
| 68 RenderThreadImpl::current()->compositor_message_filter()), | 69 RenderThreadImpl::current()->compositor_message_filter()), |
| 69 message_sender_(RenderThreadImpl::current()->sync_message_filter()), | 70 message_sender_(RenderThreadImpl::current()->sync_message_filter()), |
| 70 frame_swap_message_queue_(swap_frame_message_queue), | 71 frame_swap_message_queue_(swap_frame_message_queue), |
| 71 synthetic_begin_frame_source_(std::move(synthetic_begin_frame_source)), | 72 synthetic_begin_frame_source_(std::move(synthetic_begin_frame_source)), |
| 72 external_begin_frame_source_( | 73 external_begin_frame_source_( |
| 73 synthetic_begin_frame_source_ | 74 synthetic_begin_frame_source_ |
| 74 ? nullptr | 75 ? nullptr |
| 75 : base::MakeUnique<cc::ExternalBeginFrameSource>(this)), | 76 : base::MakeUnique<cc::ExternalBeginFrameSource>(this)), |
| 76 routing_id_(routing_id) { | 77 routing_id_(routing_id), |
| 78 last_used_frame_token_(compositor_frame_sink_id << 28) { | |
| 77 DCHECK(compositor_frame_sink_filter_); | 79 DCHECK(compositor_frame_sink_filter_); |
| 78 DCHECK(frame_swap_message_queue_); | 80 DCHECK(frame_swap_message_queue_); |
| 79 DCHECK(message_sender_); | 81 DCHECK(message_sender_); |
| 80 thread_checker_.DetachFromThread(); | 82 thread_checker_.DetachFromThread(); |
| 81 } | 83 } |
| 82 | 84 |
| 83 RendererCompositorFrameSink::~RendererCompositorFrameSink() { | 85 RendererCompositorFrameSink::~RendererCompositorFrameSink() { |
| 84 // TODO(crbug.com/702764): If not detached then IPC messages would crash | 86 // TODO(crbug.com/702764): If not detached then IPC messages would crash |
| 85 // after this class is destroyed. | 87 // after this class is destroyed. |
| 86 CHECK(!bound_); | 88 CHECK(!bound_); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 123 } | 125 } |
| 124 | 126 |
| 125 void RendererCompositorFrameSink::SubmitCompositorFrame( | 127 void RendererCompositorFrameSink::SubmitCompositorFrame( |
| 126 cc::CompositorFrame frame) { | 128 cc::CompositorFrame frame) { |
| 127 // We should only submit CompositorFrames with valid BeginFrameAcks. | 129 // We should only submit CompositorFrames with valid BeginFrameAcks. |
| 128 DCHECK_LE(cc::BeginFrameArgs::kStartingFrameNumber, | 130 DCHECK_LE(cc::BeginFrameArgs::kStartingFrameNumber, |
| 129 frame.metadata.begin_frame_ack.sequence_number); | 131 frame.metadata.begin_frame_ack.sequence_number); |
| 130 if (ShouldAllocateNewLocalSurfaceId(frame)) | 132 if (ShouldAllocateNewLocalSurfaceId(frame)) |
| 131 local_surface_id_ = id_allocator_.GenerateId(); | 133 local_surface_id_ = id_allocator_.GenerateId(); |
| 132 UpdateFrameData(frame); | 134 UpdateFrameData(frame); |
| 135 | |
| 133 { | 136 { |
| 134 std::unique_ptr<FrameSwapMessageQueue::SendMessageScope> | 137 std::unique_ptr<FrameSwapMessageQueue::SendMessageScope> |
| 135 send_message_scope = | 138 send_message_scope = |
| 136 frame_swap_message_queue_->AcquireSendMessageScope(); | 139 frame_swap_message_queue_->AcquireSendMessageScope(); |
| 137 std::vector<std::unique_ptr<IPC::Message>> messages; | 140 std::vector<std::unique_ptr<IPC::Message>> messages; |
| 138 std::vector<IPC::Message> messages_to_deliver_with_frame; | |
| 139 frame_swap_message_queue_->DrainMessages(&messages); | 141 frame_swap_message_queue_->DrainMessages(&messages); |
| 140 FrameSwapMessageQueue::TransferMessages(&messages, | 142 std::vector<IPC::Message> messages_to_send; |
| 141 &messages_to_deliver_with_frame); | 143 std::vector<IPC::Message> dummy; |
| 142 Send(new ViewHostMsg_SwapCompositorFrame( | 144 FrameSwapMessageQueue::TransferMessages(&messages, &messages_to_send); |
| 143 routing_id_, compositor_frame_sink_id_, local_surface_id_, frame, | 145 uint32_t frame_token = 0; |
| 144 messages_to_deliver_with_frame)); | 146 if (!messages_to_send.empty()) |
| 147 frame_token = ++last_used_frame_token_; | |
| 148 frame.metadata.frame_token = frame_token; | |
| 149 Send(new ViewHostMsg_SwapCompositorFrame(routing_id_, | |
| 150 compositor_frame_sink_id_, | |
| 151 local_surface_id_, frame, dummy)); | |
| 152 if (frame_token) { | |
| 153 Send(new ViewHostMsg_FrameSwapMessages(routing_id_, frame_token, | |
| 154 messages_to_send)); | |
| 155 } | |
| 145 // ~send_message_scope. | 156 // ~send_message_scope. |
| 146 } | 157 } |
| 147 } | 158 } |
| 148 | 159 |
| 149 void RendererCompositorFrameSink::OnMessageReceived( | 160 void RendererCompositorFrameSink::OnMessageReceived( |
| 150 const IPC::Message& message) { | 161 const IPC::Message& message) { |
| 151 DCHECK(thread_checker_.CalledOnValidThread()); | 162 DCHECK(thread_checker_.CalledOnValidThread()); |
| 152 IPC_BEGIN_MESSAGE_MAP(RendererCompositorFrameSink, message) | 163 IPC_BEGIN_MESSAGE_MAP(RendererCompositorFrameSink, message) |
| 153 IPC_MESSAGE_HANDLER(ViewMsg_ReclaimCompositorResources, | 164 IPC_MESSAGE_HANDLER(ViewMsg_ReclaimCompositorResources, |
| 154 OnReclaimCompositorResources) | 165 OnReclaimCompositorResources) |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 238 | 249 |
| 239 void RendererCompositorFrameSink::OnDidFinishFrame( | 250 void RendererCompositorFrameSink::OnDidFinishFrame( |
| 240 const cc::BeginFrameAck& ack) { | 251 const cc::BeginFrameAck& ack) { |
| 241 DCHECK_LE(cc::BeginFrameArgs::kStartingFrameNumber, ack.sequence_number); | 252 DCHECK_LE(cc::BeginFrameArgs::kStartingFrameNumber, ack.sequence_number); |
| 242 // If there was damage, ViewHostMsg_SwapCompositorFrame includes the ack. | 253 // If there was damage, ViewHostMsg_SwapCompositorFrame includes the ack. |
| 243 if (!ack.has_damage) | 254 if (!ack.has_damage) |
| 244 Send(new ViewHostMsg_BeginFrameDidNotSwap(routing_id_, ack)); | 255 Send(new ViewHostMsg_BeginFrameDidNotSwap(routing_id_, ack)); |
| 245 } | 256 } |
| 246 | 257 |
| 247 } // namespace content | 258 } // namespace content |
| OLD | NEW |