Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(95)

Side by Side Diff: cc/surfaces/compositor_frame_sink_support.cc

Issue 2854163003: [cc] Plumb BeginFrameAcks through SurfaceManager to DisplayScheduler. (Closed)
Patch Set: track state in DisplayScheduler rather than Surface Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | cc/surfaces/display.h » ('j') | cc/surfaces/surface_observer.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
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::BeginFrameDidNotSwap( 88 void CompositorFrameSinkSupport::BeginFrameDidNotSwap(
89 const BeginFrameAck& ack) { 89 const BeginFrameAck& ack) {
90 // TODO(eseckler): While a pending CompositorFrame exists (see TODO below), we 90 TRACE_EVENT2("cc", "CompositorFrameSinkSupport::BeginFrameDidNotSwap",
91 // should not acknowledge immediately. Instead, we should update the ack that 91 "ack.source_id", ack.source_id, "ack.sequence_number",
92 // will be sent to DisplayScheduler when the pending frame is activated. 92 ack.sequence_number);
93 DCHECK_GE(ack.sequence_number, BeginFrameArgs::kStartingFrameNumber); 93 DCHECK_GE(ack.sequence_number, BeginFrameArgs::kStartingFrameNumber);
94 94
95 // |has_damage| is not transmitted, but false by default. 95 // |has_damage| is not transmitted, but false by default.
96 DCHECK(!ack.has_damage); 96 DCHECK(!ack.has_damage);
97
98 if (current_surface_) {
99 surface_manager_->SurfaceFinishedBeginFrame(current_surface_->surface_id(),
100 ack);
101 }
97 if (begin_frame_source_) 102 if (begin_frame_source_)
98 begin_frame_source_->DidFinishFrame(this, ack); 103 begin_frame_source_->DidFinishFrame(this, ack);
99 } 104 }
100 105
101 void CompositorFrameSinkSupport::SubmitCompositorFrame( 106 void CompositorFrameSinkSupport::SubmitCompositorFrame(
102 const LocalSurfaceId& local_surface_id, 107 const LocalSurfaceId& local_surface_id,
103 CompositorFrame frame) { 108 CompositorFrame frame) {
104 TRACE_EVENT0("cc", "CompositorFrameSinkSupport::SubmitCompositorFrame"); 109 TRACE_EVENT0("cc", "CompositorFrameSinkSupport::SubmitCompositorFrame");
105 DCHECK(local_surface_id.is_valid()); 110 DCHECK(local_surface_id.is_valid());
106 DCHECK_GE(frame.metadata.begin_frame_ack.sequence_number, 111 DCHECK_GE(frame.metadata.begin_frame_ack.sequence_number,
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 weak_factory_.GetWeakPtr()), 146 weak_factory_.GetWeakPtr()),
142 base::BindRepeating(&CompositorFrameSinkSupport::WillDrawSurface, 147 base::BindRepeating(&CompositorFrameSinkSupport::WillDrawSurface,
143 weak_factory_.GetWeakPtr())); 148 weak_factory_.GetWeakPtr()));
144 149
145 if (current_surface_) { 150 if (current_surface_) {
146 surface->SetPreviousFrameSurface(current_surface_.get()); 151 surface->SetPreviousFrameSurface(current_surface_.get());
147 DestroyCurrentSurface(); 152 DestroyCurrentSurface();
148 } 153 }
149 current_surface_ = std::move(surface); 154 current_surface_ = std::move(surface);
150 155
151 // TODO(eseckler): The CompositorFrame submitted below might not be activated 156 surface_manager_->SurfaceFinishedBeginFrame(current_surface_->surface_id(),
152 // right away b/c of surface synchronization. We should only send the 157 ack);
153 // BeginFrameAck to DisplayScheduler when it is activated. This also means
154 // that we need to stay an active BFO while a CompositorFrame is pending.
155 // See https://crbug.com/703079.
156 if (begin_frame_source_) 158 if (begin_frame_source_)
157 begin_frame_source_->DidFinishFrame(this, ack); 159 begin_frame_source_->DidFinishFrame(this, ack);
158 } 160 }
159 161
160 void CompositorFrameSinkSupport::UpdateSurfaceReferences( 162 void CompositorFrameSinkSupport::UpdateSurfaceReferences(
161 const SurfaceId& last_surface_id, 163 const SurfaceId& last_surface_id,
162 const LocalSurfaceId& local_surface_id) { 164 const LocalSurfaceId& local_surface_id) {
163 const bool surface_id_changed = 165 const bool surface_id_changed =
164 last_surface_id.local_surface_id() != local_surface_id; 166 last_surface_id.local_surface_id() != local_surface_id;
165 167
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 276
275 void CompositorFrameSinkSupport::Init(SurfaceManager* surface_manager) { 277 void CompositorFrameSinkSupport::Init(SurfaceManager* surface_manager) {
276 surface_manager_ = surface_manager; 278 surface_manager_ = surface_manager;
277 if (handles_frame_sink_id_invalidation_) 279 if (handles_frame_sink_id_invalidation_)
278 surface_manager_->RegisterFrameSinkId(frame_sink_id_); 280 surface_manager_->RegisterFrameSinkId(frame_sink_id_);
279 surface_manager_->RegisterFrameSinkManagerClient(frame_sink_id_, this); 281 surface_manager_->RegisterFrameSinkManagerClient(frame_sink_id_, this);
280 } 282 }
281 283
282 void CompositorFrameSinkSupport::OnBeginFrame(const BeginFrameArgs& args) { 284 void CompositorFrameSinkSupport::OnBeginFrame(const BeginFrameArgs& args) {
283 UpdateNeedsBeginFramesInternal(); 285 UpdateNeedsBeginFramesInternal();
286 if (current_surface_) {
287 surface_manager_->SurfaceReceivedBeginFrame(current_surface_->surface_id(),
288 args);
289 }
284 last_begin_frame_args_ = args; 290 last_begin_frame_args_ = args;
285 if (client_) 291 if (client_)
286 client_->OnBeginFrame(args); 292 client_->OnBeginFrame(args);
287 } 293 }
288 294
289 const BeginFrameArgs& CompositorFrameSinkSupport::LastUsedBeginFrameArgs() 295 const BeginFrameArgs& CompositorFrameSinkSupport::LastUsedBeginFrameArgs()
290 const { 296 const {
291 return last_begin_frame_args_; 297 return last_begin_frame_args_;
292 } 298 }
293 299
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 std::unique_ptr<CopyOutputRequest> copy_request) { 353 std::unique_ptr<CopyOutputRequest> copy_request) {
348 if (!current_surface_) 354 if (!current_surface_)
349 return; 355 return;
350 356
351 DCHECK(current_surface_->compositor_frame_sink_support().get() == this); 357 DCHECK(current_surface_->compositor_frame_sink_support().get() == this);
352 current_surface_->RequestCopyOfOutput(std::move(copy_request)); 358 current_surface_->RequestCopyOfOutput(std::move(copy_request));
353 surface_manager_->SurfaceModified(current_surface_->surface_id()); 359 surface_manager_->SurfaceModified(current_surface_->surface_id());
354 } 360 }
355 361
356 } // namespace cc 362 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | cc/surfaces/display.h » ('j') | cc/surfaces/surface_observer.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698