| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "cc/surfaces/compositor_frame_sink_support.h" | 5 #include "cc/surfaces/compositor_frame_sink_support.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "cc/output/compositor_frame.h" | 10 #include "cc/output/compositor_frame.h" |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 return; | 79 return; |
| 80 DestroyCurrentSurface(); | 80 DestroyCurrentSurface(); |
| 81 } | 81 } |
| 82 | 82 |
| 83 void CompositorFrameSinkSupport::SetNeedsBeginFrame(bool needs_begin_frame) { | 83 void CompositorFrameSinkSupport::SetNeedsBeginFrame(bool needs_begin_frame) { |
| 84 needs_begin_frame_ = needs_begin_frame; | 84 needs_begin_frame_ = needs_begin_frame; |
| 85 UpdateNeedsBeginFramesInternal(); | 85 UpdateNeedsBeginFramesInternal(); |
| 86 } | 86 } |
| 87 | 87 |
| 88 void CompositorFrameSinkSupport::DidNotProduceFrame(const BeginFrameAck& ack) { | 88 void CompositorFrameSinkSupport::DidNotProduceFrame(const BeginFrameAck& ack) { |
| 89 // TODO(eseckler): While a pending CompositorFrame exists (see TODO below), we | |
| 90 // should not acknowledge immediately. Instead, we should update the ack that | |
| 91 // will be sent to DisplayScheduler when the pending frame is activated. | |
| 92 DCHECK_GE(ack.sequence_number, BeginFrameArgs::kStartingFrameNumber); | 89 DCHECK_GE(ack.sequence_number, BeginFrameArgs::kStartingFrameNumber); |
| 93 | 90 |
| 94 // |has_damage| is not transmitted, but false by default. | 91 // |has_damage| is not transmitted, but false by default. |
| 95 DCHECK(!ack.has_damage); | 92 DCHECK(!ack.has_damage); |
| 93 |
| 94 // TODO(eseckler): Forward |ack| via SurfaceObservers. |
| 95 |
| 96 if (begin_frame_source_) | 96 if (begin_frame_source_) |
| 97 begin_frame_source_->DidFinishFrame(this, ack); | 97 begin_frame_source_->DidFinishFrame(this); |
| 98 } | 98 } |
| 99 | 99 |
| 100 bool CompositorFrameSinkSupport::SubmitCompositorFrame( | 100 bool CompositorFrameSinkSupport::SubmitCompositorFrame( |
| 101 const LocalSurfaceId& local_surface_id, | 101 const LocalSurfaceId& local_surface_id, |
| 102 CompositorFrame frame) { | 102 CompositorFrame frame) { |
| 103 TRACE_EVENT0("cc", "CompositorFrameSinkSupport::SubmitCompositorFrame"); | 103 TRACE_EVENT0("cc", "CompositorFrameSinkSupport::SubmitCompositorFrame"); |
| 104 DCHECK(local_surface_id.is_valid()); | 104 DCHECK(local_surface_id.is_valid()); |
| 105 DCHECK_GE(frame.metadata.begin_frame_ack.sequence_number, | |
| 106 BeginFrameArgs::kStartingFrameNumber); | |
| 107 DCHECK(!frame.render_pass_list.empty()); | 105 DCHECK(!frame.render_pass_list.empty()); |
| 108 | 106 |
| 109 ++ack_pending_count_; | 107 ++ack_pending_count_; |
| 110 | 108 |
| 111 // |has_damage| is not transmitted. | 109 // |has_damage| is not transmitted. |
| 112 frame.metadata.begin_frame_ack.has_damage = true; | 110 frame.metadata.begin_frame_ack.has_damage = true; |
| 113 | |
| 114 BeginFrameAck ack = frame.metadata.begin_frame_ack; | 111 BeginFrameAck ack = frame.metadata.begin_frame_ack; |
| 112 DCHECK_LE(BeginFrameArgs::kStartingFrameNumber, ack.sequence_number); |
| 115 | 113 |
| 116 if (!ui::LatencyInfo::Verify(frame.metadata.latency_info, | 114 if (!ui::LatencyInfo::Verify(frame.metadata.latency_info, |
| 117 "RenderWidgetHostImpl::OnSwapCompositorFrame")) { | 115 "RenderWidgetHostImpl::OnSwapCompositorFrame")) { |
| 118 std::vector<ui::LatencyInfo>().swap(frame.metadata.latency_info); | 116 std::vector<ui::LatencyInfo>().swap(frame.metadata.latency_info); |
| 119 } | 117 } |
| 120 for (ui::LatencyInfo& latency : frame.metadata.latency_info) { | 118 for (ui::LatencyInfo& latency : frame.metadata.latency_info) { |
| 121 if (latency.latency_components().size() > 0) { | 119 if (latency.latency_components().size() > 0) { |
| 122 latency.AddLatencyNumber(ui::DISPLAY_COMPOSITOR_RECEIVED_FRAME_COMPONENT, | 120 latency.AddLatencyNumber(ui::DISPLAY_COMPOSITOR_RECEIVED_FRAME_COMPONENT, |
| 123 0, 0); | 121 0, 0); |
| 124 } | 122 } |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 surface_manager_->DestroySurface(std::move(surface)); | 160 surface_manager_->DestroySurface(std::move(surface)); |
| 163 return false; | 161 return false; |
| 164 } | 162 } |
| 165 | 163 |
| 166 if (current_surface_) { | 164 if (current_surface_) { |
| 167 surface->SetPreviousFrameSurface(current_surface_.get()); | 165 surface->SetPreviousFrameSurface(current_surface_.get()); |
| 168 DestroyCurrentSurface(); | 166 DestroyCurrentSurface(); |
| 169 } | 167 } |
| 170 current_surface_ = std::move(surface); | 168 current_surface_ = std::move(surface); |
| 171 | 169 |
| 172 // TODO(eseckler): The CompositorFrame submitted below might not be activated | 170 // TODO(eseckler): Forward |ack| via SurfaceObservers. |
| 173 // right away b/c of surface synchronization. We should only send the | 171 |
| 174 // BeginFrameAck to DisplayScheduler when it is activated. This also means | |
| 175 // that we need to stay an active BFO while a CompositorFrame is pending. | |
| 176 // See https://crbug.com/703079. | |
| 177 if (begin_frame_source_) | 172 if (begin_frame_source_) |
| 178 begin_frame_source_->DidFinishFrame(this, ack); | 173 begin_frame_source_->DidFinishFrame(this); |
| 179 | 174 |
| 180 return true; | 175 return true; |
| 181 } | 176 } |
| 182 | 177 |
| 183 void CompositorFrameSinkSupport::UpdateSurfaceReferences( | 178 void CompositorFrameSinkSupport::UpdateSurfaceReferences( |
| 184 const SurfaceId& last_surface_id, | 179 const SurfaceId& last_surface_id, |
| 185 const LocalSurfaceId& local_surface_id) { | 180 const LocalSurfaceId& local_surface_id) { |
| 186 const bool surface_id_changed = | 181 const bool surface_id_changed = |
| 187 last_surface_id.local_surface_id() != local_surface_id; | 182 last_surface_id.local_surface_id() != local_surface_id; |
| 188 | 183 |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 std::unique_ptr<CopyOutputRequest> copy_request) { | 364 std::unique_ptr<CopyOutputRequest> copy_request) { |
| 370 if (!current_surface_) | 365 if (!current_surface_) |
| 371 return; | 366 return; |
| 372 | 367 |
| 373 DCHECK(current_surface_->compositor_frame_sink_support().get() == this); | 368 DCHECK(current_surface_->compositor_frame_sink_support().get() == this); |
| 374 current_surface_->RequestCopyOfOutput(std::move(copy_request)); | 369 current_surface_->RequestCopyOfOutput(std::move(copy_request)); |
| 375 surface_manager_->SurfaceModified(current_surface_->surface_id()); | 370 surface_manager_->SurfaceModified(current_surface_->surface_id()); |
| 376 } | 371 } |
| 377 | 372 |
| 378 } // namespace cc | 373 } // namespace cc |
| OLD | NEW |