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" |
11 #include "cc/output/output_surface.h" | 11 #include "cc/output/output_surface.h" |
12 #include "cc/quads/draw_quad.h" | 12 #include "cc/quads/draw_quad.h" |
13 #include "cc/resources/prioritized_resource_manager.h" | 13 #include "cc/resources/prioritized_resource_manager.h" |
14 #include "cc/resources/resource_update_controller.h" | 14 #include "cc/resources/resource_update_controller.h" |
15 #include "cc/trees/layer_tree_host.h" | 15 #include "cc/trees/layer_tree_host.h" |
16 #include "cc/trees/layer_tree_host_single_thread_client.h" | 16 #include "cc/trees/layer_tree_host_single_thread_client.h" |
17 #include "cc/trees/layer_tree_impl.h" | 17 #include "cc/trees/layer_tree_impl.h" |
18 #include "cc/trees/scoped_abort_remaining_swap_promises.h" | 18 #include "cc/trees/scoped_abort_remaining_swap_promises.h" |
19 #include "ui/gfx/frame_time.h" | 19 #include "ui/gfx/frame_time.h" |
20 | 20 |
21 namespace cc { | 21 namespace cc { |
22 | 22 |
23 scoped_ptr<Proxy> SingleThreadProxy::Create( | 23 scoped_ptr<Proxy> SingleThreadProxy::Create( |
24 LayerTreeHost* layer_tree_host, | 24 LayerTreeHost* layer_tree_host, |
25 LayerTreeHostSingleThreadClient* client, | 25 LayerTreeHostSingleThreadClient* client, |
26 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner) { | 26 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
27 return make_scoped_ptr( | 27 scoped_ptr<BeginFrameSource> external_begin_frame_source) { |
28 new SingleThreadProxy(layer_tree_host, client, main_task_runner)); | 28 return make_scoped_ptr(new SingleThreadProxy( |
| 29 layer_tree_host, |
| 30 client, |
| 31 main_task_runner, |
| 32 external_begin_frame_source.Pass())); |
29 } | 33 } |
30 | 34 |
31 SingleThreadProxy::SingleThreadProxy( | 35 SingleThreadProxy::SingleThreadProxy( |
32 LayerTreeHost* layer_tree_host, | 36 LayerTreeHost* layer_tree_host, |
33 LayerTreeHostSingleThreadClient* client, | 37 LayerTreeHostSingleThreadClient* client, |
34 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner) | 38 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
| 39 scoped_ptr<BeginFrameSource> external_begin_frame_source) |
35 : Proxy(main_task_runner, NULL), | 40 : Proxy(main_task_runner, NULL), |
36 layer_tree_host_(layer_tree_host), | 41 layer_tree_host_(layer_tree_host), |
37 client_(client), | 42 client_(client), |
38 timing_history_(layer_tree_host->rendering_stats_instrumentation()), | 43 timing_history_(layer_tree_host->rendering_stats_instrumentation()), |
39 next_frame_is_newly_committed_frame_(false), | 44 next_frame_is_newly_committed_frame_(false), |
40 inside_draw_(false), | 45 inside_draw_(false), |
41 defer_commits_(false), | 46 defer_commits_(false), |
42 commit_was_deferred_(false), | 47 commit_was_deferred_(false), |
43 commit_requested_(false), | 48 commit_requested_(false), |
44 inside_synchronous_composite_(false), | 49 inside_synchronous_composite_(false), |
45 output_surface_creation_requested_(false), | 50 output_surface_creation_requested_(false), |
| 51 external_begin_frame_source_(external_begin_frame_source.Pass()), |
46 weak_factory_(this) { | 52 weak_factory_(this) { |
47 TRACE_EVENT0("cc", "SingleThreadProxy::SingleThreadProxy"); | 53 TRACE_EVENT0("cc", "SingleThreadProxy::SingleThreadProxy"); |
48 DCHECK(Proxy::IsMainThread()); | 54 DCHECK(Proxy::IsMainThread()); |
49 DCHECK(layer_tree_host); | 55 DCHECK(layer_tree_host); |
50 } | 56 } |
51 | 57 |
52 void SingleThreadProxy::Start() { | 58 void SingleThreadProxy::Start() { |
53 DebugScopedSetImplThread impl(this); | 59 DebugScopedSetImplThread impl(this); |
54 layer_tree_host_impl_ = layer_tree_host_->CreateLayerTreeHostImpl(this); | 60 layer_tree_host_impl_ = layer_tree_host_->CreateLayerTreeHostImpl(this); |
55 } | 61 } |
(...skipping 21 matching lines...) Expand all Loading... |
77 | 83 |
78 void SingleThreadProxy::SetLayerTreeHostClientReady() { | 84 void SingleThreadProxy::SetLayerTreeHostClientReady() { |
79 TRACE_EVENT0("cc", "SingleThreadProxy::SetLayerTreeHostClientReady"); | 85 TRACE_EVENT0("cc", "SingleThreadProxy::SetLayerTreeHostClientReady"); |
80 // Scheduling is controlled by the embedder in the single thread case, so | 86 // Scheduling is controlled by the embedder in the single thread case, so |
81 // nothing to do. | 87 // nothing to do. |
82 DCHECK(Proxy::IsMainThread()); | 88 DCHECK(Proxy::IsMainThread()); |
83 DebugScopedSetImplThread impl(this); | 89 DebugScopedSetImplThread impl(this); |
84 if (layer_tree_host_->settings().single_thread_proxy_scheduler && | 90 if (layer_tree_host_->settings().single_thread_proxy_scheduler && |
85 !scheduler_on_impl_thread_) { | 91 !scheduler_on_impl_thread_) { |
86 SchedulerSettings scheduler_settings(layer_tree_host_->settings()); | 92 SchedulerSettings scheduler_settings(layer_tree_host_->settings()); |
87 scheduler_on_impl_thread_ = Scheduler::Create(this, | 93 scheduler_on_impl_thread_ = |
88 scheduler_settings, | 94 Scheduler::Create(this, |
89 layer_tree_host_->id(), | 95 scheduler_settings, |
90 MainThreadTaskRunner(), | 96 layer_tree_host_->id(), |
91 base::PowerMonitor::Get()); | 97 MainThreadTaskRunner(), |
| 98 base::PowerMonitor::Get(), |
| 99 external_begin_frame_source_.Pass()); |
92 scheduler_on_impl_thread_->SetCanStart(); | 100 scheduler_on_impl_thread_->SetCanStart(); |
93 scheduler_on_impl_thread_->SetVisible(layer_tree_host_impl_->visible()); | 101 scheduler_on_impl_thread_->SetVisible(layer_tree_host_impl_->visible()); |
94 } | 102 } |
95 } | 103 } |
96 | 104 |
97 void SingleThreadProxy::SetVisible(bool visible) { | 105 void SingleThreadProxy::SetVisible(bool visible) { |
98 TRACE_EVENT0("cc", "SingleThreadProxy::SetVisible"); | 106 TRACE_EVENT0("cc", "SingleThreadProxy::SetVisible"); |
99 DebugScopedSetImplThread impl(this); | 107 DebugScopedSetImplThread impl(this); |
100 layer_tree_host_impl_->SetVisible(visible); | 108 layer_tree_host_impl_->SetVisible(visible); |
101 if (scheduler_on_impl_thread_) | 109 if (scheduler_on_impl_thread_) |
102 scheduler_on_impl_thread_->SetVisible(layer_tree_host_impl_->visible()); | 110 scheduler_on_impl_thread_->SetVisible(layer_tree_host_impl_->visible()); |
103 // Changing visibility could change ShouldComposite(). | 111 // Changing visibility could change ShouldComposite(). |
104 UpdateBackgroundAnimateTicking(); | |
105 } | 112 } |
106 | 113 |
107 void SingleThreadProxy::RequestNewOutputSurface() { | 114 void SingleThreadProxy::RequestNewOutputSurface() { |
108 DCHECK(Proxy::IsMainThread()); | 115 DCHECK(Proxy::IsMainThread()); |
109 DCHECK(layer_tree_host_->output_surface_lost()); | 116 DCHECK(layer_tree_host_->output_surface_lost()); |
110 output_surface_creation_callback_.Cancel(); | 117 output_surface_creation_callback_.Cancel(); |
111 if (output_surface_creation_requested_) | 118 if (output_surface_creation_requested_) |
112 return; | 119 return; |
113 output_surface_creation_requested_ = true; | 120 output_surface_creation_requested_ = true; |
114 layer_tree_host_->RequestNewOutputSurface(); | 121 layer_tree_host_->RequestNewOutputSurface(); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 client_->ScheduleAnimation(); | 161 client_->ScheduleAnimation(); |
155 SetNeedsCommit(); | 162 SetNeedsCommit(); |
156 } | 163 } |
157 | 164 |
158 void SingleThreadProxy::SetNeedsUpdateLayers() { | 165 void SingleThreadProxy::SetNeedsUpdateLayers() { |
159 TRACE_EVENT0("cc", "SingleThreadProxy::SetNeedsUpdateLayers"); | 166 TRACE_EVENT0("cc", "SingleThreadProxy::SetNeedsUpdateLayers"); |
160 DCHECK(Proxy::IsMainThread()); | 167 DCHECK(Proxy::IsMainThread()); |
161 SetNeedsCommit(); | 168 SetNeedsCommit(); |
162 } | 169 } |
163 | 170 |
| 171 void SingleThreadProxy::DoAnimate() { |
| 172 // Don't animate if there is no root layer. |
| 173 // TODO(mithro): Both Animate and UpdateAnimationState already have a |
| 174 // "!active_tree_->root_layer()" check? |
| 175 if (!layer_tree_host_impl_->active_tree()->root_layer()) { |
| 176 return; |
| 177 } |
| 178 |
| 179 layer_tree_host_impl_->Animate( |
| 180 layer_tree_host_impl_->CurrentBeginFrameArgs().frame_time); |
| 181 |
| 182 // If animations are not visible, update the animation state now as it |
| 183 // won't happen in DoComposite. |
| 184 if (!layer_tree_host_impl_->AnimationsAreVisible()) { |
| 185 layer_tree_host_impl_->UpdateAnimationState(true); |
| 186 } |
| 187 } |
| 188 |
164 void SingleThreadProxy::DoCommit() { | 189 void SingleThreadProxy::DoCommit() { |
165 TRACE_EVENT0("cc", "SingleThreadProxy::DoCommit"); | 190 TRACE_EVENT0("cc", "SingleThreadProxy::DoCommit"); |
166 DCHECK(Proxy::IsMainThread()); | 191 DCHECK(Proxy::IsMainThread()); |
167 | 192 |
168 commit_requested_ = false; | 193 commit_requested_ = false; |
169 layer_tree_host_->WillCommit(); | 194 layer_tree_host_->WillCommit(); |
170 | 195 |
171 // Commit immediately. | 196 // Commit immediately. |
172 { | 197 { |
173 DebugScopedSetMainThreadBlocked main_thread_blocked(this); | 198 DebugScopedSetMainThreadBlocked main_thread_blocked(this); |
(...skipping 21 matching lines...) Expand all Loading... |
195 layer_tree_host_impl_->resource_provider()); | 220 layer_tree_host_impl_->resource_provider()); |
196 update_controller->Finalize(); | 221 update_controller->Finalize(); |
197 | 222 |
198 if (layer_tree_host_impl_->EvictedUIResourcesExist()) | 223 if (layer_tree_host_impl_->EvictedUIResourcesExist()) |
199 layer_tree_host_->RecreateUIResources(); | 224 layer_tree_host_->RecreateUIResources(); |
200 | 225 |
201 layer_tree_host_->FinishCommitOnImplThread(layer_tree_host_impl_.get()); | 226 layer_tree_host_->FinishCommitOnImplThread(layer_tree_host_impl_.get()); |
202 | 227 |
203 layer_tree_host_impl_->CommitComplete(); | 228 layer_tree_host_impl_->CommitComplete(); |
204 | 229 |
205 UpdateBackgroundAnimateTicking(); | |
206 | |
207 #if DCHECK_IS_ON | 230 #if DCHECK_IS_ON |
208 // In the single-threaded case, the scale and scroll deltas should never be | 231 // In the single-threaded case, the scale and scroll deltas should never be |
209 // touched on the impl layer tree. | 232 // touched on the impl layer tree. |
210 scoped_ptr<ScrollAndScaleSet> scroll_info = | 233 scoped_ptr<ScrollAndScaleSet> scroll_info = |
211 layer_tree_host_impl_->ProcessScrollDeltas(); | 234 layer_tree_host_impl_->ProcessScrollDeltas(); |
212 DCHECK(!scroll_info->scrolls.size()); | 235 DCHECK(!scroll_info->scrolls.size()); |
213 DCHECK_EQ(1.f, scroll_info->page_scale_delta); | 236 DCHECK_EQ(1.f, scroll_info->page_scale_delta); |
214 #endif | 237 #endif |
215 | |
216 RenderingStatsInstrumentation* stats_instrumentation = | |
217 layer_tree_host_->rendering_stats_instrumentation(); | |
218 benchmark_instrumentation::IssueMainThreadRenderingStatsEvent( | |
219 stats_instrumentation->main_thread_rendering_stats()); | |
220 stats_instrumentation->AccumulateAndClearMainThreadStats(); | |
221 } | 238 } |
222 | 239 |
223 if (layer_tree_host_->settings().impl_side_painting) { | 240 if (layer_tree_host_->settings().impl_side_painting) { |
224 // TODO(enne): just commit directly to the active tree. | 241 // TODO(enne): just commit directly to the active tree. |
225 // | 242 // |
226 // Synchronously activate during commit to satisfy any potential | 243 // Synchronously activate during commit to satisfy any potential |
227 // SetNextCommitWaitsForActivation calls. Unfortunately, the tree | 244 // SetNextCommitWaitsForActivation calls. Unfortunately, the tree |
228 // might not be ready to draw, so DidActivateSyncTree must set | 245 // might not be ready to draw, so DidActivateSyncTree must set |
229 // the flag to force the tree to not draw until textures are ready. | 246 // the flag to force the tree to not draw until textures are ready. |
230 NotifyReadyToActivate(); | 247 NotifyReadyToActivate(); |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
321 scheduler_on_impl_thread_ = nullptr; | 338 scheduler_on_impl_thread_ = nullptr; |
322 layer_tree_host_impl_ = nullptr; | 339 layer_tree_host_impl_ = nullptr; |
323 } | 340 } |
324 layer_tree_host_ = NULL; | 341 layer_tree_host_ = NULL; |
325 } | 342 } |
326 | 343 |
327 void SingleThreadProxy::OnCanDrawStateChanged(bool can_draw) { | 344 void SingleThreadProxy::OnCanDrawStateChanged(bool can_draw) { |
328 TRACE_EVENT1( | 345 TRACE_EVENT1( |
329 "cc", "SingleThreadProxy::OnCanDrawStateChanged", "can_draw", can_draw); | 346 "cc", "SingleThreadProxy::OnCanDrawStateChanged", "can_draw", can_draw); |
330 DCHECK(Proxy::IsImplThread()); | 347 DCHECK(Proxy::IsImplThread()); |
331 UpdateBackgroundAnimateTicking(); | |
332 if (scheduler_on_impl_thread_) | 348 if (scheduler_on_impl_thread_) |
333 scheduler_on_impl_thread_->SetCanDraw(can_draw); | 349 scheduler_on_impl_thread_->SetCanDraw(can_draw); |
334 } | 350 } |
335 | 351 |
336 void SingleThreadProxy::NotifyReadyToActivate() { | 352 void SingleThreadProxy::NotifyReadyToActivate() { |
337 TRACE_EVENT0("cc", "SingleThreadProxy::NotifyReadyToActivate"); | 353 TRACE_EVENT0("cc", "SingleThreadProxy::NotifyReadyToActivate"); |
338 DebugScopedSetImplThread impl(this); | 354 DebugScopedSetImplThread impl(this); |
339 if (scheduler_on_impl_thread_) | 355 if (scheduler_on_impl_thread_) |
340 scheduler_on_impl_thread_->NotifyReadyToActivate(); | 356 scheduler_on_impl_thread_->NotifyReadyToActivate(); |
341 } | 357 } |
342 | 358 |
| 359 void SingleThreadProxy::NotifyReadyToDraw() { |
| 360 } |
| 361 |
343 void SingleThreadProxy::SetNeedsRedrawOnImplThread() { | 362 void SingleThreadProxy::SetNeedsRedrawOnImplThread() { |
344 client_->ScheduleComposite(); | 363 client_->ScheduleComposite(); |
345 if (scheduler_on_impl_thread_) | 364 if (scheduler_on_impl_thread_) |
346 scheduler_on_impl_thread_->SetNeedsRedraw(); | 365 scheduler_on_impl_thread_->SetNeedsRedraw(); |
347 } | 366 } |
348 | 367 |
349 void SingleThreadProxy::SetNeedsAnimateOnImplThread() { | 368 void SingleThreadProxy::SetNeedsAnimateOnImplThread() { |
350 SetNeedsRedrawOnImplThread(); | 369 client_->ScheduleComposite(); |
| 370 if (scheduler_on_impl_thread_) |
| 371 scheduler_on_impl_thread_->SetNeedsAnimate(); |
351 } | 372 } |
352 | 373 |
353 void SingleThreadProxy::SetNeedsManageTilesOnImplThread() { | 374 void SingleThreadProxy::SetNeedsManageTilesOnImplThread() { |
354 TRACE_EVENT0("cc", "SingleThreadProxy::SetNeedsManageTilesOnImplThread"); | 375 TRACE_EVENT0("cc", "SingleThreadProxy::SetNeedsManageTilesOnImplThread"); |
355 if (scheduler_on_impl_thread_) | 376 if (scheduler_on_impl_thread_) |
356 scheduler_on_impl_thread_->SetNeedsManageTiles(); | 377 scheduler_on_impl_thread_->SetNeedsManageTiles(); |
357 } | 378 } |
358 | 379 |
359 void SingleThreadProxy::SetNeedsRedrawRectOnImplThread( | 380 void SingleThreadProxy::SetNeedsRedrawRectOnImplThread( |
360 const gfx::Rect& damage_rect) { | 381 const gfx::Rect& damage_rect) { |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
413 // Since activation could cause tasks to run, post CommitComplete | 434 // Since activation could cause tasks to run, post CommitComplete |
414 // separately so that it runs after these tasks. This is the loose | 435 // separately so that it runs after these tasks. This is the loose |
415 // equivalent of blocking commit until activation and also running | 436 // equivalent of blocking commit until activation and also running |
416 // all tasks posted during commit/activation before CommitComplete. | 437 // all tasks posted during commit/activation before CommitComplete. |
417 MainThreadTaskRunner()->PostTask( | 438 MainThreadTaskRunner()->PostTask( |
418 FROM_HERE, | 439 FROM_HERE, |
419 base::Bind(&SingleThreadProxy::CommitComplete, | 440 base::Bind(&SingleThreadProxy::CommitComplete, |
420 weak_factory_.GetWeakPtr())); | 441 weak_factory_.GetWeakPtr())); |
421 } | 442 } |
422 | 443 |
423 UpdateBackgroundAnimateTicking(); | |
424 timing_history_.DidActivateSyncTree(); | 444 timing_history_.DidActivateSyncTree(); |
425 } | 445 } |
426 | 446 |
427 void SingleThreadProxy::DidManageTiles() { | 447 void SingleThreadProxy::DidManageTiles() { |
428 DCHECK(layer_tree_host_impl_->settings().impl_side_painting); | 448 DCHECK(layer_tree_host_impl_->settings().impl_side_painting); |
429 DCHECK(Proxy::IsImplThread()); | 449 DCHECK(Proxy::IsImplThread()); |
430 if (scheduler_on_impl_thread_) | 450 if (scheduler_on_impl_thread_) |
431 scheduler_on_impl_thread_->DidManageTiles(); | 451 scheduler_on_impl_thread_->DidManageTiles(); |
432 } | 452 } |
433 | 453 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
491 | 511 |
492 { | 512 { |
493 DebugScopedSetImplThread impl(const_cast<SingleThreadProxy*>(this)); | 513 DebugScopedSetImplThread impl(const_cast<SingleThreadProxy*>(this)); |
494 if (layer_tree_host_impl_->settings().impl_side_painting) { | 514 if (layer_tree_host_impl_->settings().impl_side_painting) { |
495 layer_tree_host_impl_->ActivateSyncTree(); | 515 layer_tree_host_impl_->ActivateSyncTree(); |
496 layer_tree_host_impl_->active_tree()->UpdateDrawProperties(); | 516 layer_tree_host_impl_->active_tree()->UpdateDrawProperties(); |
497 layer_tree_host_impl_->ManageTiles(); | 517 layer_tree_host_impl_->ManageTiles(); |
498 layer_tree_host_impl_->SynchronouslyInitializeAllTiles(); | 518 layer_tree_host_impl_->SynchronouslyInitializeAllTiles(); |
499 } | 519 } |
500 | 520 |
| 521 DoAnimate(); |
| 522 |
501 LayerTreeHostImpl::FrameData frame; | 523 LayerTreeHostImpl::FrameData frame; |
502 DoComposite(frame_begin_time, &frame); | 524 DoComposite(frame_begin_time, &frame); |
503 | 525 |
504 // DoComposite could abort, but because this is a synchronous composite | 526 // DoComposite could abort, but because this is a synchronous composite |
505 // another draw will never be scheduled, so break remaining promises. | 527 // another draw will never be scheduled, so break remaining promises. |
506 layer_tree_host_impl_->active_tree()->BreakSwapPromises( | 528 layer_tree_host_impl_->active_tree()->BreakSwapPromises( |
507 SwapPromise::SWAP_FAILS); | 529 SwapPromise::SWAP_FAILS); |
508 } | 530 } |
509 } | 531 } |
510 | 532 |
(...skipping 21 matching lines...) Expand all Loading... |
532 bool SingleThreadProxy::SupportsImplScrolling() const { | 554 bool SingleThreadProxy::SupportsImplScrolling() const { |
533 return false; | 555 return false; |
534 } | 556 } |
535 | 557 |
536 bool SingleThreadProxy::ShouldComposite() const { | 558 bool SingleThreadProxy::ShouldComposite() const { |
537 DCHECK(Proxy::IsImplThread()); | 559 DCHECK(Proxy::IsImplThread()); |
538 return layer_tree_host_impl_->visible() && | 560 return layer_tree_host_impl_->visible() && |
539 layer_tree_host_impl_->CanDraw(); | 561 layer_tree_host_impl_->CanDraw(); |
540 } | 562 } |
541 | 563 |
542 void SingleThreadProxy::UpdateBackgroundAnimateTicking() { | |
543 DCHECK(Proxy::IsImplThread()); | |
544 layer_tree_host_impl_->UpdateBackgroundAnimateTicking( | |
545 !ShouldComposite() && layer_tree_host_impl_->active_tree()->root_layer()); | |
546 } | |
547 | |
548 void SingleThreadProxy::ScheduleRequestNewOutputSurface() { | 564 void SingleThreadProxy::ScheduleRequestNewOutputSurface() { |
549 if (output_surface_creation_callback_.IsCancelled() && | 565 if (output_surface_creation_callback_.IsCancelled() && |
550 !output_surface_creation_requested_) { | 566 !output_surface_creation_requested_) { |
551 output_surface_creation_callback_.Reset( | 567 output_surface_creation_callback_.Reset( |
552 base::Bind(&SingleThreadProxy::RequestNewOutputSurface, | 568 base::Bind(&SingleThreadProxy::RequestNewOutputSurface, |
553 weak_factory_.GetWeakPtr())); | 569 weak_factory_.GetWeakPtr())); |
554 MainThreadTaskRunner()->PostTask( | 570 MainThreadTaskRunner()->PostTask( |
555 FROM_HERE, output_surface_creation_callback_.callback()); | 571 FROM_HERE, output_surface_creation_callback_.callback()); |
556 } | 572 } |
557 } | 573 } |
558 | 574 |
559 DrawResult SingleThreadProxy::DoComposite(base::TimeTicks frame_begin_time, | 575 DrawResult SingleThreadProxy::DoComposite(base::TimeTicks frame_begin_time, |
560 LayerTreeHostImpl::FrameData* frame) { | 576 LayerTreeHostImpl::FrameData* frame) { |
561 TRACE_EVENT0("cc", "SingleThreadProxy::DoComposite"); | 577 TRACE_EVENT0("cc", "SingleThreadProxy::DoComposite"); |
562 DCHECK(!layer_tree_host_->output_surface_lost()); | 578 DCHECK(!layer_tree_host_->output_surface_lost()); |
563 | 579 |
564 DrawResult draw_result; | 580 DrawResult draw_result; |
565 bool draw_frame; | 581 bool draw_frame; |
566 { | 582 { |
567 DebugScopedSetImplThread impl(this); | 583 DebugScopedSetImplThread impl(this); |
568 base::AutoReset<bool> mark_inside(&inside_draw_, true); | 584 base::AutoReset<bool> mark_inside(&inside_draw_, true); |
569 | 585 |
570 // We guard PrepareToDraw() with CanDraw() because it always returns a valid | 586 // We guard PrepareToDraw() with CanDraw() because it always returns a valid |
571 // frame, so can only be used when such a frame is possible. Since | 587 // frame, so can only be used when such a frame is possible. Since |
572 // DrawLayers() depends on the result of PrepareToDraw(), it is guarded on | 588 // DrawLayers() depends on the result of PrepareToDraw(), it is guarded on |
573 // CanDraw() as well. | 589 // CanDraw() as well. |
574 if (!ShouldComposite()) { | 590 if (!ShouldComposite()) { |
575 UpdateBackgroundAnimateTicking(); | |
576 return DRAW_ABORTED_CANT_DRAW; | 591 return DRAW_ABORTED_CANT_DRAW; |
577 } | 592 } |
578 | 593 |
579 timing_history_.DidStartDrawing(); | 594 timing_history_.DidStartDrawing(); |
580 | 595 |
581 layer_tree_host_impl_->Animate( | |
582 layer_tree_host_impl_->CurrentBeginFrameArgs().frame_time); | |
583 UpdateBackgroundAnimateTicking(); | |
584 | |
585 draw_result = layer_tree_host_impl_->PrepareToDraw(frame); | 596 draw_result = layer_tree_host_impl_->PrepareToDraw(frame); |
586 draw_frame = draw_result == DRAW_SUCCESS; | 597 draw_frame = draw_result == DRAW_SUCCESS; |
587 if (draw_frame) | 598 if (draw_frame) |
588 layer_tree_host_impl_->DrawLayers(frame, frame_begin_time); | 599 layer_tree_host_impl_->DrawLayers(frame, frame_begin_time); |
589 layer_tree_host_impl_->DidDrawAllLayers(*frame); | 600 layer_tree_host_impl_->DidDrawAllLayers(*frame); |
590 | 601 |
591 bool start_ready_animations = draw_frame; | 602 bool start_ready_animations = draw_frame; |
592 layer_tree_host_impl_->UpdateAnimationState(start_ready_animations); | 603 layer_tree_host_impl_->UpdateAnimationState(start_ready_animations); |
593 layer_tree_host_impl_->ResetCurrentBeginFrameArgsForNextFrame(); | 604 layer_tree_host_impl_->ResetCurrentBeginFrameArgsForNextFrame(); |
594 | 605 |
(...skipping 27 matching lines...) Expand all Loading... |
622 DebugScopedSetMainThread main(this); | 633 DebugScopedSetMainThread main(this); |
623 next_frame_is_newly_committed_frame_ = false; | 634 next_frame_is_newly_committed_frame_ = false; |
624 layer_tree_host_->DidCommitAndDrawFrame(); | 635 layer_tree_host_->DidCommitAndDrawFrame(); |
625 } | 636 } |
626 } | 637 } |
627 | 638 |
628 bool SingleThreadProxy::MainFrameWillHappenForTesting() { | 639 bool SingleThreadProxy::MainFrameWillHappenForTesting() { |
629 return false; | 640 return false; |
630 } | 641 } |
631 | 642 |
632 BeginFrameSource* SingleThreadProxy::ExternalBeginFrameSource() { | |
633 return layer_tree_host_impl_.get(); | |
634 } | |
635 | |
636 void SingleThreadProxy::WillBeginImplFrame(const BeginFrameArgs& args) { | 643 void SingleThreadProxy::WillBeginImplFrame(const BeginFrameArgs& args) { |
637 layer_tree_host_impl_->WillBeginImplFrame(args); | 644 layer_tree_host_impl_->WillBeginImplFrame(args); |
638 } | 645 } |
639 | 646 |
640 void SingleThreadProxy::ScheduledActionSendBeginMainFrame() { | 647 void SingleThreadProxy::ScheduledActionSendBeginMainFrame() { |
641 TRACE_EVENT0("cc", "SingleThreadProxy::ScheduledActionSendBeginMainFrame"); | 648 TRACE_EVENT0("cc", "SingleThreadProxy::ScheduledActionSendBeginMainFrame"); |
642 // Although this proxy is single-threaded, it's problematic to synchronously | 649 // Although this proxy is single-threaded, it's problematic to synchronously |
643 // have BeginMainFrame happen after ScheduledActionSendBeginMainFrame. This | 650 // have BeginMainFrame happen after ScheduledActionSendBeginMainFrame. This |
644 // could cause a commit to occur in between a series of SetNeedsCommit calls | 651 // could cause a commit to occur in between a series of SetNeedsCommit calls |
645 // (i.e. property modifications) causing some to fall on one frame and some to | 652 // (i.e. property modifications) causing some to fall on one frame and some to |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
735 return INVALID_RESULT; | 742 return INVALID_RESULT; |
736 } | 743 } |
737 | 744 |
738 void SingleThreadProxy::ScheduledActionCommit() { | 745 void SingleThreadProxy::ScheduledActionCommit() { |
739 DebugScopedSetMainThread main(this); | 746 DebugScopedSetMainThread main(this); |
740 DoCommit(); | 747 DoCommit(); |
741 } | 748 } |
742 | 749 |
743 void SingleThreadProxy::ScheduledActionAnimate() { | 750 void SingleThreadProxy::ScheduledActionAnimate() { |
744 TRACE_EVENT0("cc", "ScheduledActionAnimate"); | 751 TRACE_EVENT0("cc", "ScheduledActionAnimate"); |
745 layer_tree_host_impl_->Animate( | 752 DebugScopedSetImplThread impl(this); |
746 layer_tree_host_impl_->CurrentBeginFrameArgs().frame_time); | 753 DoAnimate(); |
747 } | 754 } |
748 | 755 |
749 void SingleThreadProxy::ScheduledActionUpdateVisibleTiles() { | 756 void SingleThreadProxy::ScheduledActionUpdateVisibleTiles() { |
750 DebugScopedSetImplThread impl(this); | 757 DebugScopedSetImplThread impl(this); |
751 layer_tree_host_impl_->UpdateVisibleTiles(); | 758 layer_tree_host_impl_->UpdateVisibleTiles(); |
752 } | 759 } |
753 | 760 |
754 void SingleThreadProxy::ScheduledActionActivateSyncTree() { | 761 void SingleThreadProxy::ScheduledActionActivateSyncTree() { |
755 DebugScopedSetImplThread impl(this); | 762 DebugScopedSetImplThread impl(this); |
756 layer_tree_host_impl_->ActivateSyncTree(); | 763 layer_tree_host_impl_->ActivateSyncTree(); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
790 | 797 |
791 base::TimeDelta SingleThreadProxy::CommitToActivateDurationEstimate() { | 798 base::TimeDelta SingleThreadProxy::CommitToActivateDurationEstimate() { |
792 return timing_history_.CommitToActivateDurationEstimate(); | 799 return timing_history_.CommitToActivateDurationEstimate(); |
793 } | 800 } |
794 | 801 |
795 void SingleThreadProxy::DidBeginImplFrameDeadline() { | 802 void SingleThreadProxy::DidBeginImplFrameDeadline() { |
796 layer_tree_host_impl_->ResetCurrentBeginFrameArgsForNextFrame(); | 803 layer_tree_host_impl_->ResetCurrentBeginFrameArgsForNextFrame(); |
797 } | 804 } |
798 | 805 |
799 } // namespace cc | 806 } // namespace cc |
OLD | NEW |