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

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

Issue 2188093002: cc: Complete swap promise for aborted commit after pending activation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix compile error Created 4 years, 4 months 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
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/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "base/profiler/scoped_tracker.h" 9 #include "base/profiler/scoped_tracker.h"
10 #include "base/trace_event/trace_event.h" 10 #include "base/trace_event/trace_event.h"
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 layer_tree_host_ = NULL; 371 layer_tree_host_ = NULL;
372 } 372 }
373 373
374 void SingleThreadProxy::SetMutator(std::unique_ptr<LayerTreeMutator> mutator) { 374 void SingleThreadProxy::SetMutator(std::unique_ptr<LayerTreeMutator> mutator) {
375 DCHECK(task_runner_provider_->IsMainThread()); 375 DCHECK(task_runner_provider_->IsMainThread());
376 DebugScopedSetImplThread impl(task_runner_provider_); 376 DebugScopedSetImplThread impl(task_runner_provider_);
377 layer_tree_host_impl_->SetLayerTreeMutator(std::move(mutator)); 377 layer_tree_host_impl_->SetLayerTreeMutator(std::move(mutator));
378 } 378 }
379 379
380 void SingleThreadProxy::OnCanDrawStateChanged(bool can_draw) { 380 void SingleThreadProxy::OnCanDrawStateChanged(bool can_draw) {
381 TRACE_EVENT1( 381 TRACE_EVENT1("cc", "SingleThreadProxy::OnCanDrawStateChanged", "can_draw",
382 "cc", "SingleThreadProxy::OnCanDrawStateChanged", "can_draw", can_draw); 382 can_draw);
383 DCHECK(task_runner_provider_->IsImplThread()); 383 DCHECK(task_runner_provider_->IsImplThread());
384 if (scheduler_on_impl_thread_) 384 if (scheduler_on_impl_thread_)
385 scheduler_on_impl_thread_->SetCanDraw(can_draw); 385 scheduler_on_impl_thread_->SetCanDraw(can_draw);
386 } 386 }
387 387
388 void SingleThreadProxy::NotifyReadyToActivate() { 388 void SingleThreadProxy::NotifyReadyToActivate() {
389 TRACE_EVENT0("cc", "SingleThreadProxy::NotifyReadyToActivate"); 389 TRACE_EVENT0("cc", "SingleThreadProxy::NotifyReadyToActivate");
390 DebugScopedSetImplThread impl(task_runner_provider_); 390 DebugScopedSetImplThread impl(task_runner_provider_);
391 if (scheduler_on_impl_thread_) 391 if (scheduler_on_impl_thread_)
392 scheduler_on_impl_thread_->NotifyReadyToActivate(); 392 scheduler_on_impl_thread_->NotifyReadyToActivate();
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 441
442 void SingleThreadProxy::PostAnimationEventsToMainThreadOnImplThread( 442 void SingleThreadProxy::PostAnimationEventsToMainThreadOnImplThread(
443 std::unique_ptr<AnimationEvents> events) { 443 std::unique_ptr<AnimationEvents> events) {
444 TRACE_EVENT0( 444 TRACE_EVENT0(
445 "cc", "SingleThreadProxy::PostAnimationEventsToMainThreadOnImplThread"); 445 "cc", "SingleThreadProxy::PostAnimationEventsToMainThreadOnImplThread");
446 DCHECK(task_runner_provider_->IsImplThread()); 446 DCHECK(task_runner_provider_->IsImplThread());
447 DebugScopedSetMainThread main(task_runner_provider_); 447 DebugScopedSetMainThread main(task_runner_provider_);
448 layer_tree_host_->SetAnimationEvents(std::move(events)); 448 layer_tree_host_->SetAnimationEvents(std::move(events));
449 } 449 }
450 450
451 bool SingleThreadProxy::IsInsideDraw() { return inside_draw_; } 451 bool SingleThreadProxy::IsInsideDraw() {
452 return inside_draw_;
453 }
452 454
453 void SingleThreadProxy::DidActivateSyncTree() { 455 void SingleThreadProxy::DidActivateSyncTree() {
454 // Synchronously call to CommitComplete. Resetting 456 // Synchronously call to CommitComplete. Resetting
455 // |commit_blocking_task_runner| would make sure all tasks posted during 457 // |commit_blocking_task_runner| would make sure all tasks posted during
456 // commit/activation before CommitComplete. 458 // commit/activation before CommitComplete.
457 CommitComplete(); 459 CommitComplete();
458 } 460 }
459 461
460 void SingleThreadProxy::WillPrepareTiles() { 462 void SingleThreadProxy::WillPrepareTiles() {
461 DCHECK(task_runner_provider_->IsImplThread()); 463 DCHECK(task_runner_provider_->IsImplThread());
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
587 DidFinishImplFrame(); 589 DidFinishImplFrame();
588 } 590 }
589 } 591 }
590 592
591 bool SingleThreadProxy::SupportsImplScrolling() const { 593 bool SingleThreadProxy::SupportsImplScrolling() const {
592 return false; 594 return false;
593 } 595 }
594 596
595 bool SingleThreadProxy::ShouldComposite() const { 597 bool SingleThreadProxy::ShouldComposite() const {
596 DCHECK(task_runner_provider_->IsImplThread()); 598 DCHECK(task_runner_provider_->IsImplThread());
597 return layer_tree_host_impl_->visible() && 599 return layer_tree_host_impl_->visible() && layer_tree_host_impl_->CanDraw();
598 layer_tree_host_impl_->CanDraw();
599 } 600 }
600 601
601 void SingleThreadProxy::ScheduleRequestNewOutputSurface() { 602 void SingleThreadProxy::ScheduleRequestNewOutputSurface() {
602 if (output_surface_creation_callback_.IsCancelled() && 603 if (output_surface_creation_callback_.IsCancelled() &&
603 !output_surface_creation_requested_) { 604 !output_surface_creation_requested_) {
604 output_surface_creation_callback_.Reset( 605 output_surface_creation_callback_.Reset(
605 base::Bind(&SingleThreadProxy::RequestNewOutputSurface, 606 base::Bind(&SingleThreadProxy::RequestNewOutputSurface,
606 weak_factory_.GetWeakPtr())); 607 weak_factory_.GetWeakPtr()));
607 task_runner_provider_->MainThreadTaskRunner()->PostTask( 608 task_runner_provider_->MainThreadTaskRunner()->PostTask(
608 FROM_HERE, output_surface_creation_callback_.callback()); 609 FROM_HERE, output_surface_creation_callback_.callback());
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
728 DCHECK(!inside_impl_frame_) 729 DCHECK(!inside_impl_frame_)
729 << "WillBeginImplFrame called while already inside an impl frame!"; 730 << "WillBeginImplFrame called while already inside an impl frame!";
730 inside_impl_frame_ = true; 731 inside_impl_frame_ = true;
731 #endif 732 #endif
732 layer_tree_host_impl_->WillBeginImplFrame(args); 733 layer_tree_host_impl_->WillBeginImplFrame(args);
733 } 734 }
734 735
735 void SingleThreadProxy::ScheduledActionSendBeginMainFrame( 736 void SingleThreadProxy::ScheduledActionSendBeginMainFrame(
736 const BeginFrameArgs& begin_frame_args) { 737 const BeginFrameArgs& begin_frame_args) {
737 TRACE_EVENT0("cc", "SingleThreadProxy::ScheduledActionSendBeginMainFrame"); 738 TRACE_EVENT0("cc", "SingleThreadProxy::ScheduledActionSendBeginMainFrame");
738 // Although this proxy is single-threaded, it's problematic to synchronously 739 // Although this proxy is single-threaded, it's problematic to synchronously
739 // have BeginMainFrame happen after ScheduledActionSendBeginMainFrame. This 740 // have BeginMainFrame happen after ScheduledActionSendBeginMainFrame. This
740 // could cause a commit to occur in between a series of SetNeedsCommit calls 741 // could cause a commit to occur in between a series of SetNeedsCommit calls
741 // (i.e. property modifications) causing some to fall on one frame and some to 742 // (i.e. property modifications) causing some to fall on one frame and some to
742 // fall on the next. Doing it asynchronously instead matches the semantics of 743 // fall on the next. Doing it asynchronously instead matches the semantics of
743 // ThreadProxy::SetNeedsCommit where SetNeedsCommit will not cause a 744 // ThreadProxy::SetNeedsCommit where SetNeedsCommit will not cause a
744 // synchronous commit. 745 // synchronous commit.
brianderson 2016/07/28 18:10:53 Should this go inside the dcheck and be indented?
sunnyps 2016/08/02 02:55:09 Done.
745 #if DCHECK_IS_ON() 746 #if DCHECK_IS_ON()
746 DCHECK(inside_impl_frame_) 747 DCHECK(inside_impl_frame_)
747 << "BeginMainFrame should only be sent inside a BeginImplFrame"; 748 << "BeginMainFrame should only be sent inside a BeginImplFrame";
748 #endif 749 #endif
749 750
750 task_runner_provider_->MainThreadTaskRunner()->PostTask( 751 task_runner_provider_->MainThreadTaskRunner()->PostTask(
751 FROM_HERE, base::Bind(&SingleThreadProxy::BeginMainFrame, 752 FROM_HERE, base::Bind(&SingleThreadProxy::BeginMainFrame,
752 weak_factory_.GetWeakPtr(), begin_frame_args)); 753 weak_factory_.GetWeakPtr(), begin_frame_args));
753 } 754 }
754 755
(...skipping 23 matching lines...) Expand all
778 ScopedAbortRemainingSwapPromises swap_promise_checker(layer_tree_host_); 779 ScopedAbortRemainingSwapPromises swap_promise_checker(layer_tree_host_);
779 780
780 if (!layer_tree_host_->visible()) { 781 if (!layer_tree_host_->visible()) {
781 TRACE_EVENT_INSTANT0("cc", "EarlyOut_NotVisible", TRACE_EVENT_SCOPE_THREAD); 782 TRACE_EVENT_INSTANT0("cc", "EarlyOut_NotVisible", TRACE_EVENT_SCOPE_THREAD);
782 BeginMainFrameAbortedOnImplThread( 783 BeginMainFrameAbortedOnImplThread(
783 CommitEarlyOutReason::ABORTED_NOT_VISIBLE); 784 CommitEarlyOutReason::ABORTED_NOT_VISIBLE);
784 return; 785 return;
785 } 786 }
786 787
787 if (layer_tree_host_->output_surface_lost()) { 788 if (layer_tree_host_->output_surface_lost()) {
788 TRACE_EVENT_INSTANT0( 789 TRACE_EVENT_INSTANT0("cc", "EarlyOut_OutputSurfaceLost",
789 "cc", "EarlyOut_OutputSurfaceLost", TRACE_EVENT_SCOPE_THREAD); 790 TRACE_EVENT_SCOPE_THREAD);
790 BeginMainFrameAbortedOnImplThread( 791 BeginMainFrameAbortedOnImplThread(
791 CommitEarlyOutReason::ABORTED_OUTPUT_SURFACE_LOST); 792 CommitEarlyOutReason::ABORTED_OUTPUT_SURFACE_LOST);
792 return; 793 return;
793 } 794 }
794 795
795 // Prevent new commits from being requested inside DoBeginMainFrame. 796 // Prevent new commits from being requested inside DoBeginMainFrame.
796 // Note: We do not want to prevent SetNeedsAnimate from requesting 797 // Note: We do not want to prevent SetNeedsAnimate from requesting
797 // a commit here. 798 // a commit here.
798 commit_requested_ = true; 799 commit_requested_ = true;
799 800
(...skipping 18 matching lines...) Expand all
818 if (scheduler_on_impl_thread_) 819 if (scheduler_on_impl_thread_)
819 scheduler_on_impl_thread_->NotifyReadyToCommit(); 820 scheduler_on_impl_thread_->NotifyReadyToCommit();
820 } 821 }
821 822
822 void SingleThreadProxy::BeginMainFrameAbortedOnImplThread( 823 void SingleThreadProxy::BeginMainFrameAbortedOnImplThread(
823 CommitEarlyOutReason reason) { 824 CommitEarlyOutReason reason) {
824 DebugScopedSetImplThread impl(task_runner_provider_); 825 DebugScopedSetImplThread impl(task_runner_provider_);
825 DCHECK(scheduler_on_impl_thread_->CommitPending()); 826 DCHECK(scheduler_on_impl_thread_->CommitPending());
826 DCHECK(!layer_tree_host_impl_->pending_tree()); 827 DCHECK(!layer_tree_host_impl_->pending_tree());
827 828
828 layer_tree_host_impl_->BeginMainFrameAborted(reason); 829 std::vector<std::unique_ptr<SwapPromise>> empty_swap_promises;
830 layer_tree_host_impl_->BeginMainFrameAborted(reason,
831 std::move(empty_swap_promises));
829 scheduler_on_impl_thread_->BeginMainFrameAborted(reason); 832 scheduler_on_impl_thread_->BeginMainFrameAborted(reason);
830 } 833 }
831 834
832 DrawResult SingleThreadProxy::ScheduledActionDrawAndSwapIfPossible() { 835 DrawResult SingleThreadProxy::ScheduledActionDrawAndSwapIfPossible() {
833 DebugScopedSetImplThread impl(task_runner_provider_); 836 DebugScopedSetImplThread impl(task_runner_provider_);
834 LayerTreeHostImpl::FrameData frame; 837 LayerTreeHostImpl::FrameData frame;
835 return DoComposite(&frame); 838 return DoComposite(&frame);
836 } 839 }
837 840
838 DrawResult SingleThreadProxy::ScheduledActionDrawAndSwapForced() { 841 DrawResult SingleThreadProxy::ScheduledActionDrawAndSwapForced() {
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
883 void SingleThreadProxy::DidFinishImplFrame() { 886 void SingleThreadProxy::DidFinishImplFrame() {
884 layer_tree_host_impl_->DidFinishImplFrame(); 887 layer_tree_host_impl_->DidFinishImplFrame();
885 #if DCHECK_IS_ON() 888 #if DCHECK_IS_ON()
886 DCHECK(inside_impl_frame_) 889 DCHECK(inside_impl_frame_)
887 << "DidFinishImplFrame called while not inside an impl frame!"; 890 << "DidFinishImplFrame called while not inside an impl frame!";
888 inside_impl_frame_ = false; 891 inside_impl_frame_ = false;
889 #endif 892 #endif
890 } 893 }
891 894
892 } // namespace cc 895 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698