| 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 <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "cc/output/compositor_frame.h" | 9 #include "cc/output/compositor_frame.h" |
| 10 #include "cc/output/copy_output_request.h" | 10 #include "cc/output/copy_output_request.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 ClearCopyRequests(); | 28 ClearCopyRequests(); |
| 29 if (current_frame_ && factory_) { | 29 if (current_frame_ && factory_) { |
| 30 ReturnedResourceArray current_resources; | 30 ReturnedResourceArray current_resources; |
| 31 TransferableResource::ReturnResources( | 31 TransferableResource::ReturnResources( |
| 32 current_frame_->delegated_frame_data->resource_list, | 32 current_frame_->delegated_frame_data->resource_list, |
| 33 ¤t_resources); | 33 ¤t_resources); |
| 34 factory_->UnrefResources(current_resources); | 34 factory_->UnrefResources(current_resources); |
| 35 } | 35 } |
| 36 if (!draw_callback_.is_null()) | 36 if (!draw_callback_.is_null()) |
| 37 draw_callback_.Run(SurfaceDrawStatus::DRAW_SKIPPED); | 37 draw_callback_.Run(SurfaceDrawStatus::DRAW_SKIPPED); |
| 38 |
| 39 if (factory_) |
| 40 factory_->SetBeginFrameSource(surface_id_, NULL); |
| 38 } | 41 } |
| 39 | 42 |
| 40 void Surface::QueueFrame(scoped_ptr<CompositorFrame> frame, | 43 void Surface::QueueFrame(scoped_ptr<CompositorFrame> frame, |
| 41 const DrawCallback& callback) { | 44 const DrawCallback& callback) { |
| 42 DCHECK(factory_); | 45 DCHECK(factory_); |
| 43 ClearCopyRequests(); | 46 ClearCopyRequests(); |
| 44 | 47 |
| 45 if (frame) { | 48 if (frame) { |
| 46 TakeLatencyInfo(&frame->metadata.latency_info); | 49 TakeLatencyInfo(&frame->metadata.latency_info); |
| 47 } | 50 } |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 destruction_dependencies_.erase( | 171 destruction_dependencies_.erase( |
| 169 std::remove_if(destruction_dependencies_.begin(), | 172 std::remove_if(destruction_dependencies_.begin(), |
| 170 destruction_dependencies_.end(), | 173 destruction_dependencies_.end(), |
| 171 [sequences, valid_id_namespaces](SurfaceSequence seq) { | 174 [sequences, valid_id_namespaces](SurfaceSequence seq) { |
| 172 return (!!sequences->erase(seq) || | 175 return (!!sequences->erase(seq) || |
| 173 !valid_id_namespaces->count(seq.id_namespace)); | 176 !valid_id_namespaces->count(seq.id_namespace)); |
| 174 }), | 177 }), |
| 175 destruction_dependencies_.end()); | 178 destruction_dependencies_.end()); |
| 176 } | 179 } |
| 177 | 180 |
| 181 void Surface::AddBeginFrameSource(BeginFrameSource* begin_frame_source) { |
| 182 DCHECK(base::STLIsSorted(begin_frame_sources_)); |
| 183 DCHECK(!ContainsValue(begin_frame_sources_, begin_frame_source)) |
| 184 << begin_frame_source; |
| 185 begin_frame_sources_.insert(begin_frame_source); |
| 186 UpdatePrimaryBeginFrameSource(); |
| 187 } |
| 188 |
| 189 void Surface::RemoveBeginFrameSource(BeginFrameSource* begin_frame_source) { |
| 190 size_t erase_count = begin_frame_sources_.erase(begin_frame_source); |
| 191 DCHECK_EQ(1u, erase_count); |
| 192 UpdatePrimaryBeginFrameSource(); |
| 193 } |
| 194 |
| 195 void Surface::UpdatePrimaryBeginFrameSource() { |
| 196 // Ensure the BeginFrameSources are sorted so our we make a stable decision |
| 197 // regarding which source is primary. |
| 198 // TODO(brianderson): Do something smarter based on coverage instead. |
| 199 DCHECK(base::STLIsSorted(begin_frame_sources_)); |
| 200 |
| 201 BeginFrameSource* primary_source = nullptr; |
| 202 if (!begin_frame_sources_.empty()) |
| 203 primary_source = *begin_frame_sources_.begin(); |
| 204 |
| 205 if (factory_) |
| 206 factory_->SetBeginFrameSource(surface_id_, primary_source); |
| 207 } |
| 208 |
| 178 void Surface::ClearCopyRequests() { | 209 void Surface::ClearCopyRequests() { |
| 179 if (current_frame_) { | 210 if (current_frame_) { |
| 180 for (const auto& render_pass : | 211 for (const auto& render_pass : |
| 181 current_frame_->delegated_frame_data->render_pass_list) { | 212 current_frame_->delegated_frame_data->render_pass_list) { |
| 182 for (const auto& copy_request : render_pass->copy_requests) | 213 for (const auto& copy_request : render_pass->copy_requests) |
| 183 copy_request->SendEmptyResult(); | 214 copy_request->SendEmptyResult(); |
| 184 } | 215 } |
| 185 } | 216 } |
| 186 } | 217 } |
| 187 | 218 |
| 188 } // namespace cc | 219 } // namespace cc |
| OLD | NEW |