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

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

Issue 1455023002: cc: Replace Pass() with std::move() in some subdirs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@pass-cc
Patch Set: pass-cc2: . Created 5 years, 1 month 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/single_thread_proxy.cc ('k') | cc/trees/threaded_channel.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"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 42
43 struct ThreadProxy::SchedulerStateRequest { 43 struct ThreadProxy::SchedulerStateRequest {
44 CompletionEvent completion; 44 CompletionEvent completion;
45 scoped_ptr<base::Value> state; 45 scoped_ptr<base::Value> state;
46 }; 46 };
47 47
48 scoped_ptr<Proxy> ThreadProxy::Create( 48 scoped_ptr<Proxy> ThreadProxy::Create(
49 LayerTreeHost* layer_tree_host, 49 LayerTreeHost* layer_tree_host,
50 TaskRunnerProvider* task_runner_provider, 50 TaskRunnerProvider* task_runner_provider,
51 scoped_ptr<BeginFrameSource> external_begin_frame_source) { 51 scoped_ptr<BeginFrameSource> external_begin_frame_source) {
52 return make_scoped_ptr(new ThreadProxy(layer_tree_host, task_runner_provider, 52 return make_scoped_ptr(
53 external_begin_frame_source.Pass())); 53 new ThreadProxy(layer_tree_host, task_runner_provider,
54 std::move(external_begin_frame_source)));
54 } 55 }
55 56
56 ThreadProxy::ThreadProxy( 57 ThreadProxy::ThreadProxy(
57 LayerTreeHost* layer_tree_host, 58 LayerTreeHost* layer_tree_host,
58 TaskRunnerProvider* task_runner_provider, 59 TaskRunnerProvider* task_runner_provider,
59 scoped_ptr<BeginFrameSource> external_begin_frame_source) 60 scoped_ptr<BeginFrameSource> external_begin_frame_source)
60 : task_runner_provider_(task_runner_provider), 61 : task_runner_provider_(task_runner_provider),
61 main_thread_only_vars_unsafe_(this, layer_tree_host), 62 main_thread_only_vars_unsafe_(this, layer_tree_host),
62 compositor_thread_vars_unsafe_( 63 compositor_thread_vars_unsafe_(
63 this, 64 this,
64 layer_tree_host->id(), 65 layer_tree_host->id(),
65 layer_tree_host->rendering_stats_instrumentation(), 66 layer_tree_host->rendering_stats_instrumentation(),
66 external_begin_frame_source.Pass()) { 67 std::move(external_begin_frame_source)) {
67 TRACE_EVENT0("cc", "ThreadProxy::ThreadProxy"); 68 TRACE_EVENT0("cc", "ThreadProxy::ThreadProxy");
68 DCHECK(task_runner_provider_); 69 DCHECK(task_runner_provider_);
69 DCHECK(task_runner_provider_->IsMainThread()); 70 DCHECK(task_runner_provider_->IsMainThread());
70 DCHECK(this->main().layer_tree_host); 71 DCHECK(this->main().layer_tree_host);
71 // TODO(khushalsagar): Move this to LayerTreeHost#InitializeThreaded once 72 // TODO(khushalsagar): Move this to LayerTreeHost#InitializeThreaded once
72 // ThreadProxy is split. LayerTreeHost creates the channel and passes it to 73 // ThreadProxy is split. LayerTreeHost creates the channel and passes it to
73 // ProxyMain#SetChannel. 74 // ProxyMain#SetChannel.
74 SetChannel(ThreadedChannel::Create(this, task_runner_provider_)); 75 SetChannel(ThreadedChannel::Create(this, task_runner_provider_));
75 } 76 }
76 77
(...skipping 27 matching lines...) Expand all
104 commit_completion_event(nullptr), 105 commit_completion_event(nullptr),
105 next_frame_is_newly_committed_frame(false), 106 next_frame_is_newly_committed_frame(false),
106 inside_draw(false), 107 inside_draw(false),
107 input_throttled_until_commit(false), 108 input_throttled_until_commit(false),
108 smoothness_priority_expiration_notifier( 109 smoothness_priority_expiration_notifier(
109 proxy->task_runner_provider() 110 proxy->task_runner_provider()
110 ->ImplThreadTaskRunner(), 111 ->ImplThreadTaskRunner(),
111 base::Bind(&ThreadProxy::RenewTreePriority, base::Unretained(proxy)), 112 base::Bind(&ThreadProxy::RenewTreePriority, base::Unretained(proxy)),
112 base::TimeDelta::FromMilliseconds( 113 base::TimeDelta::FromMilliseconds(
113 kSmoothnessTakesPriorityExpirationDelay * 1000)), 114 kSmoothnessTakesPriorityExpirationDelay * 1000)),
114 external_begin_frame_source(external_begin_frame_source.Pass()), 115 external_begin_frame_source(std::move(external_begin_frame_source)),
115 rendering_stats_instrumentation(rendering_stats_instrumentation), 116 rendering_stats_instrumentation(rendering_stats_instrumentation),
116 weak_factory(proxy) {} 117 weak_factory(proxy) {}
117 118
118 ThreadProxy::CompositorThreadOnly::~CompositorThreadOnly() {} 119 ThreadProxy::CompositorThreadOnly::~CompositorThreadOnly() {}
119 120
120 ThreadProxy::~ThreadProxy() { 121 ThreadProxy::~ThreadProxy() {
121 TRACE_EVENT0("cc", "ThreadProxy::~ThreadProxy"); 122 TRACE_EVENT0("cc", "ThreadProxy::~ThreadProxy");
122 DCHECK(task_runner_provider_->IsMainThread()); 123 DCHECK(task_runner_provider_->IsMainThread());
123 DCHECK(!main().started); 124 DCHECK(!main().started);
124 } 125 }
125 126
126 void ThreadProxy::SetChannel(scoped_ptr<ThreadedChannel> threaded_channel) { 127 void ThreadProxy::SetChannel(scoped_ptr<ThreadedChannel> threaded_channel) {
127 threaded_channel_ = threaded_channel.Pass(); 128 threaded_channel_ = std::move(threaded_channel);
128 main().channel_main = threaded_channel_.get(); 129 main().channel_main = threaded_channel_.get();
129 } 130 }
130 131
131 void ThreadProxy::FinishAllRendering() { 132 void ThreadProxy::FinishAllRendering() {
132 DCHECK(task_runner_provider_->IsMainThread()); 133 DCHECK(task_runner_provider_->IsMainThread());
133 DCHECK(!main().defer_commits); 134 DCHECK(!main().defer_commits);
134 135
135 // Make sure all GL drawing is finished on the impl thread. 136 // Make sure all GL drawing is finished on the impl thread.
136 DebugScopedSetMainThreadBlocked main_thread_blocked(task_runner_provider_); 137 DebugScopedSetMainThreadBlocked main_thread_blocked(task_runner_provider_);
137 CompletionEvent completion; 138 CompletionEvent completion;
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 // In tests the layer tree is destroyed after the scheduler is. 370 // In tests the layer tree is destroyed after the scheduler is.
370 if (impl().scheduler) 371 if (impl().scheduler)
371 impl().scheduler->SetVideoNeedsBeginFrames(needs_begin_frames); 372 impl().scheduler->SetVideoNeedsBeginFrames(needs_begin_frames);
372 } 373 }
373 374
374 void ThreadProxy::PostAnimationEventsToMainThreadOnImplThread( 375 void ThreadProxy::PostAnimationEventsToMainThreadOnImplThread(
375 scoped_ptr<AnimationEventsVector> events) { 376 scoped_ptr<AnimationEventsVector> events) {
376 TRACE_EVENT0("cc", 377 TRACE_EVENT0("cc",
377 "ThreadProxy::PostAnimationEventsToMainThreadOnImplThread"); 378 "ThreadProxy::PostAnimationEventsToMainThreadOnImplThread");
378 DCHECK(task_runner_provider_->IsImplThread()); 379 DCHECK(task_runner_provider_->IsImplThread());
379 impl().channel_impl->SetAnimationEvents(events.Pass()); 380 impl().channel_impl->SetAnimationEvents(std::move(events));
380 } 381 }
381 382
382 bool ThreadProxy::IsInsideDraw() { return impl().inside_draw; } 383 bool ThreadProxy::IsInsideDraw() { return impl().inside_draw; }
383 384
384 void ThreadProxy::SetNeedsRedraw(const gfx::Rect& damage_rect) { 385 void ThreadProxy::SetNeedsRedraw(const gfx::Rect& damage_rect) {
385 TRACE_EVENT0("cc", "ThreadProxy::SetNeedsRedraw"); 386 TRACE_EVENT0("cc", "ThreadProxy::SetNeedsRedraw");
386 DCHECK(task_runner_provider_->IsMainThread()); 387 DCHECK(task_runner_provider_->IsMainThread());
387 main().channel_main->SetNeedsRedrawOnImpl(damage_rect); 388 main().channel_main->SetNeedsRedrawOnImpl(damage_rect);
388 } 389 }
389 390
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
567 begin_main_frame_state->scroll_info = 568 begin_main_frame_state->scroll_info =
568 impl().layer_tree_host_impl->ProcessScrollDeltas(); 569 impl().layer_tree_host_impl->ProcessScrollDeltas();
569 begin_main_frame_state->memory_allocation_limit_bytes = 570 begin_main_frame_state->memory_allocation_limit_bytes =
570 impl().layer_tree_host_impl->memory_allocation_limit_bytes(); 571 impl().layer_tree_host_impl->memory_allocation_limit_bytes();
571 begin_main_frame_state->evicted_ui_resources = 572 begin_main_frame_state->evicted_ui_resources =
572 impl().layer_tree_host_impl->EvictedUIResourcesExist(); 573 impl().layer_tree_host_impl->EvictedUIResourcesExist();
573 // TODO(vmpstr): This needs to be fixed if 574 // TODO(vmpstr): This needs to be fixed if
574 // main_frame_before_activation_enabled is set, since we might run this code 575 // main_frame_before_activation_enabled is set, since we might run this code
575 // twice before recording a duration. crbug.com/469824 576 // twice before recording a duration. crbug.com/469824
576 impl().last_begin_main_frame_args = begin_main_frame_state->begin_frame_args; 577 impl().last_begin_main_frame_args = begin_main_frame_state->begin_frame_args;
577 impl().channel_impl->BeginMainFrame(begin_main_frame_state.Pass()); 578 impl().channel_impl->BeginMainFrame(std::move(begin_main_frame_state));
578 devtools_instrumentation::DidRequestMainThreadFrame( 579 devtools_instrumentation::DidRequestMainThreadFrame(
579 impl().layer_tree_host_id); 580 impl().layer_tree_host_id);
580 } 581 }
581 582
582 void ThreadProxy::SendBeginMainFrameNotExpectedSoon() { 583 void ThreadProxy::SendBeginMainFrameNotExpectedSoon() {
583 impl().channel_impl->BeginMainFrameNotExpectedSoon(); 584 impl().channel_impl->BeginMainFrameNotExpectedSoon();
584 } 585 }
585 586
586 void ThreadProxy::BeginMainFrame( 587 void ThreadProxy::BeginMainFrame(
587 scoped_ptr<BeginMainFrameAndCommitState> begin_main_frame_state) { 588 scoped_ptr<BeginMainFrameAndCommitState> begin_main_frame_state) {
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
930 } 931 }
931 932
932 void ThreadProxy::DidCompleteSwapBuffers() { 933 void ThreadProxy::DidCompleteSwapBuffers() {
933 DCHECK(task_runner_provider_->IsMainThread()); 934 DCHECK(task_runner_provider_->IsMainThread());
934 main().layer_tree_host->DidCompleteSwapBuffers(); 935 main().layer_tree_host->DidCompleteSwapBuffers();
935 } 936 }
936 937
937 void ThreadProxy::SetAnimationEvents(scoped_ptr<AnimationEventsVector> events) { 938 void ThreadProxy::SetAnimationEvents(scoped_ptr<AnimationEventsVector> events) {
938 TRACE_EVENT0("cc", "ThreadProxy::SetAnimationEvents"); 939 TRACE_EVENT0("cc", "ThreadProxy::SetAnimationEvents");
939 DCHECK(task_runner_provider_->IsMainThread()); 940 DCHECK(task_runner_provider_->IsMainThread());
940 main().layer_tree_host->SetAnimationEvents(events.Pass()); 941 main().layer_tree_host->SetAnimationEvents(std::move(events));
941 } 942 }
942 943
943 void ThreadProxy::InitializeImplOnImpl(CompletionEvent* completion, 944 void ThreadProxy::InitializeImplOnImpl(CompletionEvent* completion,
944 LayerTreeHost* layer_tree_host) { 945 LayerTreeHost* layer_tree_host) {
945 TRACE_EVENT0("cc", "ThreadProxy::InitializeImplOnImplThread"); 946 TRACE_EVENT0("cc", "ThreadProxy::InitializeImplOnImplThread");
946 DCHECK(task_runner_provider_->IsImplThread()); 947 DCHECK(task_runner_provider_->IsImplThread());
947 DCHECK(task_runner_provider_->IsMainThreadBlocked()); 948 DCHECK(task_runner_provider_->IsMainThreadBlocked());
948 DCHECK(layer_tree_host); 949 DCHECK(layer_tree_host);
949 950
950 // TODO(khushalsagar): ThreadedChannel will create ProxyImpl here and pass a 951 // TODO(khushalsagar): ThreadedChannel will create ProxyImpl here and pass a
951 // reference to itself. 952 // reference to itself.
952 impl().channel_impl = threaded_channel_.get(); 953 impl().channel_impl = threaded_channel_.get();
953 954
954 impl().layer_tree_host_impl = layer_tree_host->CreateLayerTreeHostImpl(this); 955 impl().layer_tree_host_impl = layer_tree_host->CreateLayerTreeHostImpl(this);
955 956
956 SchedulerSettings scheduler_settings( 957 SchedulerSettings scheduler_settings(
957 layer_tree_host->settings().ToSchedulerSettings()); 958 layer_tree_host->settings().ToSchedulerSettings());
958 959
959 scoped_ptr<CompositorTimingHistory> compositor_timing_history( 960 scoped_ptr<CompositorTimingHistory> compositor_timing_history(
960 new CompositorTimingHistory(CompositorTimingHistory::RENDERER_UMA, 961 new CompositorTimingHistory(CompositorTimingHistory::RENDERER_UMA,
961 impl().rendering_stats_instrumentation)); 962 impl().rendering_stats_instrumentation));
962 963
963 impl().scheduler = 964 impl().scheduler =
964 Scheduler::Create(this, scheduler_settings, impl().layer_tree_host_id, 965 Scheduler::Create(this, scheduler_settings, impl().layer_tree_host_id,
965 task_runner_provider_->ImplThreadTaskRunner(), 966 task_runner_provider_->ImplThreadTaskRunner(),
966 impl().external_begin_frame_source.get(), 967 impl().external_begin_frame_source.get(),
967 compositor_timing_history.Pass()); 968 std::move(compositor_timing_history));
968 969
969 DCHECK_EQ(impl().scheduler->visible(), 970 DCHECK_EQ(impl().scheduler->visible(),
970 impl().layer_tree_host_impl->visible()); 971 impl().layer_tree_host_impl->visible());
971 impl_thread_weak_ptr_ = impl().weak_factory.GetWeakPtr(); 972 impl_thread_weak_ptr_ = impl().weak_factory.GetWeakPtr();
972 completion->Signal(); 973 completion->Signal();
973 } 974 }
974 975
975 void ThreadProxy::InitializeOutputSurfaceOnImpl(OutputSurface* output_surface) { 976 void ThreadProxy::InitializeOutputSurfaceOnImpl(OutputSurface* output_surface) {
976 TRACE_EVENT0("cc", "ThreadProxy::InitializeOutputSurfaceOnImplThread"); 977 TRACE_EVENT0("cc", "ThreadProxy::InitializeOutputSurfaceOnImplThread");
977 DCHECK(task_runner_provider_->IsImplThread()); 978 DCHECK(task_runner_provider_->IsImplThread());
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
1162 bool animate) { 1163 bool animate) {
1163 DCHECK(task_runner_provider_->IsImplThread()); 1164 DCHECK(task_runner_provider_->IsImplThread());
1164 impl().layer_tree_host_impl->top_controls_manager()->UpdateTopControlsState( 1165 impl().layer_tree_host_impl->top_controls_manager()->UpdateTopControlsState(
1165 constraints, current, animate); 1166 constraints, current, animate);
1166 } 1167 }
1167 1168
1168 void ThreadProxy::PostFrameTimingEventsOnImplThread( 1169 void ThreadProxy::PostFrameTimingEventsOnImplThread(
1169 scoped_ptr<FrameTimingTracker::CompositeTimingSet> composite_events, 1170 scoped_ptr<FrameTimingTracker::CompositeTimingSet> composite_events,
1170 scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events) { 1171 scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events) {
1171 DCHECK(task_runner_provider_->IsImplThread()); 1172 DCHECK(task_runner_provider_->IsImplThread());
1172 impl().channel_impl->PostFrameTimingEventsOnMain(composite_events.Pass(), 1173 impl().channel_impl->PostFrameTimingEventsOnMain(
1173 main_frame_events.Pass()); 1174 std::move(composite_events), std::move(main_frame_events));
1174 } 1175 }
1175 1176
1176 void ThreadProxy::PostFrameTimingEventsOnMain( 1177 void ThreadProxy::PostFrameTimingEventsOnMain(
1177 scoped_ptr<FrameTimingTracker::CompositeTimingSet> composite_events, 1178 scoped_ptr<FrameTimingTracker::CompositeTimingSet> composite_events,
1178 scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events) { 1179 scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events) {
1179 DCHECK(task_runner_provider_->IsMainThread()); 1180 DCHECK(task_runner_provider_->IsMainThread());
1180 main().layer_tree_host->RecordFrameTimingEvents(composite_events.Pass(), 1181 main().layer_tree_host->RecordFrameTimingEvents(std::move(composite_events),
1181 main_frame_events.Pass()); 1182 std::move(main_frame_events));
1182 } 1183 }
1183 1184
1184 base::WeakPtr<ProxyMain> ThreadProxy::GetMainWeakPtr() { 1185 base::WeakPtr<ProxyMain> ThreadProxy::GetMainWeakPtr() {
1185 return main_thread_weak_ptr_; 1186 return main_thread_weak_ptr_;
1186 } 1187 }
1187 1188
1188 base::WeakPtr<ProxyImpl> ThreadProxy::GetImplWeakPtr() { 1189 base::WeakPtr<ProxyImpl> ThreadProxy::GetImplWeakPtr() {
1189 return impl_thread_weak_ptr_; 1190 return impl_thread_weak_ptr_;
1190 } 1191 }
1191 1192
1192 } // namespace cc 1193 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/single_thread_proxy.cc ('k') | cc/trees/threaded_channel.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698