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); |
sunnyps
2017/05/24 02:38:25
nit: We don't need this. When we use back to back
Eric Seckler
2017/05/24 09:00:40
I think this isn't true for local clients. DirectC
| |
98 } | 98 } |
99 | 99 |
100 void CompositorFrameSinkSupport::SubmitCompositorFrame( | 100 void 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 15 matching lines...) Expand all Loading... | |
140 weak_factory_.GetWeakPtr()), | 138 weak_factory_.GetWeakPtr()), |
141 base::BindRepeating(&CompositorFrameSinkSupport::WillDrawSurface, | 139 base::BindRepeating(&CompositorFrameSinkSupport::WillDrawSurface, |
142 weak_factory_.GetWeakPtr())); | 140 weak_factory_.GetWeakPtr())); |
143 | 141 |
144 if (current_surface_) { | 142 if (current_surface_) { |
145 surface->SetPreviousFrameSurface(current_surface_.get()); | 143 surface->SetPreviousFrameSurface(current_surface_.get()); |
146 DestroyCurrentSurface(); | 144 DestroyCurrentSurface(); |
147 } | 145 } |
148 current_surface_ = std::move(surface); | 146 current_surface_ = std::move(surface); |
149 | 147 |
150 // TODO(eseckler): The CompositorFrame submitted below might not be activated | 148 // TODO(eseckler): Forward |ack| via SurfaceObservers. |
151 // right away b/c of surface synchronization. We should only send the | 149 |
152 // BeginFrameAck to DisplayScheduler when it is activated. This also means | |
153 // that we need to stay an active BFO while a CompositorFrame is pending. | |
154 // See https://crbug.com/703079. | |
155 if (begin_frame_source_) | 150 if (begin_frame_source_) |
156 begin_frame_source_->DidFinishFrame(this, ack); | 151 begin_frame_source_->DidFinishFrame(this); |
sunnyps
2017/05/24 02:38:25
nit: same here
Eric Seckler
2017/05/24 09:00:40
see above.
| |
157 } | 152 } |
158 | 153 |
159 void CompositorFrameSinkSupport::UpdateSurfaceReferences( | 154 void CompositorFrameSinkSupport::UpdateSurfaceReferences( |
160 const SurfaceId& last_surface_id, | 155 const SurfaceId& last_surface_id, |
161 const LocalSurfaceId& local_surface_id) { | 156 const LocalSurfaceId& local_surface_id) { |
162 const bool surface_id_changed = | 157 const bool surface_id_changed = |
163 last_surface_id.local_surface_id() != local_surface_id; | 158 last_surface_id.local_surface_id() != local_surface_id; |
164 | 159 |
165 // If this is a display root surface and the SurfaceId is changing, make the | 160 // If this is a display root surface and the SurfaceId is changing, make the |
166 // new SurfaceId reachable from the top-level root. | 161 // new SurfaceId reachable from the top-level root. |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
346 std::unique_ptr<CopyOutputRequest> copy_request) { | 341 std::unique_ptr<CopyOutputRequest> copy_request) { |
347 if (!current_surface_) | 342 if (!current_surface_) |
348 return; | 343 return; |
349 | 344 |
350 DCHECK(current_surface_->compositor_frame_sink_support().get() == this); | 345 DCHECK(current_surface_->compositor_frame_sink_support().get() == this); |
351 current_surface_->RequestCopyOfOutput(std::move(copy_request)); | 346 current_surface_->RequestCopyOfOutput(std::move(copy_request)); |
352 surface_manager_->SurfaceModified(current_surface_->surface_id()); | 347 surface_manager_->SurfaceModified(current_surface_->surface_id()); |
353 } | 348 } |
354 | 349 |
355 } // namespace cc | 350 } // namespace cc |
OLD | NEW |