| 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/debug/benchmark_instrumentation.h" | 9 #include "cc/debug/benchmark_instrumentation.h" |
| 10 #include "cc/output/context_provider.h" | 10 #include "cc/output/context_provider.h" |
| (...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 342 } | 342 } |
| 343 | 343 |
| 344 scoped_ptr<ResourceUpdateQueue> queue = | 344 scoped_ptr<ResourceUpdateQueue> queue = |
| 345 make_scoped_ptr(new ResourceUpdateQueue); | 345 make_scoped_ptr(new ResourceUpdateQueue); |
| 346 layer_tree_host_->UpdateLayers(queue.get()); | 346 layer_tree_host_->UpdateLayers(queue.get()); |
| 347 layer_tree_host_->WillCommit(); | 347 layer_tree_host_->WillCommit(); |
| 348 DoCommit(queue.Pass()); | 348 DoCommit(queue.Pass()); |
| 349 layer_tree_host_->DidBeginMainFrame(); | 349 layer_tree_host_->DidBeginMainFrame(); |
| 350 | 350 |
| 351 LayerTreeHostImpl::FrameData frame; | 351 LayerTreeHostImpl::FrameData frame; |
| 352 if (DoComposite(&frame)) { | 352 if (DoComposite(frame_begin_time, &frame)) { |
| 353 { | 353 { |
| 354 DebugScopedSetMainThreadBlocked main_thread_blocked(this); | 354 DebugScopedSetMainThreadBlocked main_thread_blocked(this); |
| 355 DebugScopedSetImplThread impl(this); | 355 DebugScopedSetImplThread impl(this); |
| 356 | 356 |
| 357 // This CapturePostTasks should be destroyed before | 357 // This CapturePostTasks should be destroyed before |
| 358 // DidCommitAndDrawFrame() is called since that goes out to the embedder, | 358 // DidCommitAndDrawFrame() is called since that goes out to the embedder, |
| 359 // and we want the embedder to receive its callbacks before that. | 359 // and we want the embedder to receive its callbacks before that. |
| 360 // NOTE: This maintains consistent ordering with the ThreadProxy since | 360 // NOTE: This maintains consistent ordering with the ThreadProxy since |
| 361 // the DidCommitAndDrawFrame() must be post-tasked from the impl thread | 361 // the DidCommitAndDrawFrame() must be post-tasked from the impl thread |
| 362 // there as the main thread is not blocked, so any posted tasks inside | 362 // there as the main thread is not blocked, so any posted tasks inside |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 403 layer_tree_host_impl_->CanDraw(); | 403 layer_tree_host_impl_->CanDraw(); |
| 404 } | 404 } |
| 405 | 405 |
| 406 void SingleThreadProxy::UpdateBackgroundAnimateTicking() { | 406 void SingleThreadProxy::UpdateBackgroundAnimateTicking() { |
| 407 DCHECK(Proxy::IsImplThread()); | 407 DCHECK(Proxy::IsImplThread()); |
| 408 layer_tree_host_impl_->UpdateBackgroundAnimateTicking( | 408 layer_tree_host_impl_->UpdateBackgroundAnimateTicking( |
| 409 !ShouldComposite() && layer_tree_host_impl_->active_tree()->root_layer()); | 409 !ShouldComposite() && layer_tree_host_impl_->active_tree()->root_layer()); |
| 410 } | 410 } |
| 411 | 411 |
| 412 bool SingleThreadProxy::DoComposite( | 412 bool SingleThreadProxy::DoComposite( |
| 413 base::TimeTicks frame_begin_time, |
| 413 LayerTreeHostImpl::FrameData* frame) { | 414 LayerTreeHostImpl::FrameData* frame) { |
| 414 TRACE_EVENT0("cc", "SingleThreadProxy::DoComposite"); | 415 TRACE_EVENT0("cc", "SingleThreadProxy::DoComposite"); |
| 415 DCHECK(!layer_tree_host_->output_surface_lost()); | 416 DCHECK(!layer_tree_host_->output_surface_lost()); |
| 416 | 417 |
| 417 bool lost_output_surface = false; | 418 bool lost_output_surface = false; |
| 418 { | 419 { |
| 419 DebugScopedSetImplThread impl(this); | 420 DebugScopedSetImplThread impl(this); |
| 420 base::AutoReset<bool> mark_inside(&inside_draw_, true); | 421 base::AutoReset<bool> mark_inside(&inside_draw_, true); |
| 421 | 422 |
| 422 // We guard PrepareToDraw() with CanDraw() because it always returns a valid | 423 // We guard PrepareToDraw() with CanDraw() because it always returns a valid |
| 423 // frame, so can only be used when such a frame is possible. Since | 424 // frame, so can only be used when such a frame is possible. Since |
| 424 // DrawLayers() depends on the result of PrepareToDraw(), it is guarded on | 425 // DrawLayers() depends on the result of PrepareToDraw(), it is guarded on |
| 425 // CanDraw() as well. | 426 // CanDraw() as well. |
| 426 if (!ShouldComposite()) { | 427 if (!ShouldComposite()) { |
| 427 UpdateBackgroundAnimateTicking(); | 428 UpdateBackgroundAnimateTicking(); |
| 428 return false; | 429 return false; |
| 429 } | 430 } |
| 430 | 431 |
| 431 layer_tree_host_impl_->Animate( | 432 layer_tree_host_impl_->Animate( |
| 432 layer_tree_host_impl_->CurrentFrameTimeTicks()); | 433 layer_tree_host_impl_->CurrentFrameTimeTicks()); |
| 433 UpdateBackgroundAnimateTicking(); | 434 UpdateBackgroundAnimateTicking(); |
| 434 | 435 |
| 435 if (!layer_tree_host_impl_->IsContextLost()) { | 436 if (!layer_tree_host_impl_->IsContextLost()) { |
| 436 layer_tree_host_impl_->PrepareToDraw(frame); | 437 layer_tree_host_impl_->PrepareToDraw(frame); |
| 437 layer_tree_host_impl_->DrawLayers(frame); | 438 layer_tree_host_impl_->DrawLayers(frame, frame_begin_time); |
| 438 layer_tree_host_impl_->DidDrawAllLayers(*frame); | 439 layer_tree_host_impl_->DidDrawAllLayers(*frame); |
| 439 } | 440 } |
| 440 lost_output_surface = layer_tree_host_impl_->IsContextLost(); | 441 lost_output_surface = layer_tree_host_impl_->IsContextLost(); |
| 441 | 442 |
| 442 bool start_ready_animations = true; | 443 bool start_ready_animations = true; |
| 443 layer_tree_host_impl_->UpdateAnimationState(start_ready_animations); | 444 layer_tree_host_impl_->UpdateAnimationState(start_ready_animations); |
| 444 | 445 |
| 445 layer_tree_host_impl_->ResetCurrentFrameTimeForNextFrame(); | 446 layer_tree_host_impl_->ResetCurrentFrameTimeForNextFrame(); |
| 446 } | 447 } |
| 447 | 448 |
| 448 if (lost_output_surface) { | 449 if (lost_output_surface) { |
| 449 layer_tree_host_->DidLoseOutputSurface(); | 450 layer_tree_host_->DidLoseOutputSurface(); |
| 450 return false; | 451 return false; |
| 451 } | 452 } |
| 452 | 453 |
| 453 return true; | 454 return true; |
| 454 } | 455 } |
| 455 | 456 |
| 456 void SingleThreadProxy::DidSwapFrame() { | 457 void SingleThreadProxy::DidSwapFrame() { |
| 457 if (next_frame_is_newly_committed_frame_) { | 458 if (next_frame_is_newly_committed_frame_) { |
| 458 next_frame_is_newly_committed_frame_ = false; | 459 next_frame_is_newly_committed_frame_ = false; |
| 459 layer_tree_host_->DidCommitAndDrawFrame(); | 460 layer_tree_host_->DidCommitAndDrawFrame(); |
| 460 } | 461 } |
| 461 } | 462 } |
| 462 | 463 |
| 463 bool SingleThreadProxy::CommitPendingForTesting() { return false; } | 464 bool SingleThreadProxy::CommitPendingForTesting() { return false; } |
| 464 | 465 |
| 465 } // namespace cc | 466 } // namespace cc |
| OLD | NEW |