Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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/trees/single_thread_proxy.h" | 5 #include "cc/trees/single_thread_proxy.h" |
| 6 | 6 |
| 7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
| 9 #include "cc/output/context_provider.h" | 9 #include "cc/output/context_provider.h" |
| 10 #include "cc/output/output_surface.h" | 10 #include "cc/output/output_surface.h" |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 93 void SingleThreadProxy::SetLayerTreeHostClientReady() { | 93 void SingleThreadProxy::SetLayerTreeHostClientReady() { |
| 94 // Scheduling is controlled by the embedder in the single thread case, so | 94 // Scheduling is controlled by the embedder in the single thread case, so |
| 95 // nothing to do. | 95 // nothing to do. |
| 96 } | 96 } |
| 97 | 97 |
| 98 void SingleThreadProxy::SetVisible(bool visible) { | 98 void SingleThreadProxy::SetVisible(bool visible) { |
| 99 DebugScopedSetImplThread impl(this); | 99 DebugScopedSetImplThread impl(this); |
| 100 layer_tree_host_impl_->SetVisible(visible); | 100 layer_tree_host_impl_->SetVisible(visible); |
| 101 | 101 |
| 102 // Changing visibility could change ShouldComposite(). | 102 // Changing visibility could change ShouldComposite(). |
| 103 layer_tree_host_impl_->UpdateBackgroundAnimateTicking(!ShouldComposite()); | 103 UpdateBackgroundAnimateTicking(); |
| 104 } | 104 } |
| 105 | 105 |
| 106 void SingleThreadProxy::CreateAndInitializeOutputSurface() { | 106 void SingleThreadProxy::CreateAndInitializeOutputSurface() { |
| 107 TRACE_EVENT0( | 107 TRACE_EVENT0( |
| 108 "cc", "SingleThreadProxy::CreateAndInitializeOutputSurface"); | 108 "cc", "SingleThreadProxy::CreateAndInitializeOutputSurface"); |
| 109 DCHECK(Proxy::IsMainThread()); | 109 DCHECK(Proxy::IsMainThread()); |
| 110 | 110 |
| 111 scoped_ptr<OutputSurface> output_surface = first_output_surface_.Pass(); | 111 scoped_ptr<OutputSurface> output_surface = first_output_surface_.Pass(); |
| 112 if (!output_surface) | 112 if (!output_surface) |
| 113 output_surface = layer_tree_host_->CreateOutputSurface(); | 113 output_surface = layer_tree_host_->CreateOutputSurface(); |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 258 | 258 |
| 259 layer_tree_host_->DeleteContentsTexturesOnImplThread( | 259 layer_tree_host_->DeleteContentsTexturesOnImplThread( |
| 260 layer_tree_host_impl_->resource_provider()); | 260 layer_tree_host_impl_->resource_provider()); |
| 261 layer_tree_host_impl_.reset(); | 261 layer_tree_host_impl_.reset(); |
| 262 } | 262 } |
| 263 layer_tree_host_ = NULL; | 263 layer_tree_host_ = NULL; |
| 264 } | 264 } |
| 265 | 265 |
| 266 void SingleThreadProxy::OnCanDrawStateChanged(bool can_draw) { | 266 void SingleThreadProxy::OnCanDrawStateChanged(bool can_draw) { |
| 267 DCHECK(Proxy::IsImplThread()); | 267 DCHECK(Proxy::IsImplThread()); |
| 268 layer_tree_host_impl_->UpdateBackgroundAnimateTicking(!ShouldComposite()); | 268 UpdateBackgroundAnimateTicking(); |
| 269 } | 269 } |
| 270 | 270 |
| 271 void SingleThreadProxy::NotifyReadyToActivate() { | 271 void SingleThreadProxy::NotifyReadyToActivate() { |
| 272 // Thread-only feature. | 272 // Thread-only feature. |
| 273 NOTREACHED(); | 273 NOTREACHED(); |
| 274 } | 274 } |
| 275 | 275 |
| 276 void SingleThreadProxy::SetNeedsRedrawOnImplThread() { | 276 void SingleThreadProxy::SetNeedsRedrawOnImplThread() { |
| 277 layer_tree_host_->ScheduleComposite(); | 277 layer_tree_host_->ScheduleComposite(); |
| 278 } | 278 } |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 420 layer_tree_host_->DidBeginFrame(); | 420 layer_tree_host_->DidBeginFrame(); |
| 421 return result; | 421 return result; |
| 422 } | 422 } |
| 423 | 423 |
| 424 bool SingleThreadProxy::ShouldComposite() const { | 424 bool SingleThreadProxy::ShouldComposite() const { |
| 425 DCHECK(Proxy::IsImplThread()); | 425 DCHECK(Proxy::IsImplThread()); |
| 426 return layer_tree_host_impl_->visible() && | 426 return layer_tree_host_impl_->visible() && |
| 427 layer_tree_host_impl_->CanDraw(); | 427 layer_tree_host_impl_->CanDraw(); |
| 428 } | 428 } |
| 429 | 429 |
| 430 void SingleThreadProxy::UpdateBackgroundAnimateTicking() { | |
| 431 DCHECK(Proxy::IsImplThread()); | |
| 432 layer_tree_host_impl_->UpdateBackgroundAnimateTicking( | |
| 433 !ShouldComposite() && | |
| 434 layer_tree_host_impl_->active_tree()->root_layer()); | |
| 435 } | |
| 436 | |
| 430 bool SingleThreadProxy::DoComposite( | 437 bool SingleThreadProxy::DoComposite( |
| 431 scoped_refptr<cc::ContextProvider> offscreen_context_provider, | 438 scoped_refptr<cc::ContextProvider> offscreen_context_provider, |
| 432 base::TimeTicks frame_begin_time, | 439 base::TimeTicks frame_begin_time, |
| 433 gfx::Rect device_viewport_damage_rect, | 440 gfx::Rect device_viewport_damage_rect, |
| 434 bool for_readback, | 441 bool for_readback, |
| 435 LayerTreeHostImpl::FrameData* frame) { | 442 LayerTreeHostImpl::FrameData* frame) { |
| 436 DCHECK(!layer_tree_host_->output_surface_lost()); | 443 DCHECK(!layer_tree_host_->output_surface_lost()); |
| 437 | 444 |
| 438 bool lost_output_surface = false; | 445 bool lost_output_surface = false; |
| 439 { | 446 { |
| 440 DebugScopedSetImplThread impl(this); | 447 DebugScopedSetImplThread impl(this); |
| 441 base::AutoReset<bool> mark_inside(&inside_draw_, true); | 448 base::AutoReset<bool> mark_inside(&inside_draw_, true); |
| 442 | 449 |
| 443 layer_tree_host_impl_->SetOffscreenContextProvider( | 450 layer_tree_host_impl_->SetOffscreenContextProvider( |
| 444 offscreen_context_provider); | 451 offscreen_context_provider); |
| 445 | 452 |
| 446 bool can_do_readback = layer_tree_host_impl_->renderer()->CanReadPixels(); | 453 bool can_do_readback = layer_tree_host_impl_->renderer()->CanReadPixels(); |
| 447 | 454 |
| 448 // We guard PrepareToDraw() with CanDraw() because it always returns a valid | 455 // We guard PrepareToDraw() with CanDraw() because it always returns a valid |
| 449 // frame, so can only be used when such a frame is possible. Since | 456 // frame, so can only be used when such a frame is possible. Since |
| 450 // DrawLayers() depends on the result of PrepareToDraw(), it is guarded on | 457 // DrawLayers() depends on the result of PrepareToDraw(), it is guarded on |
| 451 // CanDraw() as well. | 458 // CanDraw() as well. |
| 452 if (!ShouldComposite() || (for_readback && !can_do_readback)) { | 459 if (!ShouldComposite() || (for_readback && !can_do_readback)) { |
| 453 layer_tree_host_impl_->UpdateBackgroundAnimateTicking(true); | 460 UpdateBackgroundAnimateTicking(); |
|
brianderson
2013/08/29 01:03:09
For the same reasons as in ThreadProxy, I do not a
| |
| 454 return false; | 461 return false; |
| 455 } | 462 } |
| 456 | 463 |
| 457 layer_tree_host_impl_->Animate( | 464 layer_tree_host_impl_->Animate( |
| 458 layer_tree_host_impl_->CurrentFrameTimeTicks(), | 465 layer_tree_host_impl_->CurrentFrameTimeTicks(), |
| 459 layer_tree_host_impl_->CurrentFrameTime()); | 466 layer_tree_host_impl_->CurrentFrameTime()); |
| 460 layer_tree_host_impl_->UpdateBackgroundAnimateTicking(false); | 467 UpdateBackgroundAnimateTicking(); |
| 461 | 468 |
| 462 layer_tree_host_impl_->PrepareToDraw(frame, device_viewport_damage_rect); | 469 layer_tree_host_impl_->PrepareToDraw(frame, device_viewport_damage_rect); |
| 463 layer_tree_host_impl_->DrawLayers(frame, frame_begin_time); | 470 layer_tree_host_impl_->DrawLayers(frame, frame_begin_time); |
| 464 layer_tree_host_impl_->DidDrawAllLayers(*frame); | 471 layer_tree_host_impl_->DidDrawAllLayers(*frame); |
| 465 lost_output_surface = layer_tree_host_impl_->IsContextLost(); | 472 lost_output_surface = layer_tree_host_impl_->IsContextLost(); |
| 466 | 473 |
| 467 bool start_ready_animations = true; | 474 bool start_ready_animations = true; |
| 468 layer_tree_host_impl_->UpdateAnimationState(start_ready_animations); | 475 layer_tree_host_impl_->UpdateAnimationState(start_ready_animations); |
| 469 | 476 |
| 470 layer_tree_host_impl_->ResetCurrentFrameTimeForNextFrame(); | 477 layer_tree_host_impl_->ResetCurrentFrameTimeForNextFrame(); |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 485 void SingleThreadProxy::DidSwapFrame() { | 492 void SingleThreadProxy::DidSwapFrame() { |
| 486 if (next_frame_is_newly_committed_frame_) { | 493 if (next_frame_is_newly_committed_frame_) { |
| 487 next_frame_is_newly_committed_frame_ = false; | 494 next_frame_is_newly_committed_frame_ = false; |
| 488 layer_tree_host_->DidCommitAndDrawFrame(); | 495 layer_tree_host_->DidCommitAndDrawFrame(); |
| 489 } | 496 } |
| 490 } | 497 } |
| 491 | 498 |
| 492 bool SingleThreadProxy::CommitPendingForTesting() { return false; } | 499 bool SingleThreadProxy::CommitPendingForTesting() { return false; } |
| 493 | 500 |
| 494 } // namespace cc | 501 } // namespace cc |
| OLD | NEW |