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

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

Issue 134623005: Make SingleThreadProxy a SchedulerClient (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 6 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 | Annotate | Revision Log
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/delay_based_time_source.h" 23 #include "cc/scheduler/delay_based_time_source.h"
24 #include "cc/scheduler/scheduler.h" 24 #include "cc/scheduler/scheduler.h"
25 #include "cc/trees/blocking_task_runner.h" 25 #include "cc/trees/blocking_task_runner.h"
26 #include "cc/trees/layer_tree_host.h" 26 #include "cc/trees/layer_tree_host.h"
27 #include "cc/trees/layer_tree_impl.h" 27 #include "cc/trees/layer_tree_impl.h"
28 #include "cc/trees/scoped_abort_remaining_swap_promises.h"
28 #include "gpu/command_buffer/client/gles2_interface.h" 29 #include "gpu/command_buffer/client/gles2_interface.h"
29 #include "ui/gfx/frame_time.h" 30 #include "ui/gfx/frame_time.h"
30 31
31 namespace cc { 32 namespace cc {
32 33
33 namespace { 34 namespace {
34 35
35 // Measured in seconds. 36 // Measured in seconds.
36 const double kSmoothnessTakesPriorityExpirationDelay = 0.25; 37 const double kSmoothnessTakesPriorityExpirationDelay = 0.25;
37 38
38 unsigned int nextBeginFrameId = 0; 39 unsigned int nextBeginFrameId = 0;
39 40
40 class SwapPromiseChecker {
41 public:
42 explicit SwapPromiseChecker(LayerTreeHost* layer_tree_host)
43 : layer_tree_host_(layer_tree_host) {}
44
45 ~SwapPromiseChecker() {
46 layer_tree_host_->BreakSwapPromises(SwapPromise::COMMIT_FAILS);
47 }
48
49 private:
50 LayerTreeHost* layer_tree_host_;
51 };
52
53 } // namespace 41 } // namespace
54 42
55 struct ThreadProxy::CommitPendingRequest { 43 struct ThreadProxy::CommitPendingRequest {
56 CompletionEvent completion; 44 CompletionEvent completion;
57 bool commit_pending; 45 bool commit_pending;
58 }; 46 };
59 47
60 struct ThreadProxy::SchedulerStateRequest { 48 struct ThreadProxy::SchedulerStateRequest {
61 CompletionEvent completion; 49 CompletionEvent completion;
62 scoped_ptr<base::Value> state; 50 scoped_ptr<base::Value> state;
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 } 439 }
452 440
453 void ThreadProxy::SetNextCommitWaitsForActivation() { 441 void ThreadProxy::SetNextCommitWaitsForActivation() {
454 DCHECK(IsMainThread()); 442 DCHECK(IsMainThread());
455 DCHECK(!blocked_main().main_thread_inside_commit); 443 DCHECK(!blocked_main().main_thread_inside_commit);
456 blocked_main().commit_waits_for_activation = true; 444 blocked_main().commit_waits_for_activation = true;
457 } 445 }
458 446
459 void ThreadProxy::SetDeferCommits(bool defer_commits) { 447 void ThreadProxy::SetDeferCommits(bool defer_commits) {
460 DCHECK(IsMainThread()); 448 DCHECK(IsMainThread());
461 DCHECK_NE(main().defer_commits, defer_commits); 449 if (main().defer_commits == defer_commits)
450 return;
451
462 main().defer_commits = defer_commits; 452 main().defer_commits = defer_commits;
463
464 if (main().defer_commits) 453 if (main().defer_commits)
465 TRACE_EVENT_ASYNC_BEGIN0("cc", "ThreadProxy::SetDeferCommits", this); 454 TRACE_EVENT_ASYNC_BEGIN0("cc", "ThreadProxy::SetDeferCommits", this);
466 else 455 else
467 TRACE_EVENT_ASYNC_END0("cc", "ThreadProxy::SetDeferCommits", this); 456 TRACE_EVENT_ASYNC_END0("cc", "ThreadProxy::SetDeferCommits", this);
468 457
469 if (!main().defer_commits && main().pending_deferred_commit) { 458 if (!main().defer_commits && main().pending_deferred_commit) {
470 Proxy::MainThreadTaskRunner()->PostTask( 459 Proxy::MainThreadTaskRunner()->PostTask(
471 FROM_HERE, 460 FROM_HERE,
472 base::Bind(&ThreadProxy::BeginMainFrame, 461 base::Bind(&ThreadProxy::BeginMainFrame,
473 main_thread_weak_ptr_, 462 main_thread_weak_ptr_,
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
733 722
734 if (main().defer_commits) { 723 if (main().defer_commits) {
735 main().pending_deferred_commit = begin_main_frame_state.Pass(); 724 main().pending_deferred_commit = begin_main_frame_state.Pass();
736 layer_tree_host()->DidDeferCommit(); 725 layer_tree_host()->DidDeferCommit();
737 TRACE_EVENT_INSTANT0( 726 TRACE_EVENT_INSTANT0(
738 "cc", "EarlyOut_DeferCommits", TRACE_EVENT_SCOPE_THREAD); 727 "cc", "EarlyOut_DeferCommits", TRACE_EVENT_SCOPE_THREAD);
739 return; 728 return;
740 } 729 }
741 730
742 // If the commit finishes, LayerTreeHost will transfer its swap promises to 731 // If the commit finishes, LayerTreeHost will transfer its swap promises to
743 // LayerTreeImpl. The destructor of SwapPromiseChecker checks LayerTressHost's 732 // LayerTreeImpl. The destructor of ScopedSwapPromiseChecker aborts the
744 // swap promises. 733 // remaining swap promises.
745 SwapPromiseChecker swap_promise_checker(layer_tree_host()); 734 ScopedAbortRemainingSwapPromises swap_promise_checker(layer_tree_host());
746 735
747 main().commit_requested = false; 736 main().commit_requested = false;
748 main().commit_request_sent_to_impl_thread = false; 737 main().commit_request_sent_to_impl_thread = false;
749 main().animate_requested = false; 738 main().animate_requested = false;
750 739
751 if (!layer_tree_host()->visible()) { 740 if (!layer_tree_host()->visible()) {
752 TRACE_EVENT_INSTANT0("cc", "EarlyOut_NotVisible", TRACE_EVENT_SCOPE_THREAD); 741 TRACE_EVENT_INSTANT0("cc", "EarlyOut_NotVisible", TRACE_EVENT_SCOPE_THREAD);
753 bool did_handle = false; 742 bool did_handle = false;
754 Proxy::ImplThreadTaskRunner()->PostTask( 743 Proxy::ImplThreadTaskRunner()->PostTask(
755 FROM_HERE, 744 FROM_HERE,
(...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after
1402 1391
1403 impl().timing_history.DidActivateSyncTree(); 1392 impl().timing_history.DidActivateSyncTree();
1404 } 1393 }
1405 1394
1406 void ThreadProxy::DidManageTiles() { 1395 void ThreadProxy::DidManageTiles() {
1407 DCHECK(IsImplThread()); 1396 DCHECK(IsImplThread());
1408 impl().scheduler->DidManageTiles(); 1397 impl().scheduler->DidManageTiles();
1409 } 1398 }
1410 1399
1411 } // namespace cc 1400 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698