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

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

Issue 2887453002: SurfaceDependencyTracker: Only observe BeginFrames if a deadline is needed (Closed)
Patch Set: Fixed an incorrect DCHECK Created 3 years, 6 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 | « cc/surfaces/surface_dependency_deadline.cc ('k') | cc/surfaces/surface_dependency_tracker.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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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_SURFACE_DEPENDENCY_TRACKER_H_ 5 #ifndef CC_SURFACES_SURFACE_DEPENDENCY_TRACKER_H_
6 #define CC_SURFACES_SURFACE_DEPENDENCY_TRACKER_H_ 6 #define CC_SURFACES_SURFACE_DEPENDENCY_TRACKER_H_
7 7
8 #include "cc/scheduler/begin_frame_source.h"
9 #include "cc/surfaces/surface.h" 8 #include "cc/surfaces/surface.h"
9 #include "cc/surfaces/surface_dependency_deadline.h"
10 #include "cc/surfaces/surfaces_export.h" 10 #include "cc/surfaces/surfaces_export.h"
11 11
12 namespace cc { 12 namespace cc {
13 13
14 class BeginFrameSource;
14 class SurfaceManager; 15 class SurfaceManager;
15 16
16 // SurfaceDependencyTracker tracks unresolved dependencies blocking 17 // SurfaceDependencyTracker tracks unresolved dependencies blocking
17 // CompositorFrames from activating. This class maintains a map from 18 // CompositorFrames from activating. This class maintains a map from
18 // a dependent surface ID to a set of Surfaces that have CompositorFrames 19 // a dependent surface ID to a set of Surfaces that have CompositorFrames
19 // blocked on that surface ID. SurfaceDependencyTracker observes when 20 // blocked on that surface ID. SurfaceDependencyTracker observes when
20 // dependent frames activate, and informs blocked surfaces. 21 // dependent frames activate, and informs blocked surfaces.
21 // 22 //
22 // When a blocking CompositorFrame is first submitted, SurfaceDependencyTracker 23 // When a blocking CompositorFrame is first submitted, SurfaceDependencyTracker
23 // will begin listening for BeginFrames, setting a deadline some number of 24 // will begin listening for BeginFrames, setting a deadline some number of
24 // BeginFrames in the future. If there are unresolved dependencies when the 25 // BeginFrames in the future. If there are unresolved dependencies when the
25 // deadline hits, then SurfaceDependencyTracker will clear then and activate 26 // deadline hits, then SurfaceDependencyTracker will clear then and activate
26 // all pending CompositorFrames. Once there are no more remaining pending 27 // all pending CompositorFrames. Once there are no more remaining pending
27 // frames, then SurfaceDependencyTracker will stop observing BeginFrames. 28 // frames, then SurfaceDependencyTracker will stop observing BeginFrames.
28 // TODO(fsamuel): Deadlines should not be global. They should be scoped to a 29 // TODO(fsamuel): Deadlines should not be global. They should be scoped to a
29 // surface subtree. However, that will not be possible until SurfaceReference 30 // surface subtree. However, that will not be possible until SurfaceReference
30 // work is complete. 31 // work is complete.
31 class CC_SURFACES_EXPORT SurfaceDependencyTracker : public BeginFrameObserver { 32 class CC_SURFACES_EXPORT SurfaceDependencyTracker {
32 public: 33 public:
33 SurfaceDependencyTracker(SurfaceManager* surface_manager, 34 SurfaceDependencyTracker(SurfaceManager* surface_manager,
34 BeginFrameSource* begin_frame_source); 35 BeginFrameSource* begin_frame_source);
35 ~SurfaceDependencyTracker() override; 36 ~SurfaceDependencyTracker();
36 37
37 // Called when |surface| has a pending CompositorFrame and it wishes to be 38 // Called when |surface| has a pending CompositorFrame and it wishes to be
38 // informed when that surface's dependencies are resolved. 39 // informed when that surface's dependencies are resolved.
39 void RequestSurfaceResolution(Surface* surface); 40 void RequestSurfaceResolution(Surface* surface);
40 41
41 bool has_deadline() const { return frames_since_deadline_set_.has_value(); } 42 bool has_deadline() const { return deadline_.has_deadline(); }
43
44 void OnDeadline();
42 45
43 void OnSurfaceActivated(Surface* surface); 46 void OnSurfaceActivated(Surface* surface);
44 void OnSurfaceDependenciesChanged( 47 void OnSurfaceDependenciesChanged(
45 Surface* surface, 48 Surface* surface,
46 const base::flat_set<SurfaceId>& added_dependencies, 49 const base::flat_set<SurfaceId>& added_dependencies,
47 const base::flat_set<SurfaceId>& removed_dependencies); 50 const base::flat_set<SurfaceId>& removed_dependencies);
48 void OnSurfaceDiscarded(Surface* surface); 51 void OnSurfaceDiscarded(Surface* surface);
49 52
50 // BeginFrameObserver implementation.
51 void OnBeginFrame(const BeginFrameArgs& args) override;
52 const BeginFrameArgs& LastUsedBeginFrameArgs() const override;
53 void OnBeginFrameSourcePausedChanged(bool paused) override;
54
55 private: 53 private:
56 // Informs all Surfaces with pending frames blocked on the provided 54 // Informs all Surfaces with pending frames blocked on the provided
57 // |surface_id| that there is now an active frame available in Surface 55 // |surface_id| that there is now an active frame available in Surface
58 // corresponding to |surface_id|. 56 // corresponding to |surface_id|.
59 void NotifySurfaceIdAvailable(const SurfaceId& surface_id); 57 void NotifySurfaceIdAvailable(const SurfaceId& surface_id);
60 58
61 SurfaceManager* const surface_manager_; 59 SurfaceManager* const surface_manager_;
62 60
63 // The last begin frame args generated by the begin frame source. 61 // This object tracks the deadline when all pending CompositorFrames in the
64 BeginFrameArgs last_begin_frame_args_; 62 // system will be activated.
65 63 SurfaceDependencyDeadline deadline_;
66 // The BeginFrameSource used to set deadlines.
67 BeginFrameSource* const begin_frame_source_;
68
69 // The number of BeginFrames observed since a deadline was set. If
70 // base::nullopt_t then a deadline is not set.
71 base::Optional<uint32_t> frames_since_deadline_set_;
72 64
73 // A map from a SurfaceId to the set of Surfaces blocked on that SurfaceId. 65 // A map from a SurfaceId to the set of Surfaces blocked on that SurfaceId.
74 std::unordered_map<SurfaceId, base::flat_set<SurfaceId>, SurfaceIdHash> 66 std::unordered_map<SurfaceId, base::flat_set<SurfaceId>, SurfaceIdHash>
75 blocked_surfaces_from_dependency_; 67 blocked_surfaces_from_dependency_;
76 68
77 // The set of SurfaceIds corresponding that are known to have blockers. 69 // The set of SurfaceIds corresponding that are known to have blockers.
78 base::flat_set<SurfaceId> blocked_surfaces_by_id_; 70 base::flat_set<SurfaceId> blocked_surfaces_by_id_;
79 71
80 // The set of SurfaceIds to which corresponding CompositorFrames have not 72 // The set of SurfaceIds to which corresponding CompositorFrames have not
81 // arrived by the time their deadline fired. 73 // arrived by the time their deadline fired.
82 base::flat_set<SurfaceId> late_surfaces_by_id_; 74 base::flat_set<SurfaceId> late_surfaces_by_id_;
83 75
84 DISALLOW_COPY_AND_ASSIGN(SurfaceDependencyTracker); 76 DISALLOW_COPY_AND_ASSIGN(SurfaceDependencyTracker);
85 }; 77 };
86 78
87 } // namespace cc 79 } // namespace cc
88 80
89 #endif // CC_SURFACES_SURFACE_DEPENDENCY_TRACKER_H_ 81 #endif // CC_SURFACES_SURFACE_DEPENDENCY_TRACKER_H_
OLDNEW
« no previous file with comments | « cc/surfaces/surface_dependency_deadline.cc ('k') | cc/surfaces/surface_dependency_tracker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698