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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 destruction_dependencies_.erase( | 160 destruction_dependencies_.erase( |
158 std::remove_if(destruction_dependencies_.begin(), | 161 std::remove_if(destruction_dependencies_.begin(), |
159 destruction_dependencies_.end(), | 162 destruction_dependencies_.end(), |
160 [sequences, valid_id_namespaces](SurfaceSequence seq) { | 163 [sequences, valid_id_namespaces](SurfaceSequence seq) { |
161 return (!!sequences->erase(seq) || | 164 return (!!sequences->erase(seq) || |
162 !valid_id_namespaces->count(seq.id_namespace)); | 165 !valid_id_namespaces->count(seq.id_namespace)); |
163 }), | 166 }), |
164 destruction_dependencies_.end()); | 167 destruction_dependencies_.end()); |
165 } | 168 } |
166 | 169 |
| 170 void Surface::AddBeginFrameSource(BeginFrameSource* begin_frame_source) { |
| 171 DCHECK(base::STLIsSorted(begin_frame_sources_)); |
| 172 DCHECK(!ContainsValue(begin_frame_sources_, begin_frame_source)); |
| 173 begin_frame_sources_.insert(begin_frame_source); |
| 174 UpdatePrimaryBeginFrameSource(); |
| 175 } |
| 176 |
| 177 void Surface::RemoveBeginFrameSource(BeginFrameSource* begin_frame_source) { |
| 178 size_t erase_count = begin_frame_sources_.erase(begin_frame_source); |
| 179 DCHECK_EQ(1u, erase_count); |
| 180 UpdatePrimaryBeginFrameSource(); |
| 181 } |
| 182 |
| 183 void Surface::UpdatePrimaryBeginFrameSource() { |
| 184 // Ensure the BeginFrameSources are sorted so our we make a stable decision |
| 185 // regarding which source is primary. |
| 186 // TODO(brianderson): Do something smarter based on coverage instead. |
| 187 DCHECK(base::STLIsSorted(begin_frame_sources_)); |
| 188 |
| 189 BeginFrameSource* primary_source = nullptr; |
| 190 if (!begin_frame_sources_.empty()) |
| 191 primary_source = *begin_frame_sources_.begin(); |
| 192 |
| 193 if (factory_) |
| 194 factory_->SetBeginFrameSource(surface_id_, primary_source); |
| 195 } |
| 196 |
167 void Surface::ClearCopyRequests() { | 197 void Surface::ClearCopyRequests() { |
168 if (current_frame_) { | 198 if (current_frame_) { |
169 for (const auto& render_pass : | 199 for (const auto& render_pass : |
170 current_frame_->delegated_frame_data->render_pass_list) { | 200 current_frame_->delegated_frame_data->render_pass_list) { |
171 for (const auto& copy_request : render_pass->copy_requests) | 201 for (const auto& copy_request : render_pass->copy_requests) |
172 copy_request->SendEmptyResult(); | 202 copy_request->SendEmptyResult(); |
173 } | 203 } |
174 } | 204 } |
175 } | 205 } |
176 | 206 |
177 } // namespace cc | 207 } // namespace cc |
OLD | NEW |