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

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

Issue 816543004: Update from https://crrev.com/308996 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years 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/thread_proxy.h ('k') | examples/pdf_viewer/pdf_viewer.cc » ('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/thread_proxy.h" 5 #include "cc/trees/thread_proxy.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 9
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/debug/trace_event.h" 12 #include "base/debug/trace_event.h"
13 #include "base/debug/trace_event_argument.h" 13 #include "base/debug/trace_event_argument.h"
14 #include "base/debug/trace_event_synthetic_delay.h" 14 #include "base/debug/trace_event_synthetic_delay.h"
15 #include "cc/base/swap_promise.h" 15 #include "cc/base/swap_promise.h"
16 #include "cc/debug/benchmark_instrumentation.h" 16 #include "cc/debug/benchmark_instrumentation.h"
17 #include "cc/debug/devtools_instrumentation.h" 17 #include "cc/debug/devtools_instrumentation.h"
18 #include "cc/input/input_handler.h" 18 #include "cc/input/input_handler.h"
19 #include "cc/output/context_provider.h" 19 #include "cc/output/context_provider.h"
20 #include "cc/output/output_surface.h" 20 #include "cc/output/output_surface.h"
21 #include "cc/quads/draw_quad.h" 21 #include "cc/quads/draw_quad.h"
22 #include "cc/resources/prioritized_resource_manager.h" 22 #include "cc/resources/prioritized_resource_manager.h"
23 #include "cc/scheduler/commit_earlyout_reason.h"
23 #include "cc/scheduler/delay_based_time_source.h" 24 #include "cc/scheduler/delay_based_time_source.h"
24 #include "cc/scheduler/scheduler.h" 25 #include "cc/scheduler/scheduler.h"
25 #include "cc/trees/blocking_task_runner.h" 26 #include "cc/trees/blocking_task_runner.h"
26 #include "cc/trees/layer_tree_host.h" 27 #include "cc/trees/layer_tree_host.h"
27 #include "cc/trees/layer_tree_impl.h" 28 #include "cc/trees/layer_tree_impl.h"
28 #include "cc/trees/scoped_abort_remaining_swap_promises.h" 29 #include "cc/trees/scoped_abort_remaining_swap_promises.h"
29 #include "gpu/command_buffer/client/gles2_interface.h" 30 #include "gpu/command_buffer/client/gles2_interface.h"
30 #include "ui/gfx/frame_time.h" 31 #include "ui/gfx/frame_time.h"
31 32
32 namespace cc { 33 namespace cc {
(...skipping 657 matching lines...) Expand 10 before | Expand all | Expand 10 after
690 // LayerTreeImpl. The destructor of ScopedSwapPromiseChecker aborts the 691 // LayerTreeImpl. The destructor of ScopedSwapPromiseChecker aborts the
691 // remaining swap promises. 692 // remaining swap promises.
692 ScopedAbortRemainingSwapPromises swap_promise_checker(layer_tree_host()); 693 ScopedAbortRemainingSwapPromises swap_promise_checker(layer_tree_host());
693 694
694 main().commit_requested = false; 695 main().commit_requested = false;
695 main().commit_request_sent_to_impl_thread = false; 696 main().commit_request_sent_to_impl_thread = false;
696 main().animate_requested = false; 697 main().animate_requested = false;
697 698
698 if (!layer_tree_host()->visible()) { 699 if (!layer_tree_host()->visible()) {
699 TRACE_EVENT_INSTANT0("cc", "EarlyOut_NotVisible", TRACE_EVENT_SCOPE_THREAD); 700 TRACE_EVENT_INSTANT0("cc", "EarlyOut_NotVisible", TRACE_EVENT_SCOPE_THREAD);
700 bool did_handle = false;
701 Proxy::ImplThreadTaskRunner()->PostTask( 701 Proxy::ImplThreadTaskRunner()->PostTask(
702 FROM_HERE, 702 FROM_HERE, base::Bind(&ThreadProxy::BeginMainFrameAbortedOnImplThread,
703 base::Bind(&ThreadProxy::BeginMainFrameAbortedOnImplThread, 703 impl_thread_weak_ptr_,
704 impl_thread_weak_ptr_, 704 CommitEarlyOutReason::ABORTED_NOT_VISIBLE));
705 did_handle));
706 return; 705 return;
707 } 706 }
708 707
709 if (layer_tree_host()->output_surface_lost()) { 708 if (layer_tree_host()->output_surface_lost()) {
710 TRACE_EVENT_INSTANT0( 709 TRACE_EVENT_INSTANT0(
711 "cc", "EarlyOut_OutputSurfaceLost", TRACE_EVENT_SCOPE_THREAD); 710 "cc", "EarlyOut_OutputSurfaceLost", TRACE_EVENT_SCOPE_THREAD);
712 bool did_handle = false;
713 Proxy::ImplThreadTaskRunner()->PostTask( 711 Proxy::ImplThreadTaskRunner()->PostTask(
714 FROM_HERE, 712 FROM_HERE,
715 base::Bind(&ThreadProxy::BeginMainFrameAbortedOnImplThread, 713 base::Bind(&ThreadProxy::BeginMainFrameAbortedOnImplThread,
716 impl_thread_weak_ptr_, 714 impl_thread_weak_ptr_,
717 did_handle)); 715 CommitEarlyOutReason::ABORTED_OUTPUT_SURFACE_LOST));
718 return; 716 return;
719 } 717 }
720 718
721 // Do not notify the impl thread of commit requests that occur during 719 // Do not notify the impl thread of commit requests that occur during
722 // the apply/animate/layout part of the BeginMainFrameAndCommit process since 720 // the apply/animate/layout part of the BeginMainFrameAndCommit process since
723 // those commit requests will get painted immediately. Once we have done 721 // those commit requests will get painted immediately. Once we have done
724 // the paint, main().commit_requested will be set to false to allow new commit 722 // the paint, main().commit_requested will be set to false to allow new commit
725 // requests to be scheduled. 723 // requests to be scheduled.
726 // On the other hand, the animate_requested flag should remain cleared 724 // On the other hand, the animate_requested flag should remain cleared
727 // here so that any animation requests generated by the apply or animate 725 // here so that any animation requests generated by the apply or animate
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
779 // call to happen again now so that the commit request is sent to the impl 777 // call to happen again now so that the commit request is sent to the impl
780 // thread. 778 // thread.
781 if (main().animate_requested) { 779 if (main().animate_requested) {
782 // Forces SetNeedsAnimate to consider posting a commit task. 780 // Forces SetNeedsAnimate to consider posting a commit task.
783 main().animate_requested = false; 781 main().animate_requested = false;
784 SetNeedsAnimate(); 782 SetNeedsAnimate();
785 } 783 }
786 784
787 if (!updated && can_cancel_this_commit) { 785 if (!updated && can_cancel_this_commit) {
788 TRACE_EVENT_INSTANT0("cc", "EarlyOut_NoUpdates", TRACE_EVENT_SCOPE_THREAD); 786 TRACE_EVENT_INSTANT0("cc", "EarlyOut_NoUpdates", TRACE_EVENT_SCOPE_THREAD);
789 bool did_handle = true;
790 Proxy::ImplThreadTaskRunner()->PostTask( 787 Proxy::ImplThreadTaskRunner()->PostTask(
791 FROM_HERE, 788 FROM_HERE, base::Bind(&ThreadProxy::BeginMainFrameAbortedOnImplThread,
792 base::Bind(&ThreadProxy::BeginMainFrameAbortedOnImplThread, 789 impl_thread_weak_ptr_,
793 impl_thread_weak_ptr_, 790 CommitEarlyOutReason::FINISHED_NO_UPDATES));
794 did_handle));
795 791
796 // Although the commit is internally aborted, this is because it has been 792 // Although the commit is internally aborted, this is because it has been
797 // detected to be a no-op. From the perspective of an embedder, this commit 793 // detected to be a no-op. From the perspective of an embedder, this commit
798 // went through, and input should no longer be throttled, etc. 794 // went through, and input should no longer be throttled, etc.
799 layer_tree_host()->CommitComplete(); 795 layer_tree_host()->CommitComplete();
800 layer_tree_host()->DidBeginMainFrame(); 796 layer_tree_host()->DidBeginMainFrame();
801 layer_tree_host()->BreakSwapPromises(SwapPromise::COMMIT_NO_UPDATE); 797 layer_tree_host()->BreakSwapPromises(SwapPromise::COMMIT_NO_UPDATE);
802 return; 798 return;
803 } 799 }
804 800
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
877 impl().commit_completion_event = completion; 873 impl().commit_completion_event = completion;
878 impl().current_resource_update_controller = ResourceUpdateController::Create( 874 impl().current_resource_update_controller = ResourceUpdateController::Create(
879 this, 875 this,
880 Proxy::ImplThreadTaskRunner(), 876 Proxy::ImplThreadTaskRunner(),
881 queue.Pass(), 877 queue.Pass(),
882 impl().layer_tree_host_impl->resource_provider()); 878 impl().layer_tree_host_impl->resource_provider());
883 impl().current_resource_update_controller->PerformMoreUpdates( 879 impl().current_resource_update_controller->PerformMoreUpdates(
884 impl().scheduler->AnticipatedDrawTime()); 880 impl().scheduler->AnticipatedDrawTime());
885 } 881 }
886 882
887 void ThreadProxy::BeginMainFrameAbortedOnImplThread(bool did_handle) { 883 void ThreadProxy::BeginMainFrameAbortedOnImplThread(
888 TRACE_EVENT0("cc", "ThreadProxy::BeginMainFrameAbortedOnImplThread"); 884 CommitEarlyOutReason reason) {
885 TRACE_EVENT1("cc", "ThreadProxy::BeginMainFrameAbortedOnImplThread", "reason",
886 CommitEarlyOutReasonToString(reason));
889 DCHECK(IsImplThread()); 887 DCHECK(IsImplThread());
890 DCHECK(impl().scheduler); 888 DCHECK(impl().scheduler);
891 DCHECK(impl().scheduler->CommitPending()); 889 DCHECK(impl().scheduler->CommitPending());
892 DCHECK(!impl().layer_tree_host_impl->pending_tree()); 890 DCHECK(!impl().layer_tree_host_impl->pending_tree());
893 891
894 if (did_handle) 892 if (CommitEarlyOutHandledCommit(reason))
895 SetInputThrottledUntilCommitOnImplThread(false); 893 SetInputThrottledUntilCommitOnImplThread(false);
896 impl().layer_tree_host_impl->BeginMainFrameAborted(did_handle); 894 impl().layer_tree_host_impl->BeginMainFrameAborted(reason);
897 impl().scheduler->BeginMainFrameAborted(did_handle); 895 impl().scheduler->BeginMainFrameAborted(reason);
898 } 896 }
899 897
900 void ThreadProxy::ScheduledActionAnimate() { 898 void ThreadProxy::ScheduledActionAnimate() {
901 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionAnimate"); 899 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionAnimate");
902 DCHECK(IsImplThread()); 900 DCHECK(IsImplThread());
903 901
904 // Don't animate if there is no root layer. 902 // Don't animate if there is no root layer.
905 // TODO(mithro): Both Animate and UpdateAnimationState already have a 903 // TODO(mithro): Both Animate and UpdateAnimationState already have a
906 // "!active_tree_->root_layer()" check? 904 // "!active_tree_->root_layer()" check?
907 if (!impl().layer_tree_host_impl->active_tree()->root_layer()) { 905 if (!impl().layer_tree_host_impl->active_tree()->root_layer()) {
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after
1334 1332
1335 impl().timing_history.DidActivateSyncTree(); 1333 impl().timing_history.DidActivateSyncTree();
1336 } 1334 }
1337 1335
1338 void ThreadProxy::DidPrepareTiles() { 1336 void ThreadProxy::DidPrepareTiles() {
1339 DCHECK(IsImplThread()); 1337 DCHECK(IsImplThread());
1340 impl().scheduler->DidPrepareTiles(); 1338 impl().scheduler->DidPrepareTiles();
1341 } 1339 }
1342 1340
1343 } // namespace cc 1341 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/thread_proxy.h ('k') | examples/pdf_viewer/pdf_viewer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698