| 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 previous_frame_surface_id_ = surface->surface_id(); | 52 previous_frame_surface_id_ = surface->surface_id(); |
| 53 } | 53 } |
| 54 | 54 |
| 55 void Surface::QueueFrame(CompositorFrame frame, const DrawCallback& callback) { | 55 void Surface::QueueFrame(CompositorFrame frame, const DrawCallback& callback) { |
| 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 // Receive and track the resources referenced from the CompositorFrame |
| 63 // regardless of whether it's pending or active. |
| 64 factory_->ReceiveFromChild(frame.resource_list); |
| 65 |
| 62 if (!blocking_surfaces_.empty()) { | 66 if (!blocking_surfaces_.empty()) { |
| 63 pending_frame_ = std::move(frame); | 67 pending_frame_ = std::move(frame); |
| 64 if (pending_frame_) { | 68 pending_referenced_surfaces_ = pending_frame_->metadata.referenced_surfaces; |
| 65 factory_->ReceiveFromChild(pending_frame_->resource_list); | 69 // Ask the surface manager to inform |this| when its dependencies are |
| 66 pending_referenced_surfaces_ = | 70 // resolved. |
| 67 pending_frame_->metadata.referenced_surfaces; | 71 factory_->manager()->RequestSurfaceResolution(this); |
| 68 // Ask the surface manager to inform |this| when its dependencies are | |
| 69 // resolved. | |
| 70 factory_->manager()->RequestSurfaceResolution(this); | |
| 71 } | |
| 72 } else { | 72 } else { |
| 73 // If there are no blockers, then immediately activate the frame. | 73 // If there are no blockers, then immediately activate the frame. |
| 74 ActivateFrame(std::move(frame)); | 74 ActivateFrame(std::move(frame)); |
| 75 } | 75 } |
| 76 | 76 |
| 77 // Returns resources for the previous pending frame. | 77 // Returns resources for the previous pending frame. |
| 78 if (previous_pending_frame) | 78 if (previous_pending_frame) |
| 79 UnrefFrameResources(*previous_pending_frame); | 79 UnrefFrameResources(*previous_pending_frame); |
| 80 | 80 |
| 81 if (!draw_callback_.is_null()) | 81 if (!draw_callback_.is_null()) |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 // of blockers. | 145 // of blockers. |
| 146 blocking_surfaces_.clear(); | 146 blocking_surfaces_.clear(); |
| 147 ActivatePendingFrame(); | 147 ActivatePendingFrame(); |
| 148 } | 148 } |
| 149 | 149 |
| 150 void Surface::ActivatePendingFrame() { | 150 void Surface::ActivatePendingFrame() { |
| 151 DCHECK(pending_frame_); | 151 DCHECK(pending_frame_); |
| 152 ActivateFrame(std::move(pending_frame_.value())); | 152 ActivateFrame(std::move(pending_frame_.value())); |
| 153 pending_frame_.reset(); | 153 pending_frame_.reset(); |
| 154 pending_referenced_surfaces_.clear(); | 154 pending_referenced_surfaces_.clear(); |
| 155 // ActiveFrame resources are now double ref-ed. Unref. | |
| 156 UnrefFrameResources(*active_frame_); | |
| 157 } | 155 } |
| 158 | 156 |
| 159 // A frame is activated if all its Surface ID dependences are active or a | 157 // A frame is activated if all its Surface ID dependences are active or a |
| 160 // deadline has hit and the frame was forcibly activated by the display | 158 // deadline has hit and the frame was forcibly activated by the display |
| 161 // compositor. | 159 // compositor. |
| 162 void Surface::ActivateFrame(CompositorFrame frame) { | 160 void Surface::ActivateFrame(CompositorFrame frame) { |
| 163 DCHECK(factory_); | 161 DCHECK(factory_); |
| 164 ClearCopyRequests(); | 162 ClearCopyRequests(); |
| 165 | 163 |
| 166 TakeLatencyInfo(&frame.metadata.latency_info); | 164 TakeLatencyInfo(&frame.metadata.latency_info); |
| 167 | 165 |
| 168 base::Optional<CompositorFrame> previous_frame = std::move(active_frame_); | 166 base::Optional<CompositorFrame> previous_frame = std::move(active_frame_); |
| 169 active_frame_ = std::move(frame); | 167 active_frame_ = std::move(frame); |
| 170 | 168 |
| 171 factory_->ReceiveFromChild(active_frame_->resource_list); | |
| 172 | |
| 173 // Empty frames shouldn't be drawn and shouldn't contribute damage, so don't | 169 // Empty frames shouldn't be drawn and shouldn't contribute damage, so don't |
| 174 // increment frame index for them. | 170 // increment frame index for them. |
| 175 if (!active_frame_->render_pass_list.empty()) | 171 if (!active_frame_->render_pass_list.empty()) |
| 176 ++frame_index_; | 172 ++frame_index_; |
| 177 | 173 |
| 178 previous_frame_surface_id_ = surface_id(); | 174 previous_frame_surface_id_ = surface_id(); |
| 179 | 175 |
| 180 if (previous_frame) | 176 if (previous_frame) |
| 181 UnrefFrameResources(*previous_frame); | 177 UnrefFrameResources(*previous_frame); |
| 182 | 178 |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 310 void Surface::ClearCopyRequests() { | 306 void Surface::ClearCopyRequests() { |
| 311 if (active_frame_) { | 307 if (active_frame_) { |
| 312 for (const auto& render_pass : active_frame_->render_pass_list) { | 308 for (const auto& render_pass : active_frame_->render_pass_list) { |
| 313 for (const auto& copy_request : render_pass->copy_requests) | 309 for (const auto& copy_request : render_pass->copy_requests) |
| 314 copy_request->SendEmptyResult(); | 310 copy_request->SendEmptyResult(); |
| 315 } | 311 } |
| 316 } | 312 } |
| 317 } | 313 } |
| 318 | 314 |
| 319 } // namespace cc | 315 } // namespace cc |
| OLD | NEW |