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

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

Issue 2854163003: [cc] Plumb BeginFrameAcks through SurfaceManager to DisplayScheduler. (Closed)
Patch Set: Pass ack via SurfaceDamaged, add back tests. 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
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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 TRACE_EVENT2("cc", "CompositorFrameSinkSupport::DidNotProduceFrame",
90 "ack.source_id", ack.source_id, "ack.sequence_number",
91 ack.sequence_number);
89 DCHECK_GE(ack.sequence_number, BeginFrameArgs::kStartingFrameNumber); 92 DCHECK_GE(ack.sequence_number, BeginFrameArgs::kStartingFrameNumber);
90 93
91 // |has_damage| is not transmitted, but false by default. 94 // |has_damage| is not transmitted, but false by default.
92 DCHECK(!ack.has_damage); 95 DCHECK(!ack.has_damage);
93 96
94 // TODO(eseckler): Forward |ack| via SurfaceObservers. 97 if (current_surface_)
95 98 surface_manager_->SurfaceModified(current_surface_->surface_id(), ack);
96 if (begin_frame_source_) 99 if (begin_frame_source_)
97 begin_frame_source_->DidFinishFrame(this); 100 begin_frame_source_->DidFinishFrame(this);
98 } 101 }
99 102
100 bool CompositorFrameSinkSupport::SubmitCompositorFrame( 103 bool CompositorFrameSinkSupport::SubmitCompositorFrame(
101 const LocalSurfaceId& local_surface_id, 104 const LocalSurfaceId& local_surface_id,
102 CompositorFrame frame) { 105 CompositorFrame frame) {
103 TRACE_EVENT0("cc", "CompositorFrameSinkSupport::SubmitCompositorFrame"); 106 TRACE_EVENT0("cc", "CompositorFrameSinkSupport::SubmitCompositorFrame");
104 DCHECK(local_surface_id.is_valid()); 107 DCHECK(local_surface_id.is_valid());
105 DCHECK(!frame.render_pass_list.empty()); 108 DCHECK(!frame.render_pass_list.empty());
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 161
159 if (!result) 162 if (!result)
160 return false; 163 return false;
161 164
162 if (current_surface_) { 165 if (current_surface_) {
163 surface->SetPreviousFrameSurface(current_surface_.get()); 166 surface->SetPreviousFrameSurface(current_surface_.get());
164 DestroyCurrentSurface(); 167 DestroyCurrentSurface();
165 } 168 }
166 current_surface_ = std::move(surface); 169 current_surface_ = std::move(surface);
167 170
168 // TODO(eseckler): Forward |ack| via SurfaceObservers.
169
170 if (begin_frame_source_) 171 if (begin_frame_source_)
171 begin_frame_source_->DidFinishFrame(this); 172 begin_frame_source_->DidFinishFrame(this);
172 173
173 return true; 174 return true;
174 } 175 }
175 176
176 void CompositorFrameSinkSupport::UpdateSurfaceReferences( 177 void CompositorFrameSinkSupport::UpdateSurfaceReferences(
177 const SurfaceId& last_surface_id, 178 const SurfaceId& last_surface_id,
178 const LocalSurfaceId& local_surface_id) { 179 const LocalSurfaceId& local_surface_id) {
179 const bool surface_id_changed = 180 const bool surface_id_changed =
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 291
291 void CompositorFrameSinkSupport::Init(SurfaceManager* surface_manager) { 292 void CompositorFrameSinkSupport::Init(SurfaceManager* surface_manager) {
292 surface_manager_ = surface_manager; 293 surface_manager_ = surface_manager;
293 if (handles_frame_sink_id_invalidation_) 294 if (handles_frame_sink_id_invalidation_)
294 surface_manager_->RegisterFrameSinkId(frame_sink_id_); 295 surface_manager_->RegisterFrameSinkId(frame_sink_id_);
295 surface_manager_->RegisterFrameSinkManagerClient(frame_sink_id_, this); 296 surface_manager_->RegisterFrameSinkManagerClient(frame_sink_id_, this);
296 } 297 }
297 298
298 void CompositorFrameSinkSupport::OnBeginFrame(const BeginFrameArgs& args) { 299 void CompositorFrameSinkSupport::OnBeginFrame(const BeginFrameArgs& args) {
299 UpdateNeedsBeginFramesInternal(); 300 UpdateNeedsBeginFramesInternal();
301 if (current_surface_) {
302 surface_manager_->SurfaceDamageExpected(current_surface_->surface_id(),
303 args);
304 }
300 last_begin_frame_args_ = args; 305 last_begin_frame_args_ = args;
301 if (client_) 306 if (client_)
302 client_->OnBeginFrame(args); 307 client_->OnBeginFrame(args);
303 } 308 }
304 309
305 const BeginFrameArgs& CompositorFrameSinkSupport::LastUsedBeginFrameArgs() 310 const BeginFrameArgs& CompositorFrameSinkSupport::LastUsedBeginFrameArgs()
306 const { 311 const {
307 return last_begin_frame_args_; 312 return last_begin_frame_args_;
308 } 313 }
309 314
310 void CompositorFrameSinkSupport::OnBeginFrameSourcePausedChanged(bool paused) {} 315 void CompositorFrameSinkSupport::OnBeginFrameSourcePausedChanged(bool paused) {}
311 316
312 void CompositorFrameSinkSupport::OnSurfaceActivated(Surface* surface) { 317 void CompositorFrameSinkSupport::OnSurfaceActivated(Surface* surface) {
313 DCHECK(surface->HasActiveFrame()); 318 DCHECK(surface->HasActiveFrame());
319 const CompositorFrame& frame = surface->GetActiveFrame();
314 if (!seen_first_frame_activation_) { 320 if (!seen_first_frame_activation_) {
321 // SurfaceCreated only applies for the first Surface activation.
315 seen_first_frame_activation_ = true; 322 seen_first_frame_activation_ = true;
316 323
317 const CompositorFrame& frame = surface->GetActiveFrame();
318 gfx::Size frame_size = frame.render_pass_list.back()->output_rect.size(); 324 gfx::Size frame_size = frame.render_pass_list.back()->output_rect.size();
319
320 // SurfaceCreated only applies for the first Surface activation. Thus,
321 // SurfaceFactory stops observing new activations after the first one.
322 surface_manager_->SurfaceCreated(SurfaceInfo( 325 surface_manager_->SurfaceCreated(SurfaceInfo(
323 surface->surface_id(), frame.metadata.device_scale_factor, frame_size)); 326 surface->surface_id(), frame.metadata.device_scale_factor, frame_size));
324 } 327 }
325 // Fire SurfaceCreated first so that a temporary reference is added before it 328 // Fire SurfaceCreated first so that a temporary reference is added before it
326 // is potentially transformed into a real reference by the client. 329 // is potentially transformed into a real reference by the client.
327 ReferencedSurfacesChanged(surface->surface_id().local_surface_id(), 330 ReferencedSurfacesChanged(surface->surface_id().local_surface_id(),
328 surface->active_referenced_surfaces()); 331 surface->active_referenced_surfaces());
329 if (!surface_manager_->SurfaceModified(surface->surface_id())) { 332 if (!surface_manager_->SurfaceModified(surface->surface_id(),
333 frame.metadata.begin_frame_ack)) {
330 TRACE_EVENT_INSTANT0("cc", "Damage not visible.", TRACE_EVENT_SCOPE_THREAD); 334 TRACE_EVENT_INSTANT0("cc", "Damage not visible.", TRACE_EVENT_SCOPE_THREAD);
331 surface->RunDrawCallback(); 335 surface->RunDrawCallback();
332 } 336 }
333 surface_manager_->SurfaceActivated(surface); 337 surface_manager_->SurfaceActivated(surface);
334 } 338 }
335 339
336 void CompositorFrameSinkSupport::UpdateNeedsBeginFramesInternal() { 340 void CompositorFrameSinkSupport::UpdateNeedsBeginFramesInternal() {
337 if (!begin_frame_source_) 341 if (!begin_frame_source_)
338 return; 342 return;
339 343
(...skipping 18 matching lines...) Expand all
358 surface_manager_->DestroySurface(std::move(current_surface_)); 362 surface_manager_->DestroySurface(std::move(current_surface_));
359 } 363 }
360 364
361 void CompositorFrameSinkSupport::RequestCopyOfSurface( 365 void CompositorFrameSinkSupport::RequestCopyOfSurface(
362 std::unique_ptr<CopyOutputRequest> copy_request) { 366 std::unique_ptr<CopyOutputRequest> copy_request) {
363 if (!current_surface_) 367 if (!current_surface_)
364 return; 368 return;
365 369
366 DCHECK(current_surface_->compositor_frame_sink_support().get() == this); 370 DCHECK(current_surface_->compositor_frame_sink_support().get() == this);
367 current_surface_->RequestCopyOfOutput(std::move(copy_request)); 371 current_surface_->RequestCopyOfOutput(std::move(copy_request));
368 surface_manager_->SurfaceModified(current_surface_->surface_id()); 372 BeginFrameAck ack;
373 ack.has_damage = true;
374 surface_manager_->SurfaceModified(current_surface_->surface_id(), ack);
369 } 375 }
370 376
371 } // namespace cc 377 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698