OLD | NEW |
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 25 matching lines...) Expand all Loading... |
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_begin_frame = |
42 pending_frame.metadata.can_activate_before_dependencies; | 42 pending_frame.metadata.can_activate_before_dependencies; |
43 | 43 |
44 // Referenced surface IDs that aren't currently known to the surface manager | 44 // Referenced surface IDs that aren't currently known to the surface manager |
45 // or do not have an active CompsotiorFrame block this frame. | 45 // or do not have an active CompsotiorFrame block this frame. |
46 for (const SurfaceId& surface_id : | 46 for (const SurfaceId& surface_id : pending_frame.metadata.embedded_surfaces) { |
47 pending_frame.metadata.referenced_surfaces) { | |
48 Surface* surface_dependency = surface_manager_->GetSurfaceForId(surface_id); | 47 Surface* surface_dependency = surface_manager_->GetSurfaceForId(surface_id); |
49 if (!surface_dependency || !surface_dependency->HasActiveFrame()) | 48 if (!surface_dependency || !surface_dependency->HasActiveFrame()) |
50 blocked_surfaces_from_dependency_[surface_id].insert( | 49 blocked_surfaces_from_dependency_[surface_id].insert( |
51 surface->surface_id()); | 50 surface->surface_id()); |
52 } | 51 } |
53 | 52 |
54 if (!observed_surfaces_by_id_.count(surface->surface_id())) { | 53 if (!observed_surfaces_by_id_.count(surface->surface_id())) { |
55 surface->AddObserver(this); | 54 surface->AddObserver(this); |
56 observed_surfaces_by_id_.insert(surface->surface_id()); | 55 observed_surfaces_by_id_.insert(surface->surface_id()); |
57 } | 56 } |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 const std::vector<SurfaceId>* pending_referenced_surfaces) {} | 109 const std::vector<SurfaceId>* pending_referenced_surfaces) {} |
111 | 110 |
112 void SurfaceDependencyTracker::OnSurfaceDiscarded(Surface* surface) { | 111 void SurfaceDependencyTracker::OnSurfaceDiscarded(Surface* surface) { |
113 // If the surface being destroyed doesn't have a pending frame then we have | 112 // If the surface being destroyed doesn't have a pending frame then we have |
114 // nothing to do here. | 113 // nothing to do here. |
115 if (!surface->HasPendingFrame()) | 114 if (!surface->HasPendingFrame()) |
116 return; | 115 return; |
117 | 116 |
118 const CompositorFrame& pending_frame = surface->GetPendingFrame(); | 117 const CompositorFrame& pending_frame = surface->GetPendingFrame(); |
119 | 118 |
120 DCHECK(!pending_frame.metadata.referenced_surfaces.empty()); | 119 DCHECK(!pending_frame.metadata.embedded_surfaces.empty()); |
121 | 120 |
122 for (const SurfaceId& surface_id : | 121 for (const SurfaceId& surface_id : pending_frame.metadata.embedded_surfaces) { |
123 pending_frame.metadata.referenced_surfaces) { | |
124 auto it = blocked_surfaces_from_dependency_.find(surface_id); | 122 auto it = blocked_surfaces_from_dependency_.find(surface_id); |
125 if (it == blocked_surfaces_from_dependency_.end()) | 123 if (it == blocked_surfaces_from_dependency_.end()) |
126 continue; | 124 continue; |
127 | 125 |
128 auto& blocked_surface_ids = it->second; | 126 auto& blocked_surface_ids = it->second; |
129 auto blocked_surface_ids_it = | 127 auto blocked_surface_ids_it = |
130 blocked_surface_ids.find(surface->surface_id()); | 128 blocked_surface_ids.find(surface->surface_id()); |
131 if (blocked_surface_ids_it != blocked_surface_ids.end()) { | 129 if (blocked_surface_ids_it != blocked_surface_ids.end()) { |
132 blocked_surface_ids.erase(surface->surface_id()); | 130 blocked_surface_ids.erase(surface->surface_id()); |
133 if (blocked_surface_ids.empty()) | 131 if (blocked_surface_ids.empty()) |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 // A blocked surface may have been garbage collected during dependency | 207 // A blocked surface may have been garbage collected during dependency |
210 // resolution. | 208 // resolution. |
211 DCHECK(!observed_surfaces_by_id_.count(blocked_surface_by_id)); | 209 DCHECK(!observed_surfaces_by_id_.count(blocked_surface_by_id)); |
212 continue; | 210 continue; |
213 } | 211 } |
214 blocked_surface->NotifySurfaceIdAvailable(surface_id); | 212 blocked_surface->NotifySurfaceIdAvailable(surface_id); |
215 } | 213 } |
216 } | 214 } |
217 | 215 |
218 } // namespace cc | 216 } // namespace cc |
OLD | NEW |