Index: content/browser/compositor/delegated_frame_host.cc |
diff --git a/content/browser/compositor/delegated_frame_host.cc b/content/browser/compositor/delegated_frame_host.cc |
index c6657b7974e50224fff636414b9cc22e5d64418b..ea85703ffc415b46504b6f7fe22c95f633e1aaa8 100644 |
--- a/content/browser/compositor/delegated_frame_host.cc |
+++ b/content/browser/compositor/delegated_frame_host.cc |
@@ -61,6 +61,7 @@ DelegatedFrameHost::DelegatedFrameHost(DelegatedFrameHostClient* client) |
: client_(client), |
compositor_(nullptr), |
use_surfaces_(UseSurfacesEnabled()), |
+ current_begin_frame_source_(nullptr), |
tick_clock_(new base::DefaultTickClock()), |
last_output_surface_id_(0), |
pending_delegated_ack_count_(0), |
@@ -68,11 +69,28 @@ DelegatedFrameHost::DelegatedFrameHost(DelegatedFrameHostClient* client) |
current_scale_factor_(1.f), |
can_lock_compositor_(YES_CAN_LOCK), |
delegated_frame_evictor_(new DelegatedFrameEvictor(this)) { |
+ SetCurrentBeginFrameSource(nullptr); |
ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); |
factory->AddObserver(this); |
id_allocator_ = factory->GetContextFactory()->CreateSurfaceIdAllocator(); |
} |
+void DelegatedFrameHost::SetCurrentBeginFrameSource(BeginFrameSource* new_bfs) { |
+ if (!new_bfs) { |
+ // FIXME(mithro): Add a OrphanedBeginFrameSource |
+ // FIXME(mithro): We can probably figure out a better BeginFrameSource to use here using what the DelegatedFrameHost. |
+ new_bfs = OrphanedBeginFrameSource::getSource(); |
+ } |
+ |
+ // FIXME(mithro): This will need some of the BeginFrameSourceMultiplexer stuff.... |
+ if (new_bfs != current_begin_frame_source_) { |
+ if (current_begin_frame_source_) |
+ current_begin_frame_source_->RemoveObserver(this); |
+ current_begin_frame_source_ = new_bfs; |
+ current_begin_frame_source_->AddObserver(this); |
+ } |
+} |
+ |
void DelegatedFrameHost::WasShown(const ui::LatencyInfo& latency_info) { |
delegated_frame_evictor_->SetVisible(true); |
@@ -480,6 +498,11 @@ void DelegatedFrameHost::SwapDelegatedFrame( |
// Note: the frame may have been evicted immediately. |
} |
+void DelegatedFrameHost::SetBeginFrameSource(SurfaceId id, BeginFrameSource* new_bfs) { |
+ if (id != surface_id_) return; |
+ SetCurrentBeginFrameSource(new_bfs); |
+} |
+ |
void DelegatedFrameHost::SendDelegatedFrameAck(uint32 output_surface_id) { |
cc::CompositorFrameAck ack; |
if (!surface_returned_resources_.empty()) |
@@ -941,6 +964,10 @@ DelegatedFrameHost::~DelegatedFrameHost() { |
if (resource_collection_.get()) |
resource_collection_->SetClient(NULL); |
+ DCHECK_EQ(current_begin_frame_source_, OrphanBeginFrameSource::getSource()); |
+ current_begin_frame_source_->RemoveObserver(this); |
+ current_begin_frame_source_ = NULL; |
+ |
DCHECK(!vsync_manager_.get()); |
} |