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

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

Issue 475483002: Revert "Make SingleThreadProxy a SchedulerClient" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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"
29 #include "gpu/command_buffer/client/gles2_interface.h" 28 #include "gpu/command_buffer/client/gles2_interface.h"
30 #include "ui/gfx/frame_time.h" 29 #include "ui/gfx/frame_time.h"
31 30
32 namespace cc { 31 namespace cc {
33 32
34 namespace { 33 namespace {
35 34
36 // Measured in seconds. 35 // Measured in seconds.
37 const double kSmoothnessTakesPriorityExpirationDelay = 0.25; 36 const double kSmoothnessTakesPriorityExpirationDelay = 0.25;
38 37
39 unsigned int nextBeginFrameId = 0; 38 unsigned int nextBeginFrameId = 0;
40 39
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
41 } // namespace 53 } // namespace
42 54
43 struct ThreadProxy::SchedulerStateRequest { 55 struct ThreadProxy::SchedulerStateRequest {
44 CompletionEvent completion; 56 CompletionEvent completion;
45 scoped_ptr<base::Value> state; 57 scoped_ptr<base::Value> state;
46 }; 58 };
47 59
48 scoped_ptr<Proxy> ThreadProxy::Create( 60 scoped_ptr<Proxy> ThreadProxy::Create(
49 LayerTreeHost* layer_tree_host, 61 LayerTreeHost* layer_tree_host,
50 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, 62 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner,
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 } 446 }
435 447
436 void ThreadProxy::SetNextCommitWaitsForActivation() { 448 void ThreadProxy::SetNextCommitWaitsForActivation() {
437 DCHECK(IsMainThread()); 449 DCHECK(IsMainThread());
438 DCHECK(!blocked_main().main_thread_inside_commit); 450 DCHECK(!blocked_main().main_thread_inside_commit);
439 blocked_main().commit_waits_for_activation = true; 451 blocked_main().commit_waits_for_activation = true;
440 } 452 }
441 453
442 void ThreadProxy::SetDeferCommits(bool defer_commits) { 454 void ThreadProxy::SetDeferCommits(bool defer_commits) {
443 DCHECK(IsMainThread()); 455 DCHECK(IsMainThread());
444 if (main().defer_commits == defer_commits) 456 DCHECK_NE(main().defer_commits, defer_commits);
445 return; 457 main().defer_commits = defer_commits;
446 458
447 main().defer_commits = defer_commits;
448 if (main().defer_commits) 459 if (main().defer_commits)
449 TRACE_EVENT_ASYNC_BEGIN0("cc", "ThreadProxy::SetDeferCommits", this); 460 TRACE_EVENT_ASYNC_BEGIN0("cc", "ThreadProxy::SetDeferCommits", this);
450 else 461 else
451 TRACE_EVENT_ASYNC_END0("cc", "ThreadProxy::SetDeferCommits", this); 462 TRACE_EVENT_ASYNC_END0("cc", "ThreadProxy::SetDeferCommits", this);
452 463
453 if (!main().defer_commits && main().pending_deferred_commit) { 464 if (!main().defer_commits && main().pending_deferred_commit) {
454 Proxy::MainThreadTaskRunner()->PostTask( 465 Proxy::MainThreadTaskRunner()->PostTask(
455 FROM_HERE, 466 FROM_HERE,
456 base::Bind(&ThreadProxy::BeginMainFrame, 467 base::Bind(&ThreadProxy::BeginMainFrame,
457 main_thread_weak_ptr_, 468 main_thread_weak_ptr_,
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
717 728
718 if (main().defer_commits) { 729 if (main().defer_commits) {
719 main().pending_deferred_commit = begin_main_frame_state.Pass(); 730 main().pending_deferred_commit = begin_main_frame_state.Pass();
720 layer_tree_host()->DidDeferCommit(); 731 layer_tree_host()->DidDeferCommit();
721 TRACE_EVENT_INSTANT0( 732 TRACE_EVENT_INSTANT0(
722 "cc", "EarlyOut_DeferCommits", TRACE_EVENT_SCOPE_THREAD); 733 "cc", "EarlyOut_DeferCommits", TRACE_EVENT_SCOPE_THREAD);
723 return; 734 return;
724 } 735 }
725 736
726 // If the commit finishes, LayerTreeHost will transfer its swap promises to 737 // If the commit finishes, LayerTreeHost will transfer its swap promises to
727 // LayerTreeImpl. The destructor of ScopedSwapPromiseChecker aborts the 738 // LayerTreeImpl. The destructor of SwapPromiseChecker checks LayerTressHost's
728 // remaining swap promises. 739 // swap promises.
729 ScopedAbortRemainingSwapPromises swap_promise_checker(layer_tree_host()); 740 SwapPromiseChecker swap_promise_checker(layer_tree_host());
730 741
731 main().commit_requested = false; 742 main().commit_requested = false;
732 main().commit_request_sent_to_impl_thread = false; 743 main().commit_request_sent_to_impl_thread = false;
733 main().animate_requested = false; 744 main().animate_requested = false;
734 745
735 if (!layer_tree_host()->visible()) { 746 if (!layer_tree_host()->visible()) {
736 TRACE_EVENT_INSTANT0("cc", "EarlyOut_NotVisible", TRACE_EVENT_SCOPE_THREAD); 747 TRACE_EVENT_INSTANT0("cc", "EarlyOut_NotVisible", TRACE_EVENT_SCOPE_THREAD);
737 bool did_handle = false; 748 bool did_handle = false;
738 Proxy::ImplThreadTaskRunner()->PostTask( 749 Proxy::ImplThreadTaskRunner()->PostTask(
739 FROM_HERE, 750 FROM_HERE,
(...skipping 651 matching lines...) Expand 10 before | Expand all | Expand 10 after
1391 1402
1392 impl().timing_history.DidActivateSyncTree(); 1403 impl().timing_history.DidActivateSyncTree();
1393 } 1404 }
1394 1405
1395 void ThreadProxy::DidManageTiles() { 1406 void ThreadProxy::DidManageTiles() {
1396 DCHECK(IsImplThread()); 1407 DCHECK(IsImplThread());
1397 impl().scheduler->DidManageTiles(); 1408 impl().scheduler->DidManageTiles();
1398 } 1409 }
1399 1410
1400 } // namespace cc 1411 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/single_thread_proxy.cc ('k') | chrome/browser/ui/views/menu_view_drag_and_drop_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698