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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 void SingleThreadProxy::SetLayerTreeHostClientReady() { | 72 void SingleThreadProxy::SetLayerTreeHostClientReady() { |
73 TRACE_EVENT0("cc", "SingleThreadProxy::SetLayerTreeHostClientReady"); | 73 TRACE_EVENT0("cc", "SingleThreadProxy::SetLayerTreeHostClientReady"); |
74 // Scheduling is controlled by the embedder in the single thread case, so | 74 // Scheduling is controlled by the embedder in the single thread case, so |
75 // nothing to do. | 75 // nothing to do. |
76 } | 76 } |
77 | 77 |
78 void SingleThreadProxy::SetVisible(bool visible) { | 78 void SingleThreadProxy::SetVisible(bool visible) { |
79 TRACE_EVENT0("cc", "SingleThreadProxy::SetVisible"); | 79 TRACE_EVENT0("cc", "SingleThreadProxy::SetVisible"); |
80 DebugScopedSetImplThread impl(this); | 80 DebugScopedSetImplThread impl(this); |
81 layer_tree_host_impl_->SetVisible(visible); | 81 layer_tree_host_impl_->SetVisible(visible); |
82 | |
83 // Changing visibility could change ShouldComposite(). | |
84 UpdateBackgroundAnimateTicking(); | |
85 } | 82 } |
86 | 83 |
87 void SingleThreadProxy::CreateAndInitializeOutputSurface() { | 84 void SingleThreadProxy::CreateAndInitializeOutputSurface() { |
88 TRACE_EVENT0( | 85 TRACE_EVENT0( |
89 "cc", "SingleThreadProxy::CreateAndInitializeOutputSurface"); | 86 "cc", "SingleThreadProxy::CreateAndInitializeOutputSurface"); |
90 DCHECK(Proxy::IsMainThread()); | 87 DCHECK(Proxy::IsMainThread()); |
91 DCHECK(layer_tree_host_->output_surface_lost()); | 88 DCHECK(layer_tree_host_->output_surface_lost()); |
92 | 89 |
93 scoped_ptr<OutputSurface> output_surface = | 90 scoped_ptr<OutputSurface> output_surface = |
94 layer_tree_host_->CreateOutputSurface(); | 91 layer_tree_host_->CreateOutputSurface(); |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 layer_tree_host_impl_->resource_provider()); | 222 layer_tree_host_impl_->resource_provider()); |
226 layer_tree_host_impl_.reset(); | 223 layer_tree_host_impl_.reset(); |
227 } | 224 } |
228 layer_tree_host_ = NULL; | 225 layer_tree_host_ = NULL; |
229 } | 226 } |
230 | 227 |
231 void SingleThreadProxy::OnCanDrawStateChanged(bool can_draw) { | 228 void SingleThreadProxy::OnCanDrawStateChanged(bool can_draw) { |
232 TRACE_EVENT1( | 229 TRACE_EVENT1( |
233 "cc", "SingleThreadProxy::OnCanDrawStateChanged", "can_draw", can_draw); | 230 "cc", "SingleThreadProxy::OnCanDrawStateChanged", "can_draw", can_draw); |
234 DCHECK(Proxy::IsImplThread()); | 231 DCHECK(Proxy::IsImplThread()); |
235 UpdateBackgroundAnimateTicking(); | |
236 } | 232 } |
237 | 233 |
238 void SingleThreadProxy::NotifyReadyToActivate() { | 234 void SingleThreadProxy::NotifyReadyToActivate() { |
239 // Thread-only feature. | 235 // Thread-only feature. |
240 NOTREACHED(); | 236 NOTREACHED(); |
241 } | 237 } |
242 | 238 |
243 void SingleThreadProxy::SetNeedsRedrawOnImplThread() { | 239 void SingleThreadProxy::SetNeedsRedrawOnImplThread() { |
244 client_->ScheduleComposite(); | 240 client_->ScheduleComposite(); |
245 } | 241 } |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
405 } | 401 } |
406 } | 402 } |
407 } | 403 } |
408 | 404 |
409 bool SingleThreadProxy::ShouldComposite() const { | 405 bool SingleThreadProxy::ShouldComposite() const { |
410 DCHECK(Proxy::IsImplThread()); | 406 DCHECK(Proxy::IsImplThread()); |
411 return layer_tree_host_impl_->visible() && | 407 return layer_tree_host_impl_->visible() && |
412 layer_tree_host_impl_->CanDraw(); | 408 layer_tree_host_impl_->CanDraw(); |
413 } | 409 } |
414 | 410 |
415 void SingleThreadProxy::UpdateBackgroundAnimateTicking() { | |
416 DCHECK(Proxy::IsImplThread()); | |
417 layer_tree_host_impl_->UpdateBackgroundAnimateTicking( | |
418 !ShouldComposite() && layer_tree_host_impl_->active_tree()->root_layer()); | |
419 } | |
420 | |
421 bool SingleThreadProxy::DoComposite( | 411 bool SingleThreadProxy::DoComposite( |
422 base::TimeTicks frame_begin_time, | 412 base::TimeTicks frame_begin_time, |
423 LayerTreeHostImpl::FrameData* frame) { | 413 LayerTreeHostImpl::FrameData* frame) { |
424 TRACE_EVENT0("cc", "SingleThreadProxy::DoComposite"); | 414 TRACE_EVENT0("cc", "SingleThreadProxy::DoComposite"); |
425 DCHECK(!layer_tree_host_->output_surface_lost()); | 415 DCHECK(!layer_tree_host_->output_surface_lost()); |
426 | 416 |
427 bool lost_output_surface = false; | 417 bool lost_output_surface = false; |
428 { | 418 { |
429 DebugScopedSetImplThread impl(this); | 419 DebugScopedSetImplThread impl(this); |
430 base::AutoReset<bool> mark_inside(&inside_draw_, true); | 420 base::AutoReset<bool> mark_inside(&inside_draw_, true); |
431 | 421 |
432 // We guard PrepareToDraw() with CanDraw() because it always returns a valid | 422 // We guard PrepareToDraw() with CanDraw() because it always returns a valid |
433 // frame, so can only be used when such a frame is possible. Since | 423 // frame, so can only be used when such a frame is possible. Since |
434 // DrawLayers() depends on the result of PrepareToDraw(), it is guarded on | 424 // DrawLayers() depends on the result of PrepareToDraw(), it is guarded on |
435 // CanDraw() as well. | 425 // CanDraw() as well. |
436 if (!ShouldComposite()) { | 426 if (!ShouldComposite()) { |
437 UpdateBackgroundAnimateTicking(); | |
438 return false; | 427 return false; |
439 } | 428 } |
440 | 429 |
441 layer_tree_host_impl_->Animate( | 430 layer_tree_host_impl_->Animate( |
442 layer_tree_host_impl_->CurrentFrameTimeTicks()); | 431 layer_tree_host_impl_->CurrentFrameTimeTicks()); |
443 UpdateBackgroundAnimateTicking(); | |
444 | 432 |
445 if (!layer_tree_host_impl_->IsContextLost()) { | 433 if (!layer_tree_host_impl_->IsContextLost()) { |
446 layer_tree_host_impl_->PrepareToDraw(frame); | 434 layer_tree_host_impl_->PrepareToDraw(frame); |
447 layer_tree_host_impl_->DrawLayers(frame, frame_begin_time); | 435 layer_tree_host_impl_->DrawLayers(frame, frame_begin_time); |
448 layer_tree_host_impl_->DidDrawAllLayers(*frame); | 436 layer_tree_host_impl_->DidDrawAllLayers(*frame); |
449 } | 437 } |
450 lost_output_surface = layer_tree_host_impl_->IsContextLost(); | 438 lost_output_surface = layer_tree_host_impl_->IsContextLost(); |
451 | 439 |
452 bool start_ready_animations = true; | 440 bool start_ready_animations = true; |
453 layer_tree_host_impl_->UpdateAnimationState(start_ready_animations); | 441 layer_tree_host_impl_->UpdateAnimationState(start_ready_animations); |
(...skipping 12 matching lines...) Expand all Loading... |
466 void SingleThreadProxy::DidSwapFrame() { | 454 void SingleThreadProxy::DidSwapFrame() { |
467 if (next_frame_is_newly_committed_frame_) { | 455 if (next_frame_is_newly_committed_frame_) { |
468 next_frame_is_newly_committed_frame_ = false; | 456 next_frame_is_newly_committed_frame_ = false; |
469 layer_tree_host_->DidCommitAndDrawFrame(); | 457 layer_tree_host_->DidCommitAndDrawFrame(); |
470 } | 458 } |
471 } | 459 } |
472 | 460 |
473 bool SingleThreadProxy::CommitPendingForTesting() { return false; } | 461 bool SingleThreadProxy::CommitPendingForTesting() { return false; } |
474 | 462 |
475 } // namespace cc | 463 } // namespace cc |
OLD | NEW |