| Index: cc/surfaces/surface.cc
|
| diff --git a/cc/surfaces/surface.cc b/cc/surfaces/surface.cc
|
| index e3b0f5ecd5fbcb21bb87151a737e39b47dd7cdd8..0ffd522960fe16727a4534360e333d0d44d747d5 100644
|
| --- a/cc/surfaces/surface.cc
|
| +++ b/cc/surfaces/surface.cc
|
| @@ -35,6 +35,9 @@ Surface::~Surface() {
|
| }
|
| if (!draw_callback_.is_null())
|
| draw_callback_.Run(SurfaceDrawStatus::DRAW_SKIPPED);
|
| +
|
| + if (factory_)
|
| + factory_->SetBeginFrameSource(surface_id_, NULL);
|
| }
|
|
|
| void Surface::QueueFrame(scoped_ptr<CompositorFrame> frame,
|
| @@ -175,6 +178,34 @@ void Surface::SatisfyDestructionDependencies(
|
| destruction_dependencies_.end());
|
| }
|
|
|
| +void Surface::AddBeginFrameSource(BeginFrameSource* begin_frame_source) {
|
| + DCHECK(base::STLIsSorted(begin_frame_sources_));
|
| + DCHECK(!ContainsValue(begin_frame_sources_, begin_frame_source))
|
| + << begin_frame_source;
|
| + begin_frame_sources_.insert(begin_frame_source);
|
| + UpdatePrimaryBeginFrameSource();
|
| +}
|
| +
|
| +void Surface::RemoveBeginFrameSource(BeginFrameSource* begin_frame_source) {
|
| + size_t erase_count = begin_frame_sources_.erase(begin_frame_source);
|
| + DCHECK_EQ(1u, erase_count);
|
| + UpdatePrimaryBeginFrameSource();
|
| +}
|
| +
|
| +void Surface::UpdatePrimaryBeginFrameSource() {
|
| + // Ensure the BeginFrameSources are sorted so our we make a stable decision
|
| + // regarding which source is primary.
|
| + // TODO(brianderson): Do something smarter based on coverage instead.
|
| + DCHECK(base::STLIsSorted(begin_frame_sources_));
|
| +
|
| + BeginFrameSource* primary_source = nullptr;
|
| + if (!begin_frame_sources_.empty())
|
| + primary_source = *begin_frame_sources_.begin();
|
| +
|
| + if (factory_)
|
| + factory_->SetBeginFrameSource(surface_id_, primary_source);
|
| +}
|
| +
|
| void Surface::ClearCopyRequests() {
|
| if (current_frame_) {
|
| for (const auto& render_pass :
|
|
|