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 21 matching lines...) Expand all Loading... |
32 ClearCopyRequests(); | 32 ClearCopyRequests(); |
33 if (current_frame_ && factory_) { | 33 if (current_frame_ && factory_) { |
34 ReturnedResourceArray current_resources; | 34 ReturnedResourceArray current_resources; |
35 TransferableResource::ReturnResources( | 35 TransferableResource::ReturnResources( |
36 current_frame_->delegated_frame_data->resource_list, | 36 current_frame_->delegated_frame_data->resource_list, |
37 ¤t_resources); | 37 ¤t_resources); |
38 factory_->UnrefResources(current_resources); | 38 factory_->UnrefResources(current_resources); |
39 } | 39 } |
40 if (!draw_callback_.is_null()) | 40 if (!draw_callback_.is_null()) |
41 draw_callback_.Run(SurfaceDrawStatus::DRAW_SKIPPED); | 41 draw_callback_.Run(SurfaceDrawStatus::DRAW_SKIPPED); |
42 | |
43 if (factory_) | |
44 factory_->SetBeginFrameSource(surface_id_, NULL); | |
45 } | 42 } |
46 | 43 |
47 void Surface::QueueFrame(scoped_ptr<CompositorFrame> frame, | 44 void Surface::QueueFrame(scoped_ptr<CompositorFrame> frame, |
48 const DrawCallback& callback) { | 45 const DrawCallback& callback) { |
49 DCHECK(factory_); | 46 DCHECK(factory_); |
50 ClearCopyRequests(); | 47 ClearCopyRequests(); |
51 | 48 |
52 if (frame) { | 49 if (frame) { |
53 TakeLatencyInfo(&frame->metadata.latency_info); | 50 TakeLatencyInfo(&frame->metadata.latency_info); |
54 } | 51 } |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 destruction_dependencies_.erase( | 168 destruction_dependencies_.erase( |
172 std::remove_if(destruction_dependencies_.begin(), | 169 std::remove_if(destruction_dependencies_.begin(), |
173 destruction_dependencies_.end(), | 170 destruction_dependencies_.end(), |
174 [sequences, valid_id_namespaces](SurfaceSequence seq) { | 171 [sequences, valid_id_namespaces](SurfaceSequence seq) { |
175 return (!!sequences->erase(seq) || | 172 return (!!sequences->erase(seq) || |
176 !valid_id_namespaces->count(seq.id_namespace)); | 173 !valid_id_namespaces->count(seq.id_namespace)); |
177 }), | 174 }), |
178 destruction_dependencies_.end()); | 175 destruction_dependencies_.end()); |
179 } | 176 } |
180 | 177 |
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 | |
209 void Surface::ClearCopyRequests() { | 178 void Surface::ClearCopyRequests() { |
210 if (current_frame_) { | 179 if (current_frame_) { |
211 for (const auto& render_pass : | 180 for (const auto& render_pass : |
212 current_frame_->delegated_frame_data->render_pass_list) { | 181 current_frame_->delegated_frame_data->render_pass_list) { |
213 for (const auto& copy_request : render_pass->copy_requests) | 182 for (const auto& copy_request : render_pass->copy_requests) |
214 copy_request->SendEmptyResult(); | 183 copy_request->SendEmptyResult(); |
215 } | 184 } |
216 } | 185 } |
217 } | 186 } |
218 | 187 |
219 } // namespace cc | 188 } // namespace cc |
OLD | NEW |