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

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

Issue 2785103003: [cc] CompositorFrameSinkSupport: Defer BeginFrameAck of pending frames. (Closed)
Patch Set: add comment Created 3 years, 8 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/compositor_frame_sink_support.cc » ('j') | no next file with comments »
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 #ifndef CC_SURFACES_COMPOSITOR_FRAME_SINK_SUPPORT_H_ 5 #ifndef CC_SURFACES_COMPOSITOR_FRAME_SINK_SUPPORT_H_
6 #define CC_SURFACES_COMPOSITOR_FRAME_SINK_SUPPORT_H_ 6 #define CC_SURFACES_COMPOSITOR_FRAME_SINK_SUPPORT_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <unordered_set> 9 #include <unordered_set>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
14 #include "base/optional.h"
14 #include "cc/output/compositor_frame.h" 15 #include "cc/output/compositor_frame.h"
15 #include "cc/scheduler/begin_frame_source.h" 16 #include "cc/scheduler/begin_frame_source.h"
16 #include "cc/surfaces/referenced_surface_tracker.h" 17 #include "cc/surfaces/referenced_surface_tracker.h"
17 #include "cc/surfaces/surface_factory.h" 18 #include "cc/surfaces/surface_factory.h"
18 #include "cc/surfaces/surface_factory_client.h" 19 #include "cc/surfaces/surface_factory_client.h"
19 #include "cc/surfaces/surface_id.h" 20 #include "cc/surfaces/surface_id.h"
20 #include "cc/surfaces/surfaces_export.h" 21 #include "cc/surfaces/surfaces_export.h"
21 22
22 namespace cc { 23 namespace cc {
23 24
(...skipping 25 matching lines...) Expand all
49 50
50 void EvictFrame(); 51 void EvictFrame();
51 void SetNeedsBeginFrame(bool needs_begin_frame); 52 void SetNeedsBeginFrame(bool needs_begin_frame);
52 void BeginFrameDidNotSwap(const BeginFrameAck& ack); 53 void BeginFrameDidNotSwap(const BeginFrameAck& ack);
53 void SubmitCompositorFrame(const LocalSurfaceId& local_surface_id, 54 void SubmitCompositorFrame(const LocalSurfaceId& local_surface_id,
54 CompositorFrame frame); 55 CompositorFrame frame);
55 void RequestCopyOfSurface(std::unique_ptr<CopyOutputRequest> request); 56 void RequestCopyOfSurface(std::unique_ptr<CopyOutputRequest> request);
56 void ForceReclaimResources(); 57 void ForceReclaimResources();
57 void ClaimTemporaryReference(const SurfaceId& surface_id); 58 void ClaimTemporaryReference(const SurfaceId& surface_id);
58 59
60 base::Optional<BeginFrameAck> begin_frame_ack_for_pending_frame_for_testing()
61 const {
62 return begin_frame_ack_for_pending_frame_;
63 }
64
59 private: 65 private:
60 // Update surface references with SurfaceManager for current CompositorFrame 66 // Update surface references with SurfaceManager for current CompositorFrame
61 // that has |local_surface_id|. UpdateReferences() must be called on 67 // that has |local_surface_id|. UpdateReferences() must be called on
62 // |reference_tracker_| before calling this. Will add and remove top-level 68 // |reference_tracker_| before calling this. Will add and remove top-level
63 // root references if |display_| is not null. 69 // root references if |display_| is not null.
64 void UpdateSurfaceReferences(const SurfaceId& last_surface_id, 70 void UpdateSurfaceReferences(const SurfaceId& last_surface_id,
65 const LocalSurfaceId& local_surface_id); 71 const LocalSurfaceId& local_surface_id);
66 72
67 void AddTopLevelRootReference(const SurfaceId& surface_id); 73 void AddTopLevelRootReference(const SurfaceId& surface_id);
68 void RemoveTopLevelRootReference(const SurfaceId& surface_id); 74 void RemoveTopLevelRootReference(const SurfaceId& surface_id);
69 75
70 void DidReceiveCompositorFrameAck(); 76 void DidReceiveCompositorFrameAck();
77 void PendingFrameDiscarded();
71 78
72 // SurfaceFactoryClient implementation. 79 // SurfaceFactoryClient implementation.
73 void ReferencedSurfacesChanged( 80 void ReferencedSurfacesChanged(
74 const LocalSurfaceId& local_surface_id, 81 const LocalSurfaceId& local_surface_id,
75 const std::vector<SurfaceId>* active_referenced_surfaces, 82 const std::vector<SurfaceId>* active_referenced_surfaces,
76 const std::vector<SurfaceId>* pending_referenced_surfaces) override; 83 const std::vector<SurfaceId>* pending_referenced_surfaces) override;
77 void ReturnResources(const ReturnedResourceArray& resources) override; 84 void ReturnResources(const ReturnedResourceArray& resources) override;
78 void SetBeginFrameSource(BeginFrameSource* begin_frame_source) override; 85 void SetBeginFrameSource(BeginFrameSource* begin_frame_source) override;
79 void WillDrawSurface(const LocalSurfaceId& local_surface_id, 86 void WillDrawSurface(const LocalSurfaceId& local_surface_id,
80 const gfx::Rect& damage_rect) override; 87 const gfx::Rect& damage_rect) override;
88 void PendingFrameActivated(const LocalSurfaceId& local_surface_id) override;
89 void SurfaceDiscarded(const LocalSurfaceId& local_surface_id) override;
81 90
82 // BeginFrameObserver implementation. 91 // BeginFrameObserver implementation.
83 void OnBeginFrame(const BeginFrameArgs& args) override; 92 void OnBeginFrame(const BeginFrameArgs& args) override;
84 const BeginFrameArgs& LastUsedBeginFrameArgs() const override; 93 const BeginFrameArgs& LastUsedBeginFrameArgs() const override;
85 void OnBeginFrameSourcePausedChanged(bool paused) override; 94 void OnBeginFrameSourcePausedChanged(bool paused) override;
86 95
87 void UpdateNeedsBeginFramesInternal(); 96 void UpdateNeedsBeginFramesInternal();
97 // Send |ack| to BeginFrameSource and update
98 // |latest_confirmed_begin_frame_sequence_number_ / source_id_|.
99 void AcknowledgeBeginFrame(const BeginFrameAck& ack);
100 // Send a no-damage BeginFrameAck for the last BeginFrame that re-confirms the
101 // |latest_confirmed_begin_frame_sequence_number_|. Used to confirm past
102 // BeginFrames while a pending CompositorFrame is queued but not activated.
103 void AcknowledgeLastBeginFrameWithoutUpdates();
88 104
89 CompositorFrameSinkSupportClient* const client_; 105 CompositorFrameSinkSupportClient* const client_;
90 106
91 SurfaceManager* const surface_manager_; 107 SurfaceManager* const surface_manager_;
92 108
93 const FrameSinkId frame_sink_id_; 109 const FrameSinkId frame_sink_id_;
94 110
95 SurfaceFactory surface_factory_; 111 SurfaceFactory surface_factory_;
96 // Counts the number of CompositorFrames that have been submitted and have not 112 // Counts the number of CompositorFrames that have been submitted and have not
97 // yet received an ACK. 113 // yet received an ACK.
98 int ack_pending_count_ = 0; 114 int ack_pending_count_ = 0;
99 ReturnedResourceArray surface_returned_resources_; 115 ReturnedResourceArray surface_returned_resources_;
100 116
101 // The begin frame source being observered. Null if none. 117 // The begin frame source being observered. Null if none.
102 BeginFrameSource* begin_frame_source_ = nullptr; 118 BeginFrameSource* begin_frame_source_ = nullptr;
103 119
104 // The last begin frame args generated by the begin frame source. 120 // The last begin frame args generated by the begin frame source.
105 BeginFrameArgs last_begin_frame_args_; 121 BeginFrameArgs last_begin_frame_args_;
106 122
123 // The BeginFrameAck that will be issued when the last submitted
124 // CompositorFrame is activated. Only set if we recently submitted a
125 // CompositorFrame that has not been activated yet.
126 base::Optional<BeginFrameAck> begin_frame_ack_for_pending_frame_;
127 // The surface that the last CompositorFrame was submitted to. Used to
128 // determine whether the last CompositorFrame may have been dropped during
129 // SurfaceDiscarded.
130 LocalSurfaceId surface_id_for_pending_frame_;
131
132 // Whether the last BeginFrame was forwarded to the client.
133 bool last_begin_frame_sent_to_client_ = true;
134
135 uint32_t latest_confirmed_begin_frame_source_id_ = 0;
136 uint64_t latest_confirmed_begin_frame_sequence_number_ =
137 BeginFrameArgs::kInvalidFrameNumber;
138
107 // Whether a request for begin frames has been issued. 139 // Whether a request for begin frames has been issued.
108 bool needs_begin_frame_ = false; 140 bool client_needs_begin_frame_ = false;
109 141
110 // Whether or not a frame observer has been added. 142 // Whether or not a frame observer has been added.
111 bool added_frame_observer_ = false; 143 bool added_frame_observer_ = false;
112 144
113 // Track the surface references for the surface corresponding to this 145 // Track the surface references for the surface corresponding to this
114 // compositor frame sink. 146 // compositor frame sink.
115 ReferencedSurfaceTracker reference_tracker_; 147 ReferencedSurfaceTracker reference_tracker_;
116 148
117 const bool is_root_; 149 const bool is_root_;
118 150
(...skipping 10 matching lines...) Expand all
129 const bool handles_frame_sink_id_invalidation_; 161 const bool handles_frame_sink_id_invalidation_;
130 162
131 base::WeakPtrFactory<CompositorFrameSinkSupport> weak_factory_; 163 base::WeakPtrFactory<CompositorFrameSinkSupport> weak_factory_;
132 164
133 DISALLOW_COPY_AND_ASSIGN(CompositorFrameSinkSupport); 165 DISALLOW_COPY_AND_ASSIGN(CompositorFrameSinkSupport);
134 }; 166 };
135 167
136 } // namespace cc 168 } // namespace cc
137 169
138 #endif // CC_SURFACES_COMPOSITOR_FRAME_SINK_SUPPORT_H_ 170 #endif // CC_SURFACES_COMPOSITOR_FRAME_SINK_SUPPORT_H_
OLDNEW
« no previous file with comments | « no previous file | cc/surfaces/compositor_frame_sink_support.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698