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

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

Issue 619843002: cc: Make separate interface for BeginFrame ipc from OutputSurface (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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/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"
11 #include "cc/output/output_surface.h" 11 #include "cc/output/output_surface.h"
12 #include "cc/quads/draw_quad.h" 12 #include "cc/quads/draw_quad.h"
13 #include "cc/resources/prioritized_resource_manager.h" 13 #include "cc/resources/prioritized_resource_manager.h"
14 #include "cc/resources/resource_update_controller.h" 14 #include "cc/resources/resource_update_controller.h"
15 #include "cc/trees/layer_tree_host.h" 15 #include "cc/trees/layer_tree_host.h"
16 #include "cc/trees/layer_tree_host_single_thread_client.h" 16 #include "cc/trees/layer_tree_host_single_thread_client.h"
17 #include "cc/trees/layer_tree_impl.h" 17 #include "cc/trees/layer_tree_impl.h"
18 #include "cc/trees/scoped_abort_remaining_swap_promises.h" 18 #include "cc/trees/scoped_abort_remaining_swap_promises.h"
19 #include "ui/gfx/frame_time.h" 19 #include "ui/gfx/frame_time.h"
20 20
21 namespace cc { 21 namespace cc {
22 22
23 scoped_ptr<Proxy> SingleThreadProxy::Create( 23 scoped_ptr<Proxy> SingleThreadProxy::Create(
24 LayerTreeHost* layer_tree_host, 24 LayerTreeHost* layer_tree_host,
25 LayerTreeHostSingleThreadClient* client, 25 LayerTreeHostSingleThreadClient* client,
26 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner) { 26 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner,
27 return make_scoped_ptr( 27 scoped_refptr<ExternalBeginFrameSource> external_begin_frame_source) {
28 new SingleThreadProxy(layer_tree_host, client, main_task_runner)); 28 return make_scoped_ptr(new SingleThreadProxy(layer_tree_host,
29 client,
30 main_task_runner,
31 external_begin_frame_source));
29 } 32 }
30 33
31 SingleThreadProxy::SingleThreadProxy( 34 SingleThreadProxy::SingleThreadProxy(
32 LayerTreeHost* layer_tree_host, 35 LayerTreeHost* layer_tree_host,
33 LayerTreeHostSingleThreadClient* client, 36 LayerTreeHostSingleThreadClient* client,
34 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner) 37 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner,
38 scoped_refptr<ExternalBeginFrameSource> external_begin_frame_source)
35 : Proxy(main_task_runner, NULL), 39 : Proxy(main_task_runner, NULL),
36 layer_tree_host_(layer_tree_host), 40 layer_tree_host_(layer_tree_host),
37 client_(client), 41 client_(client),
38 timing_history_(layer_tree_host->rendering_stats_instrumentation()), 42 timing_history_(layer_tree_host->rendering_stats_instrumentation()),
39 next_frame_is_newly_committed_frame_(false), 43 next_frame_is_newly_committed_frame_(false),
40 inside_draw_(false), 44 inside_draw_(false),
41 defer_commits_(false), 45 defer_commits_(false),
42 commit_was_deferred_(false), 46 commit_was_deferred_(false),
43 commit_requested_(false), 47 commit_requested_(false),
44 output_surface_creation_requested_(false), 48 output_surface_creation_requested_(false),
49 external_begin_frame_source_(external_begin_frame_source),
45 weak_factory_(this) { 50 weak_factory_(this) {
46 TRACE_EVENT0("cc", "SingleThreadProxy::SingleThreadProxy"); 51 TRACE_EVENT0("cc", "SingleThreadProxy::SingleThreadProxy");
47 DCHECK(Proxy::IsMainThread()); 52 DCHECK(Proxy::IsMainThread());
48 DCHECK(layer_tree_host); 53 DCHECK(layer_tree_host);
49 } 54 }
50 55
51 void SingleThreadProxy::Start() { 56 void SingleThreadProxy::Start() {
52 DebugScopedSetImplThread impl(this); 57 DebugScopedSetImplThread impl(this);
53 layer_tree_host_impl_ = layer_tree_host_->CreateLayerTreeHostImpl(this); 58 layer_tree_host_impl_ = layer_tree_host_->CreateLayerTreeHostImpl(this);
54 } 59 }
(...skipping 21 matching lines...) Expand all
76 81
77 void SingleThreadProxy::SetLayerTreeHostClientReady() { 82 void SingleThreadProxy::SetLayerTreeHostClientReady() {
78 TRACE_EVENT0("cc", "SingleThreadProxy::SetLayerTreeHostClientReady"); 83 TRACE_EVENT0("cc", "SingleThreadProxy::SetLayerTreeHostClientReady");
79 // Scheduling is controlled by the embedder in the single thread case, so 84 // Scheduling is controlled by the embedder in the single thread case, so
80 // nothing to do. 85 // nothing to do.
81 DCHECK(Proxy::IsMainThread()); 86 DCHECK(Proxy::IsMainThread());
82 DebugScopedSetImplThread impl(this); 87 DebugScopedSetImplThread impl(this);
83 if (layer_tree_host_->settings().single_thread_proxy_scheduler && 88 if (layer_tree_host_->settings().single_thread_proxy_scheduler &&
84 !scheduler_on_impl_thread_) { 89 !scheduler_on_impl_thread_) {
85 SchedulerSettings scheduler_settings(layer_tree_host_->settings()); 90 SchedulerSettings scheduler_settings(layer_tree_host_->settings());
86 scheduler_on_impl_thread_ = Scheduler::Create(this, 91 scheduler_on_impl_thread_ =
87 scheduler_settings, 92 Scheduler::Create(this,
88 layer_tree_host_->id(), 93 scheduler_settings,
89 MainThreadTaskRunner()); 94 layer_tree_host_->id(),
95 MainThreadTaskRunner(),
96 external_begin_frame_source_);
90 scheduler_on_impl_thread_->SetCanStart(); 97 scheduler_on_impl_thread_->SetCanStart();
91 scheduler_on_impl_thread_->SetVisible(layer_tree_host_impl_->visible()); 98 scheduler_on_impl_thread_->SetVisible(layer_tree_host_impl_->visible());
99 // |external_begin_frame_source_| is not used anymore by this.
100 // Proxy only delivers |external_begin_frame_source_| to Scheduler.
101 external_begin_frame_source_ = nullptr;
92 } 102 }
93 } 103 }
94 104
95 void SingleThreadProxy::SetVisible(bool visible) { 105 void SingleThreadProxy::SetVisible(bool visible) {
96 TRACE_EVENT0("cc", "SingleThreadProxy::SetVisible"); 106 TRACE_EVENT0("cc", "SingleThreadProxy::SetVisible");
97 DebugScopedSetImplThread impl(this); 107 DebugScopedSetImplThread impl(this);
98 layer_tree_host_impl_->SetVisible(visible); 108 layer_tree_host_impl_->SetVisible(visible);
99 if (scheduler_on_impl_thread_) 109 if (scheduler_on_impl_thread_)
100 scheduler_on_impl_thread_->SetVisible(layer_tree_host_impl_->visible()); 110 scheduler_on_impl_thread_->SetVisible(layer_tree_host_impl_->visible());
101 // Changing visibility could change ShouldComposite(). 111 // Changing visibility could change ShouldComposite().
(...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after
605 DebugScopedSetMainThread main(this); 615 DebugScopedSetMainThread main(this);
606 next_frame_is_newly_committed_frame_ = false; 616 next_frame_is_newly_committed_frame_ = false;
607 layer_tree_host_->DidCommitAndDrawFrame(); 617 layer_tree_host_->DidCommitAndDrawFrame();
608 } 618 }
609 } 619 }
610 620
611 bool SingleThreadProxy::MainFrameWillHappenForTesting() { 621 bool SingleThreadProxy::MainFrameWillHappenForTesting() {
612 return false; 622 return false;
613 } 623 }
614 624
615 BeginFrameSource* SingleThreadProxy::ExternalBeginFrameSource() {
616 return layer_tree_host_impl_.get();
617 }
618
619 void SingleThreadProxy::WillBeginImplFrame(const BeginFrameArgs& args) { 625 void SingleThreadProxy::WillBeginImplFrame(const BeginFrameArgs& args) {
620 layer_tree_host_impl_->WillBeginImplFrame(args); 626 layer_tree_host_impl_->WillBeginImplFrame(args);
621 } 627 }
622 628
623 void SingleThreadProxy::ScheduledActionSendBeginMainFrame() { 629 void SingleThreadProxy::ScheduledActionSendBeginMainFrame() {
624 TRACE_EVENT0("cc", "SingleThreadProxy::ScheduledActionSendBeginMainFrame"); 630 TRACE_EVENT0("cc", "SingleThreadProxy::ScheduledActionSendBeginMainFrame");
625 // Although this proxy is single-threaded, it's problematic to synchronously 631 // Although this proxy is single-threaded, it's problematic to synchronously
626 // have BeginMainFrame happen after ScheduledActionSendBeginMainFrame. This 632 // have BeginMainFrame happen after ScheduledActionSendBeginMainFrame. This
627 // could cause a commit to occur in between a series of SetNeedsCommit calls 633 // could cause a commit to occur in between a series of SetNeedsCommit calls
628 // (i.e. property modifications) causing some to fall on one frame and some to 634 // (i.e. property modifications) causing some to fall on one frame and some to
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
773 779
774 base::TimeDelta SingleThreadProxy::CommitToActivateDurationEstimate() { 780 base::TimeDelta SingleThreadProxy::CommitToActivateDurationEstimate() {
775 return timing_history_.CommitToActivateDurationEstimate(); 781 return timing_history_.CommitToActivateDurationEstimate();
776 } 782 }
777 783
778 void SingleThreadProxy::DidBeginImplFrameDeadline() { 784 void SingleThreadProxy::DidBeginImplFrameDeadline() {
779 layer_tree_host_impl_->ResetCurrentBeginFrameArgsForNextFrame(); 785 layer_tree_host_impl_->ResetCurrentBeginFrameArgsForNextFrame();
780 } 786 }
781 787
782 } // namespace cc 788 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698