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

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

Issue 2814633006: Surface synchronization: Immediately activate late arriving CompositorFrames (Closed)
Patch Set: 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 | « cc/surfaces/surface_dependency_tracker.h ('k') | no next file » | 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 #include "cc/surfaces/surface_dependency_tracker.h" 5 #include "cc/surfaces/surface_dependency_tracker.h"
6 6
7 #include "cc/surfaces/surface.h" 7 #include "cc/surfaces/surface.h"
8 #include "cc/surfaces/surface_info.h" 8 #include "cc/surfaces/surface_info.h"
9 #include "cc/surfaces/surface_manager.h" 9 #include "cc/surfaces/surface_manager.h"
10 10
(...skipping 20 matching lines...) Expand all
31 DCHECK(observed_surface); 31 DCHECK(observed_surface);
32 observed_surface->RemoveObserver(this); 32 observed_surface->RemoveObserver(this);
33 } 33 }
34 observed_surfaces_by_id_.clear(); 34 observed_surfaces_by_id_.clear();
35 } 35 }
36 36
37 void SurfaceDependencyTracker::RequestSurfaceResolution(Surface* surface) { 37 void SurfaceDependencyTracker::RequestSurfaceResolution(Surface* surface) {
38 DCHECK(surface->HasPendingFrame()); 38 DCHECK(surface->HasPendingFrame());
39 39
40 const CompositorFrame& pending_frame = surface->GetPendingFrame(); 40 const CompositorFrame& pending_frame = surface->GetPendingFrame();
41 bool needs_begin_frame = 41 bool needs_deadline = pending_frame.metadata.can_activate_before_dependencies;
42 pending_frame.metadata.can_activate_before_dependencies; 42
43 auto late_it = late_surfaces_by_id_.find(surface->surface_id());
44 if (needs_deadline && late_it != late_surfaces_by_id_.end()) {
45 late_surfaces_by_id_.erase(late_it);
46 surface->ActivatePendingFrameForDeadline();
47 return;
48 }
43 49
44 // Referenced surface IDs that aren't currently known to the surface manager 50 // Referenced surface IDs that aren't currently known to the surface manager
45 // or do not have an active CompsotiorFrame block this frame. 51 // or do not have an active CompsotiorFrame block this frame.
46 for (const SurfaceId& surface_id : pending_frame.metadata.embedded_surfaces) { 52 for (const SurfaceId& surface_id : pending_frame.metadata.embedded_surfaces) {
47 Surface* surface_dependency = surface_manager_->GetSurfaceForId(surface_id); 53 Surface* surface_dependency = surface_manager_->GetSurfaceForId(surface_id);
48 if (!surface_dependency || !surface_dependency->HasActiveFrame()) 54 if (!surface_dependency || !surface_dependency->HasActiveFrame())
49 blocked_surfaces_from_dependency_[surface_id].insert( 55 blocked_surfaces_from_dependency_[surface_id].insert(
50 surface->surface_id()); 56 surface->surface_id());
51 } 57 }
52 58
53 if (!observed_surfaces_by_id_.count(surface->surface_id())) { 59 if (!observed_surfaces_by_id_.count(surface->surface_id())) {
54 surface->AddObserver(this); 60 surface->AddObserver(this);
55 observed_surfaces_by_id_.insert(surface->surface_id()); 61 observed_surfaces_by_id_.insert(surface->surface_id());
56 } 62 }
57 63
58 if (needs_begin_frame && !frames_since_deadline_set_) 64 if (needs_deadline && !frames_since_deadline_set_)
59 frames_since_deadline_set_ = 0; 65 frames_since_deadline_set_ = 0;
60 } 66 }
61 67
62 void SurfaceDependencyTracker::OnBeginFrame(const BeginFrameArgs& args) { 68 void SurfaceDependencyTracker::OnBeginFrame(const BeginFrameArgs& args) {
63 // If no deadline is set then we have nothing to do. 69 // If no deadline is set then we have nothing to do.
64 if (!frames_since_deadline_set_) 70 if (!frames_since_deadline_set_)
65 return; 71 return;
66 72
67 // TODO(fsamuel, kylechar): We have a single global deadline here. We should 73 // TODO(fsamuel, kylechar): We have a single global deadline here. We should
68 // scope deadlines to surface subtrees. We cannot do that until 74 // scope deadlines to surface subtrees. We cannot do that until
69 // SurfaceReferences have been fully implemented 75 // SurfaceReferences have been fully implemented
70 // (see https://crbug.com/689719). 76 // (see https://crbug.com/689719).
71 last_begin_frame_args_ = args; 77 last_begin_frame_args_ = args;
72 // Nothing to do if we haven't hit a deadline yet. 78 // Nothing to do if we haven't hit a deadline yet.
73 if (++(*frames_since_deadline_set_) != kMaxBeginFrameCount) 79 if (++(*frames_since_deadline_set_) != kMaxBeginFrameCount)
74 return; 80 return;
75 81
82 late_surfaces_by_id_.clear();
83
76 // Activate all surfaces that respect the deadline. 84 // Activate all surfaces that respect the deadline.
77 // Copy the set of blocked surfaces here because that set can mutate as we 85 // Copy the set of blocked surfaces here because that set can mutate as we
78 // activate CompositorFrames: an activation can trigger further activations 86 // activate CompositorFrames: an activation can trigger further activations
79 // which will remove elements from |observed_surfaces_by_id_|. This 87 // which will remove elements from |observed_surfaces_by_id_|. This
80 // invalidates the iterator. 88 // invalidates the iterator.
81 base::flat_set<SurfaceId> blocked_surfaces_by_id(observed_surfaces_by_id_); 89 base::flat_set<SurfaceId> blocked_surfaces_by_id(observed_surfaces_by_id_);
82 for (const SurfaceId& surface_id : blocked_surfaces_by_id) { 90 for (const SurfaceId& surface_id : blocked_surfaces_by_id) {
83 Surface* blocked_surface = surface_manager_->GetSurfaceForId(surface_id); 91 Surface* blocked_surface = surface_manager_->GetSurfaceForId(surface_id);
84 if (!blocked_surface) { 92 if (!blocked_surface) {
85 // A blocked surface may have been garbage collected during dependency 93 // A blocked surface may have been garbage collected during dependency
86 // resolution. 94 // resolution.
87 DCHECK(!observed_surfaces_by_id_.count(surface_id)); 95 DCHECK(!observed_surfaces_by_id_.count(surface_id));
88 continue; 96 continue;
89 } 97 }
90 // Clear all tracked blockers for |blocked_surface|. 98 // Clear all tracked blockers for |blocked_surface|.
91 for (const SurfaceId& blocking_surface_id : 99 for (const SurfaceId& blocking_surface_id :
92 blocked_surface->blocking_surfaces()) 100 blocked_surface->blocking_surfaces()) {
101 // If we are not activating this blocker now, then it's late.
102 if (!blocked_surfaces_by_id.count(blocking_surface_id))
103 late_surfaces_by_id_.insert(blocking_surface_id);
93 blocked_surfaces_from_dependency_[blocking_surface_id].erase(surface_id); 104 blocked_surfaces_from_dependency_[blocking_surface_id].erase(surface_id);
105 }
94 blocked_surface->ActivatePendingFrameForDeadline(); 106 blocked_surface->ActivatePendingFrameForDeadline();
95 } 107 }
96 108
97 frames_since_deadline_set_.reset(); 109 frames_since_deadline_set_.reset();
98 } 110 }
99 111
100 const BeginFrameArgs& SurfaceDependencyTracker::LastUsedBeginFrameArgs() const { 112 const BeginFrameArgs& SurfaceDependencyTracker::LastUsedBeginFrameArgs() const {
101 return last_begin_frame_args_; 113 return last_begin_frame_args_;
102 } 114 }
103 115
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 // A blocked surface may have been garbage collected during dependency 214 // A blocked surface may have been garbage collected during dependency
203 // resolution. 215 // resolution.
204 DCHECK(!observed_surfaces_by_id_.count(blocked_surface_by_id)); 216 DCHECK(!observed_surfaces_by_id_.count(blocked_surface_by_id));
205 continue; 217 continue;
206 } 218 }
207 blocked_surface->NotifySurfaceIdAvailable(surface_id); 219 blocked_surface->NotifySurfaceIdAvailable(surface_id);
208 } 220 }
209 } 221 }
210 222
211 } // namespace cc 223 } // namespace cc
OLDNEW
« no previous file with comments | « cc/surfaces/surface_dependency_tracker.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698