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

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

Issue 2755463002: [cc] Fix CompositorFrameSinkSupport BeginFrameAck interface. (Closed)
Patch Set: sync Created 3 years, 9 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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 60
61 void CompositorFrameSinkSupport::EvictFrame() { 61 void CompositorFrameSinkSupport::EvictFrame() {
62 surface_factory_.EvictSurface(); 62 surface_factory_.EvictSurface();
63 } 63 }
64 64
65 void CompositorFrameSinkSupport::SetNeedsBeginFrame(bool needs_begin_frame) { 65 void CompositorFrameSinkSupport::SetNeedsBeginFrame(bool needs_begin_frame) {
66 needs_begin_frame_ = needs_begin_frame; 66 needs_begin_frame_ = needs_begin_frame;
67 UpdateNeedsBeginFramesInternal(); 67 UpdateNeedsBeginFramesInternal();
68 } 68 }
69 69
70 void CompositorFrameSinkSupport::DidFinishFrame(const BeginFrameAck& ack) { 70 void CompositorFrameSinkSupport::BeginFrameDidNotSwap(
71 const BeginFrameAck& ack) {
72 // TODO(eseckler): While a pending CompositorFrame exists (see TODO below), we
73 // should not acknowledge immediately. Instead, we should update the ack that
74 // will be sent to DisplayScheduler when the pending frame is activated.
75 DCHECK_LE(BeginFrameArgs::kStartingFrameNumber, ack.sequence_number);
76 // |has_damage| is not transmitted, but false by default.
77 DCHECK(!ack.has_damage);
78 // |remaining_frames| is not transmitted, but 0 by default.
79 DCHECK_EQ(0u, ack.remaining_frames);
71 if (begin_frame_source_) 80 if (begin_frame_source_)
72 begin_frame_source_->DidFinishFrame(this, ack); 81 begin_frame_source_->DidFinishFrame(this, ack);
73 } 82 }
74 83
75 void CompositorFrameSinkSupport::SubmitCompositorFrame( 84 void CompositorFrameSinkSupport::SubmitCompositorFrame(
76 const LocalSurfaceId& local_surface_id, 85 const LocalSurfaceId& local_surface_id,
77 CompositorFrame frame) { 86 CompositorFrame frame) {
78 ++ack_pending_count_; 87 ++ack_pending_count_;
79 88
89 if (frame.metadata.begin_frame_ack.sequence_number <
90 BeginFrameArgs::kStartingFrameNumber) {
91 DLOG(ERROR) << "Received CompositorFrame with invalid BeginFrameAck.";
92 frame.metadata.begin_frame_ack.source_id = BeginFrameArgs::kManualSourceId;
93 frame.metadata.begin_frame_ack.sequence_number =
94 BeginFrameArgs::kStartingFrameNumber;
95 }
96 // |has_damage| and |remaining_frames| are not transmitted.
97 frame.metadata.begin_frame_ack.has_damage = true;
98 frame.metadata.begin_frame_ack.remaining_frames = 0;
99
80 surface_factory_.SubmitCompositorFrame( 100 surface_factory_.SubmitCompositorFrame(
81 local_surface_id, std::move(frame), 101 local_surface_id, std::move(frame),
82 base::Bind(&CompositorFrameSinkSupport::DidReceiveCompositorFrameAck, 102 base::Bind(&CompositorFrameSinkSupport::DidReceiveCompositorFrameAck,
83 weak_factory_.GetWeakPtr())); 103 weak_factory_.GetWeakPtr()));
104
105 // TODO(eseckler): The CompositorFrame submitted below might not be activated
106 // right away b/c of surface synchronization. We should only send the
107 // BeginFrameAck to DisplayScheduler when it is activated. This also means
108 // that we need to stay an active BFO while a CompositorFrame is pending.
109 // See https://crbug.com/703079.
110 if (begin_frame_source_)
111 begin_frame_source_->DidFinishFrame(this, frame.metadata.begin_frame_ack);
84 } 112 }
85 113
86 void CompositorFrameSinkSupport::UpdateSurfaceReferences( 114 void CompositorFrameSinkSupport::UpdateSurfaceReferences(
87 const SurfaceId& last_surface_id, 115 const SurfaceId& last_surface_id,
88 const LocalSurfaceId& local_surface_id) { 116 const LocalSurfaceId& local_surface_id) {
89 const bool surface_id_changed = 117 const bool surface_id_changed =
90 last_surface_id.local_surface_id() != local_surface_id; 118 last_surface_id.local_surface_id() != local_surface_id;
91 119
92 // If this is a display root surface and the SurfaceId is changing, make the 120 // If this is a display root surface and the SurfaceId is changing, make the
93 // new SurfaceId reachable from the top-level root. 121 // new SurfaceId reachable from the top-level root.
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 else 259 else
232 begin_frame_source_->RemoveObserver(this); 260 begin_frame_source_->RemoveObserver(this);
233 } 261 }
234 262
235 void CompositorFrameSinkSupport::RequestCopyOfSurface( 263 void CompositorFrameSinkSupport::RequestCopyOfSurface(
236 std::unique_ptr<CopyOutputRequest> request) { 264 std::unique_ptr<CopyOutputRequest> request) {
237 surface_factory_.RequestCopyOfSurface(std::move(request)); 265 surface_factory_.RequestCopyOfSurface(std::move(request));
238 } 266 }
239 267
240 } // namespace cc 268 } // namespace cc
OLDNEW
« no previous file with comments | « cc/surfaces/compositor_frame_sink_support.h ('k') | cc/surfaces/compositor_frame_sink_support_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698