Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(507)

Side by Side Diff: cc/trees/single_thread_proxy.cc

Issue 713783002: Revert of Moving background animation ticking from LayerTreeHostImpl into the Scheduler. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@scheduler-timesource-refactor
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/trees/single_thread_proxy.h ('k') | cc/trees/thread_proxy.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 } 94 }
95 } 95 }
96 96
97 void SingleThreadProxy::SetVisible(bool visible) { 97 void SingleThreadProxy::SetVisible(bool visible) {
98 TRACE_EVENT0("cc", "SingleThreadProxy::SetVisible"); 98 TRACE_EVENT0("cc", "SingleThreadProxy::SetVisible");
99 DebugScopedSetImplThread impl(this); 99 DebugScopedSetImplThread impl(this);
100 layer_tree_host_impl_->SetVisible(visible); 100 layer_tree_host_impl_->SetVisible(visible);
101 if (scheduler_on_impl_thread_) 101 if (scheduler_on_impl_thread_)
102 scheduler_on_impl_thread_->SetVisible(layer_tree_host_impl_->visible()); 102 scheduler_on_impl_thread_->SetVisible(layer_tree_host_impl_->visible());
103 // Changing visibility could change ShouldComposite(). 103 // Changing visibility could change ShouldComposite().
104 UpdateBackgroundAnimateTicking();
104 } 105 }
105 106
106 void SingleThreadProxy::RequestNewOutputSurface() { 107 void SingleThreadProxy::RequestNewOutputSurface() {
107 DCHECK(Proxy::IsMainThread()); 108 DCHECK(Proxy::IsMainThread());
108 DCHECK(layer_tree_host_->output_surface_lost()); 109 DCHECK(layer_tree_host_->output_surface_lost());
109 output_surface_creation_callback_.Cancel(); 110 output_surface_creation_callback_.Cancel();
110 if (output_surface_creation_requested_) 111 if (output_surface_creation_requested_)
111 return; 112 return;
112 output_surface_creation_requested_ = true; 113 output_surface_creation_requested_ = true;
113 layer_tree_host_->RequestNewOutputSurface(); 114 layer_tree_host_->RequestNewOutputSurface();
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 client_->ScheduleAnimation(); 154 client_->ScheduleAnimation();
154 SetNeedsCommit(); 155 SetNeedsCommit();
155 } 156 }
156 157
157 void SingleThreadProxy::SetNeedsUpdateLayers() { 158 void SingleThreadProxy::SetNeedsUpdateLayers() {
158 TRACE_EVENT0("cc", "SingleThreadProxy::SetNeedsUpdateLayers"); 159 TRACE_EVENT0("cc", "SingleThreadProxy::SetNeedsUpdateLayers");
159 DCHECK(Proxy::IsMainThread()); 160 DCHECK(Proxy::IsMainThread());
160 SetNeedsCommit(); 161 SetNeedsCommit();
161 } 162 }
162 163
163 void SingleThreadProxy::DoAnimate() {
164 // Don't animate if there is no root layer.
165 // TODO(mithro): Both Animate and UpdateAnimationState already have a
166 // "!active_tree_->root_layer()" check?
167 if (!layer_tree_host_impl_->active_tree()->root_layer()) {
168 return;
169 }
170
171 layer_tree_host_impl_->Animate(
172 layer_tree_host_impl_->CurrentBeginFrameArgs().frame_time);
173
174 // If animations are not visible, update the animation state now as it
175 // won't happen in DoComposite.
176 if (!layer_tree_host_impl_->AnimationsAreVisible()) {
177 layer_tree_host_impl_->UpdateAnimationState(true);
178 }
179 }
180
181 void SingleThreadProxy::DoCommit() { 164 void SingleThreadProxy::DoCommit() {
182 TRACE_EVENT0("cc", "SingleThreadProxy::DoCommit"); 165 TRACE_EVENT0("cc", "SingleThreadProxy::DoCommit");
183 DCHECK(Proxy::IsMainThread()); 166 DCHECK(Proxy::IsMainThread());
184 167
185 commit_requested_ = false; 168 commit_requested_ = false;
186 layer_tree_host_->WillCommit(); 169 layer_tree_host_->WillCommit();
187 170
188 // Commit immediately. 171 // Commit immediately.
189 { 172 {
190 DebugScopedSetMainThreadBlocked main_thread_blocked(this); 173 DebugScopedSetMainThreadBlocked main_thread_blocked(this);
(...skipping 21 matching lines...) Expand all
212 layer_tree_host_impl_->resource_provider()); 195 layer_tree_host_impl_->resource_provider());
213 update_controller->Finalize(); 196 update_controller->Finalize();
214 197
215 if (layer_tree_host_impl_->EvictedUIResourcesExist()) 198 if (layer_tree_host_impl_->EvictedUIResourcesExist())
216 layer_tree_host_->RecreateUIResources(); 199 layer_tree_host_->RecreateUIResources();
217 200
218 layer_tree_host_->FinishCommitOnImplThread(layer_tree_host_impl_.get()); 201 layer_tree_host_->FinishCommitOnImplThread(layer_tree_host_impl_.get());
219 202
220 layer_tree_host_impl_->CommitComplete(); 203 layer_tree_host_impl_->CommitComplete();
221 204
205 UpdateBackgroundAnimateTicking();
206
222 #if DCHECK_IS_ON 207 #if DCHECK_IS_ON
223 // In the single-threaded case, the scale and scroll deltas should never be 208 // In the single-threaded case, the scale and scroll deltas should never be
224 // touched on the impl layer tree. 209 // touched on the impl layer tree.
225 scoped_ptr<ScrollAndScaleSet> scroll_info = 210 scoped_ptr<ScrollAndScaleSet> scroll_info =
226 layer_tree_host_impl_->ProcessScrollDeltas(); 211 layer_tree_host_impl_->ProcessScrollDeltas();
227 DCHECK(!scroll_info->scrolls.size()); 212 DCHECK(!scroll_info->scrolls.size());
228 DCHECK_EQ(1.f, scroll_info->page_scale_delta); 213 DCHECK_EQ(1.f, scroll_info->page_scale_delta);
229 #endif 214 #endif
230 } 215 }
231 216
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 scheduler_on_impl_thread_ = nullptr; 315 scheduler_on_impl_thread_ = nullptr;
331 layer_tree_host_impl_ = nullptr; 316 layer_tree_host_impl_ = nullptr;
332 } 317 }
333 layer_tree_host_ = NULL; 318 layer_tree_host_ = NULL;
334 } 319 }
335 320
336 void SingleThreadProxy::OnCanDrawStateChanged(bool can_draw) { 321 void SingleThreadProxy::OnCanDrawStateChanged(bool can_draw) {
337 TRACE_EVENT1( 322 TRACE_EVENT1(
338 "cc", "SingleThreadProxy::OnCanDrawStateChanged", "can_draw", can_draw); 323 "cc", "SingleThreadProxy::OnCanDrawStateChanged", "can_draw", can_draw);
339 DCHECK(Proxy::IsImplThread()); 324 DCHECK(Proxy::IsImplThread());
325 UpdateBackgroundAnimateTicking();
340 if (scheduler_on_impl_thread_) 326 if (scheduler_on_impl_thread_)
341 scheduler_on_impl_thread_->SetCanDraw(can_draw); 327 scheduler_on_impl_thread_->SetCanDraw(can_draw);
342 } 328 }
343 329
344 void SingleThreadProxy::NotifyReadyToActivate() { 330 void SingleThreadProxy::NotifyReadyToActivate() {
345 TRACE_EVENT0("cc", "SingleThreadProxy::NotifyReadyToActivate"); 331 TRACE_EVENT0("cc", "SingleThreadProxy::NotifyReadyToActivate");
346 DebugScopedSetImplThread impl(this); 332 DebugScopedSetImplThread impl(this);
347 if (scheduler_on_impl_thread_) 333 if (scheduler_on_impl_thread_)
348 scheduler_on_impl_thread_->NotifyReadyToActivate(); 334 scheduler_on_impl_thread_->NotifyReadyToActivate();
349 } 335 }
350 336
351 void SingleThreadProxy::SetNeedsRedrawOnImplThread() { 337 void SingleThreadProxy::SetNeedsRedrawOnImplThread() {
352 client_->ScheduleComposite(); 338 client_->ScheduleComposite();
353 if (scheduler_on_impl_thread_) 339 if (scheduler_on_impl_thread_)
354 scheduler_on_impl_thread_->SetNeedsRedraw(); 340 scheduler_on_impl_thread_->SetNeedsRedraw();
355 } 341 }
356 342
357 void SingleThreadProxy::SetNeedsAnimateOnImplThread() { 343 void SingleThreadProxy::SetNeedsAnimateOnImplThread() {
358 client_->ScheduleComposite(); 344 SetNeedsRedrawOnImplThread();
359 if (scheduler_on_impl_thread_)
360 scheduler_on_impl_thread_->SetNeedsAnimate();
361 } 345 }
362 346
363 void SingleThreadProxy::SetNeedsManageTilesOnImplThread() { 347 void SingleThreadProxy::SetNeedsManageTilesOnImplThread() {
364 TRACE_EVENT0("cc", "SingleThreadProxy::SetNeedsManageTilesOnImplThread"); 348 TRACE_EVENT0("cc", "SingleThreadProxy::SetNeedsManageTilesOnImplThread");
365 if (scheduler_on_impl_thread_) 349 if (scheduler_on_impl_thread_)
366 scheduler_on_impl_thread_->SetNeedsManageTiles(); 350 scheduler_on_impl_thread_->SetNeedsManageTiles();
367 } 351 }
368 352
369 void SingleThreadProxy::SetNeedsRedrawRectOnImplThread( 353 void SingleThreadProxy::SetNeedsRedrawRectOnImplThread(
370 const gfx::Rect& damage_rect) { 354 const gfx::Rect& damage_rect) {
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 // Since activation could cause tasks to run, post CommitComplete 407 // Since activation could cause tasks to run, post CommitComplete
424 // separately so that it runs after these tasks. This is the loose 408 // separately so that it runs after these tasks. This is the loose
425 // equivalent of blocking commit until activation and also running 409 // equivalent of blocking commit until activation and also running
426 // all tasks posted during commit/activation before CommitComplete. 410 // all tasks posted during commit/activation before CommitComplete.
427 MainThreadTaskRunner()->PostTask( 411 MainThreadTaskRunner()->PostTask(
428 FROM_HERE, 412 FROM_HERE,
429 base::Bind(&SingleThreadProxy::CommitComplete, 413 base::Bind(&SingleThreadProxy::CommitComplete,
430 weak_factory_.GetWeakPtr())); 414 weak_factory_.GetWeakPtr()));
431 } 415 }
432 416
417 UpdateBackgroundAnimateTicking();
433 timing_history_.DidActivateSyncTree(); 418 timing_history_.DidActivateSyncTree();
434 } 419 }
435 420
436 void SingleThreadProxy::DidManageTiles() { 421 void SingleThreadProxy::DidManageTiles() {
437 DCHECK(layer_tree_host_impl_->settings().impl_side_painting); 422 DCHECK(layer_tree_host_impl_->settings().impl_side_painting);
438 DCHECK(Proxy::IsImplThread()); 423 DCHECK(Proxy::IsImplThread());
439 if (scheduler_on_impl_thread_) 424 if (scheduler_on_impl_thread_)
440 scheduler_on_impl_thread_->DidManageTiles(); 425 scheduler_on_impl_thread_->DidManageTiles();
441 } 426 }
442 427
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
500 485
501 { 486 {
502 DebugScopedSetImplThread impl(const_cast<SingleThreadProxy*>(this)); 487 DebugScopedSetImplThread impl(const_cast<SingleThreadProxy*>(this));
503 if (layer_tree_host_impl_->settings().impl_side_painting) { 488 if (layer_tree_host_impl_->settings().impl_side_painting) {
504 layer_tree_host_impl_->ActivateSyncTree(); 489 layer_tree_host_impl_->ActivateSyncTree();
505 layer_tree_host_impl_->active_tree()->UpdateDrawProperties(); 490 layer_tree_host_impl_->active_tree()->UpdateDrawProperties();
506 layer_tree_host_impl_->ManageTiles(); 491 layer_tree_host_impl_->ManageTiles();
507 layer_tree_host_impl_->SynchronouslyInitializeAllTiles(); 492 layer_tree_host_impl_->SynchronouslyInitializeAllTiles();
508 } 493 }
509 494
510 DoAnimate();
511
512 LayerTreeHostImpl::FrameData frame; 495 LayerTreeHostImpl::FrameData frame;
513 DoComposite(frame_begin_time, &frame); 496 DoComposite(frame_begin_time, &frame);
514 497
515 // DoComposite could abort, but because this is a synchronous composite 498 // DoComposite could abort, but because this is a synchronous composite
516 // another draw will never be scheduled, so break remaining promises. 499 // another draw will never be scheduled, so break remaining promises.
517 layer_tree_host_impl_->active_tree()->BreakSwapPromises( 500 layer_tree_host_impl_->active_tree()->BreakSwapPromises(
518 SwapPromise::SWAP_FAILS); 501 SwapPromise::SWAP_FAILS);
519 } 502 }
520 } 503 }
521 504
(...skipping 21 matching lines...) Expand all
543 bool SingleThreadProxy::SupportsImplScrolling() const { 526 bool SingleThreadProxy::SupportsImplScrolling() const {
544 return false; 527 return false;
545 } 528 }
546 529
547 bool SingleThreadProxy::ShouldComposite() const { 530 bool SingleThreadProxy::ShouldComposite() const {
548 DCHECK(Proxy::IsImplThread()); 531 DCHECK(Proxy::IsImplThread());
549 return layer_tree_host_impl_->visible() && 532 return layer_tree_host_impl_->visible() &&
550 layer_tree_host_impl_->CanDraw(); 533 layer_tree_host_impl_->CanDraw();
551 } 534 }
552 535
536 void SingleThreadProxy::UpdateBackgroundAnimateTicking() {
537 DCHECK(Proxy::IsImplThread());
538 layer_tree_host_impl_->UpdateBackgroundAnimateTicking(
539 !ShouldComposite() && layer_tree_host_impl_->active_tree()->root_layer());
540 }
541
553 void SingleThreadProxy::ScheduleRequestNewOutputSurface() { 542 void SingleThreadProxy::ScheduleRequestNewOutputSurface() {
554 if (output_surface_creation_callback_.IsCancelled() && 543 if (output_surface_creation_callback_.IsCancelled() &&
555 !output_surface_creation_requested_) { 544 !output_surface_creation_requested_) {
556 output_surface_creation_callback_.Reset( 545 output_surface_creation_callback_.Reset(
557 base::Bind(&SingleThreadProxy::RequestNewOutputSurface, 546 base::Bind(&SingleThreadProxy::RequestNewOutputSurface,
558 weak_factory_.GetWeakPtr())); 547 weak_factory_.GetWeakPtr()));
559 MainThreadTaskRunner()->PostTask( 548 MainThreadTaskRunner()->PostTask(
560 FROM_HERE, output_surface_creation_callback_.callback()); 549 FROM_HERE, output_surface_creation_callback_.callback());
561 } 550 }
562 } 551 }
563 552
564 DrawResult SingleThreadProxy::DoComposite(base::TimeTicks frame_begin_time, 553 DrawResult SingleThreadProxy::DoComposite(base::TimeTicks frame_begin_time,
565 LayerTreeHostImpl::FrameData* frame) { 554 LayerTreeHostImpl::FrameData* frame) {
566 TRACE_EVENT0("cc", "SingleThreadProxy::DoComposite"); 555 TRACE_EVENT0("cc", "SingleThreadProxy::DoComposite");
567 DCHECK(!layer_tree_host_->output_surface_lost()); 556 DCHECK(!layer_tree_host_->output_surface_lost());
568 557
569 DrawResult draw_result; 558 DrawResult draw_result;
570 bool draw_frame; 559 bool draw_frame;
571 { 560 {
572 DebugScopedSetImplThread impl(this); 561 DebugScopedSetImplThread impl(this);
573 base::AutoReset<bool> mark_inside(&inside_draw_, true); 562 base::AutoReset<bool> mark_inside(&inside_draw_, true);
574 563
575 // We guard PrepareToDraw() with CanDraw() because it always returns a valid 564 // We guard PrepareToDraw() with CanDraw() because it always returns a valid
576 // frame, so can only be used when such a frame is possible. Since 565 // frame, so can only be used when such a frame is possible. Since
577 // DrawLayers() depends on the result of PrepareToDraw(), it is guarded on 566 // DrawLayers() depends on the result of PrepareToDraw(), it is guarded on
578 // CanDraw() as well. 567 // CanDraw() as well.
579 if (!ShouldComposite()) { 568 if (!ShouldComposite()) {
569 UpdateBackgroundAnimateTicking();
580 return DRAW_ABORTED_CANT_DRAW; 570 return DRAW_ABORTED_CANT_DRAW;
581 } 571 }
582 572
583 timing_history_.DidStartDrawing(); 573 timing_history_.DidStartDrawing();
584 574
575 layer_tree_host_impl_->Animate(
576 layer_tree_host_impl_->CurrentBeginFrameArgs().frame_time);
577 UpdateBackgroundAnimateTicking();
578
585 draw_result = layer_tree_host_impl_->PrepareToDraw(frame); 579 draw_result = layer_tree_host_impl_->PrepareToDraw(frame);
586 draw_frame = draw_result == DRAW_SUCCESS; 580 draw_frame = draw_result == DRAW_SUCCESS;
587 if (draw_frame) 581 if (draw_frame)
588 layer_tree_host_impl_->DrawLayers(frame, frame_begin_time); 582 layer_tree_host_impl_->DrawLayers(frame, frame_begin_time);
589 layer_tree_host_impl_->DidDrawAllLayers(*frame); 583 layer_tree_host_impl_->DidDrawAllLayers(*frame);
590 584
591 bool start_ready_animations = draw_frame; 585 bool start_ready_animations = draw_frame;
592 layer_tree_host_impl_->UpdateAnimationState(start_ready_animations); 586 layer_tree_host_impl_->UpdateAnimationState(start_ready_animations);
593 layer_tree_host_impl_->ResetCurrentBeginFrameArgsForNextFrame(); 587 layer_tree_host_impl_->ResetCurrentBeginFrameArgsForNextFrame();
594 588
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
735 return INVALID_RESULT; 729 return INVALID_RESULT;
736 } 730 }
737 731
738 void SingleThreadProxy::ScheduledActionCommit() { 732 void SingleThreadProxy::ScheduledActionCommit() {
739 DebugScopedSetMainThread main(this); 733 DebugScopedSetMainThread main(this);
740 DoCommit(); 734 DoCommit();
741 } 735 }
742 736
743 void SingleThreadProxy::ScheduledActionAnimate() { 737 void SingleThreadProxy::ScheduledActionAnimate() {
744 TRACE_EVENT0("cc", "ScheduledActionAnimate"); 738 TRACE_EVENT0("cc", "ScheduledActionAnimate");
745 DebugScopedSetImplThread impl(this); 739 layer_tree_host_impl_->Animate(
746 DoAnimate(); 740 layer_tree_host_impl_->CurrentBeginFrameArgs().frame_time);
747 } 741 }
748 742
749 void SingleThreadProxy::ScheduledActionUpdateVisibleTiles() { 743 void SingleThreadProxy::ScheduledActionUpdateVisibleTiles() {
750 DebugScopedSetImplThread impl(this); 744 DebugScopedSetImplThread impl(this);
751 layer_tree_host_impl_->UpdateVisibleTiles(); 745 layer_tree_host_impl_->UpdateVisibleTiles();
752 } 746 }
753 747
754 void SingleThreadProxy::ScheduledActionActivateSyncTree() { 748 void SingleThreadProxy::ScheduledActionActivateSyncTree() {
755 DebugScopedSetImplThread impl(this); 749 DebugScopedSetImplThread impl(this);
756 layer_tree_host_impl_->ActivateSyncTree(); 750 layer_tree_host_impl_->ActivateSyncTree();
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
790 784
791 base::TimeDelta SingleThreadProxy::CommitToActivateDurationEstimate() { 785 base::TimeDelta SingleThreadProxy::CommitToActivateDurationEstimate() {
792 return timing_history_.CommitToActivateDurationEstimate(); 786 return timing_history_.CommitToActivateDurationEstimate();
793 } 787 }
794 788
795 void SingleThreadProxy::DidBeginImplFrameDeadline() { 789 void SingleThreadProxy::DidBeginImplFrameDeadline() {
796 layer_tree_host_impl_->ResetCurrentBeginFrameArgsForNextFrame(); 790 layer_tree_host_impl_->ResetCurrentBeginFrameArgsForNextFrame();
797 } 791 }
798 792
799 } // namespace cc 793 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/single_thread_proxy.h ('k') | cc/trees/thread_proxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698