Chromium Code Reviews| Index: content/browser/android/in_process/synchronous_compositor_impl.cc |
| diff --git a/content/browser/android/in_process/synchronous_compositor_impl.cc b/content/browser/android/in_process/synchronous_compositor_impl.cc |
| index e76b36b85be6b0e5698c9c5d4e4b12d82f50ad7a..2fe57eb57d9cbdd1e77f2e348c663bd7a9dac097 100644 |
| --- a/content/browser/android/in_process/synchronous_compositor_impl.cc |
| +++ b/content/browser/android/in_process/synchronous_compositor_impl.cc |
| @@ -74,6 +74,8 @@ SynchronousCompositorImpl::SynchronousCompositorImpl(WebContents* contents) |
| routing_id_(contents->GetRoutingID()), |
| input_handler_(NULL), |
| invoking_composite_(false), |
| + is_active_(false), |
| + renderer_needs_begin_frames_(false), |
| weak_ptr_factory_(this) { |
| DCHECK(contents); |
| DCHECK_NE(routing_id_, MSG_ROUTING_NONE); |
| @@ -120,11 +122,14 @@ void SynchronousCompositorImpl::DidInitializeRendererObjects( |
| begin_frame_source_ = begin_frame_source; |
| begin_frame_source_->SetCompositor(this); |
| - output_surface_->SetBeginFrameSource(begin_frame_source_); |
| + output_surface_->SetCompositor(this); |
| + |
| output_surface_->SetTreeActivationCallback( |
| base::Bind(&SynchronousCompositorImpl::DidActivatePendingTree, |
| weak_ptr_factory_.GetWeakPtr())); |
| - NeedsBeginFramesChanged(); |
| + |
| + OnNeedsBeginFramesChange(begin_frame_source_->NeedsBeginFrames()); |
|
boliu
2015/02/11 02:28:14
Move this to BFS::SetCompositor
|
| + |
| compositor_client_->DidInitializeCompositor(this); |
| } |
| @@ -133,7 +138,7 @@ void SynchronousCompositorImpl::DidDestroyRendererObjects() { |
| DCHECK(begin_frame_source_); |
| begin_frame_source_->SetCompositor(nullptr); |
| - output_surface_->SetBeginFrameSource(nullptr); |
| + output_surface_->SetCompositor(nullptr); |
| if (compositor_client_) |
| compositor_client_->DidDestroyCompositor(this); |
| compositor_client_ = nullptr; |
| @@ -183,6 +188,7 @@ scoped_ptr<cc::CompositorFrame> SynchronousCompositorImpl::DemandDrawHw( |
| base::AutoReset<bool> invoking_composite_resetter(&invoking_composite_, |
| true); |
| + |
| scoped_ptr<cc::CompositorFrame> frame = |
| output_surface_->DemandDrawHw(surface_size, |
| transform, |
| @@ -190,12 +196,10 @@ scoped_ptr<cc::CompositorFrame> SynchronousCompositorImpl::DemandDrawHw( |
| clip, |
| viewport_rect_for_tile_priority, |
| transform_for_tile_priority); |
| + |
| if (frame.get()) |
| UpdateFrameMetaData(frame->metadata); |
| - compositor_client_->SetContinuousInvalidate( |
| - begin_frame_source_->NeedsBeginFrames()); |
| - |
| return frame.Pass(); |
| } |
| @@ -214,14 +218,13 @@ bool SynchronousCompositorImpl::DemandDrawSw(SkCanvas* canvas) { |
| base::AutoReset<bool> invoking_composite_resetter(&invoking_composite_, |
| true); |
| + |
| scoped_ptr<cc::CompositorFrame> frame = |
| output_surface_->DemandDrawSw(canvas); |
| + |
| if (frame.get()) |
| UpdateFrameMetaData(frame->metadata); |
| - compositor_client_->SetContinuousInvalidate( |
| - begin_frame_source_->NeedsBeginFrames()); |
| - |
| return !!frame.get(); |
| } |
| @@ -241,11 +244,45 @@ void SynchronousCompositorImpl::SetMemoryPolicy(size_t bytes_limit) { |
| output_surface_->SetMemoryPolicy(bytes_limit); |
| } |
| +void SynchronousCompositorImpl::PostInvalidate() { |
| + DCHECK(CalledOnValidThread()); |
| + DCHECK(compositor_client_); |
| + compositor_client_->PostInvalidate(); |
| +} |
| + |
| void SynchronousCompositorImpl::DidChangeRootLayerScrollOffset() { |
| if (input_handler_) |
| input_handler_->OnRootLayerDelegatedScrollOffsetChanged(); |
| } |
| +void SynchronousCompositorImpl::SetIsActive(bool is_active) { |
| + is_active_ = is_active; |
| + UpdateNeedsBeginFrames(); |
| +} |
| + |
| +void SynchronousCompositorImpl::OnNeedsBeginFramesChange( |
| + bool needs_begin_frames) { |
| + renderer_needs_begin_frames_ = needs_begin_frames; |
| + UpdateNeedsBeginFrames(); |
| +} |
| + |
| +void SynchronousCompositorImpl::SendBeginFrame(cc::BeginFrameArgs args) { |
| + DCHECK(begin_frame_source_); |
| + begin_frame_source_->SendBeginFrameOnAnimate(args); |
| +} |
| + |
| +void SynchronousCompositorImpl::SendBeginFrameOnDraw() { |
| + DCHECK(begin_frame_source_); |
| + begin_frame_source_->SendBeginFrameOnDraw(); |
| +} |
| + |
| +void SynchronousCompositorImpl::UpdateNeedsBeginFrames() { |
| + RenderWidgetHostViewAndroid* rwhv = static_cast<RenderWidgetHostViewAndroid*>( |
|
boliu
2015/02/11 02:28:14
nts and general comment I guess: should check life
|
| + contents_->GetRenderWidgetHostView()); |
| + if (rwhv) |
| + rwhv->OnSetNeedsBeginFrames(is_active_ && renderer_needs_begin_frames_); |
| +} |
| + |
| void SynchronousCompositorImpl::SetInputHandler( |
| cc::InputHandler* input_handler) { |
| DCHECK(CalledOnValidThread()); |
| @@ -275,18 +312,6 @@ void SynchronousCompositorImpl::DidStopFlinging() { |
| rwhv->DidStopFlinging(); |
| } |
| -void SynchronousCompositorImpl::NeedsBeginFramesChanged() const { |
| - DCHECK(CalledOnValidThread()); |
| - DCHECK(begin_frame_source_); |
| - if (invoking_composite_) |
| - return; |
| - |
| - if (compositor_client_) { |
| - compositor_client_->SetContinuousInvalidate( |
| - begin_frame_source_->NeedsBeginFrames()); |
| - } |
| -} |
| - |
| InputEventAckState SynchronousCompositorImpl::HandleInputEvent( |
| const blink::WebInputEvent& input_event) { |
| DCHECK(CalledOnValidThread()); |