OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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.h" | 5 #include "cc/surfaces/surface.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 base::Optional<CompositorFrame> previous_pending_frame = | 56 base::Optional<CompositorFrame> previous_pending_frame = |
57 std::move(pending_frame_); | 57 std::move(pending_frame_); |
58 pending_frame_.reset(); | 58 pending_frame_.reset(); |
59 | 59 |
60 UpdateBlockingSurfaces(previous_pending_frame, frame); | 60 UpdateBlockingSurfaces(previous_pending_frame, frame); |
61 | 61 |
62 if (!blocking_surfaces_.empty()) { | 62 if (!blocking_surfaces_.empty()) { |
63 pending_frame_ = std::move(frame); | 63 pending_frame_ = std::move(frame); |
64 if (pending_frame_) { | 64 if (pending_frame_) { |
65 factory_->ReceiveFromChild(pending_frame_->resource_list); | 65 factory_->ReceiveFromChild(pending_frame_->resource_list); |
| 66 pending_referenced_surfaces_ = |
| 67 pending_frame_->metadata.referenced_surfaces; |
66 // Ask the surface manager to inform |this| when its dependencies are | 68 // Ask the surface manager to inform |this| when its dependencies are |
67 // resolved. | 69 // resolved. |
68 factory_->manager()->RequestSurfaceResolution(this); | 70 factory_->manager()->RequestSurfaceResolution(this); |
69 } | 71 } |
70 } else { | 72 } else { |
71 // If there are no blockers, then immediately activate the frame. | 73 // If there are no blockers, then immediately activate the frame. |
72 ActivateFrame(std::move(frame)); | 74 ActivateFrame(std::move(frame)); |
73 } | 75 } |
74 | 76 |
75 // Returns resources for the previous pending frame. | 77 // Returns resources for the previous pending frame. |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 // If a frame is being activated because of a deadline, then clear its set | 144 // If a frame is being activated because of a deadline, then clear its set |
143 // of blockers. | 145 // of blockers. |
144 blocking_surfaces_.clear(); | 146 blocking_surfaces_.clear(); |
145 ActivatePendingFrame(); | 147 ActivatePendingFrame(); |
146 } | 148 } |
147 | 149 |
148 void Surface::ActivatePendingFrame() { | 150 void Surface::ActivatePendingFrame() { |
149 DCHECK(pending_frame_); | 151 DCHECK(pending_frame_); |
150 ActivateFrame(std::move(pending_frame_.value())); | 152 ActivateFrame(std::move(pending_frame_.value())); |
151 pending_frame_.reset(); | 153 pending_frame_.reset(); |
| 154 pending_referenced_surfaces_.clear(); |
152 // ActiveFrame resources are now double ref-ed. Unref. | 155 // ActiveFrame resources are now double ref-ed. Unref. |
153 UnrefFrameResources(*active_frame_); | 156 UnrefFrameResources(*active_frame_); |
154 } | 157 } |
155 | 158 |
156 // A frame is activated if all its Surface ID dependences are active or a | 159 // A frame is activated if all its Surface ID dependences are active or a |
157 // deadline has hit and the frame was forcibly activated by the display | 160 // deadline has hit and the frame was forcibly activated by the display |
158 // compositor. | 161 // compositor. |
159 void Surface::ActivateFrame(CompositorFrame frame) { | 162 void Surface::ActivateFrame(CompositorFrame frame) { |
160 DCHECK(factory_); | 163 DCHECK(factory_); |
161 ClearCopyRequests(); | 164 ClearCopyRequests(); |
162 | 165 |
163 TakeLatencyInfo(&frame.metadata.latency_info); | 166 TakeLatencyInfo(&frame.metadata.latency_info); |
164 | 167 |
165 base::Optional<CompositorFrame> previous_frame = std::move(active_frame_); | 168 base::Optional<CompositorFrame> previous_frame = std::move(active_frame_); |
166 active_frame_ = std::move(frame); | 169 active_frame_ = std::move(frame); |
167 | 170 |
168 factory_->ReceiveFromChild(active_frame_->resource_list); | 171 factory_->ReceiveFromChild(active_frame_->resource_list); |
169 | 172 |
170 // Empty frames shouldn't be drawn and shouldn't contribute damage, so don't | 173 // Empty frames shouldn't be drawn and shouldn't contribute damage, so don't |
171 // increment frame index for them. | 174 // increment frame index for them. |
172 if (!active_frame_->render_pass_list.empty()) | 175 if (!active_frame_->render_pass_list.empty()) |
173 ++frame_index_; | 176 ++frame_index_; |
174 | 177 |
175 previous_frame_surface_id_ = surface_id(); | 178 previous_frame_surface_id_ = surface_id(); |
176 | 179 |
177 if (previous_frame) | 180 if (previous_frame) |
178 UnrefFrameResources(*previous_frame); | 181 UnrefFrameResources(*previous_frame); |
179 | 182 |
180 referenced_surfaces_ = active_frame_->metadata.referenced_surfaces; | 183 active_referenced_surfaces_ = active_frame_->metadata.referenced_surfaces; |
181 | 184 |
182 for (auto& observer : observers_) | 185 for (auto& observer : observers_) |
183 observer.OnSurfaceActivated(this); | 186 observer.OnSurfaceActivated(this); |
184 } | 187 } |
185 | 188 |
186 void Surface::UpdateBlockingSurfaces( | 189 void Surface::UpdateBlockingSurfaces( |
187 const base::Optional<CompositorFrame>& previous_pending_frame, | 190 const base::Optional<CompositorFrame>& previous_pending_frame, |
188 const CompositorFrame& current_frame) { | 191 const CompositorFrame& current_frame) { |
189 // If there is no SurfaceDependencyTracker installed then the |current_frame| | 192 // If there is no SurfaceDependencyTracker installed then the |current_frame| |
190 // does not block on anything. | 193 // does not block on anything. |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 void Surface::ClearCopyRequests() { | 310 void Surface::ClearCopyRequests() { |
308 if (active_frame_) { | 311 if (active_frame_) { |
309 for (const auto& render_pass : active_frame_->render_pass_list) { | 312 for (const auto& render_pass : active_frame_->render_pass_list) { |
310 for (const auto& copy_request : render_pass->copy_requests) | 313 for (const auto& copy_request : render_pass->copy_requests) |
311 copy_request->SendEmptyResult(); | 314 copy_request->SendEmptyResult(); |
312 } | 315 } |
313 } | 316 } |
314 } | 317 } |
315 | 318 |
316 } // namespace cc | 319 } // namespace cc |
OLD | NEW |