| OLD | NEW |
| 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 30 matching lines...) Expand all Loading... |
| 41 } // namespace | 41 } // namespace |
| 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 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, | 50 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
| 51 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) { | 51 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, |
| 52 return make_scoped_ptr( | 52 scoped_ptr<ExternalBeginFrameSource> external_begin_frame_source) { |
| 53 new ThreadProxy(layer_tree_host, main_task_runner, impl_task_runner)); | 53 return make_scoped_ptr(new ThreadProxy(layer_tree_host, |
| 54 main_task_runner, |
| 55 impl_task_runner, |
| 56 external_begin_frame_source.Pass())); |
| 54 } | 57 } |
| 55 | 58 |
| 56 ThreadProxy::ThreadProxy( | 59 ThreadProxy::ThreadProxy( |
| 57 LayerTreeHost* layer_tree_host, | 60 LayerTreeHost* layer_tree_host, |
| 58 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, | 61 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
| 59 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) | 62 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, |
| 63 scoped_ptr<ExternalBeginFrameSource> external_begin_frame_source) |
| 60 : Proxy(main_task_runner, impl_task_runner), | 64 : Proxy(main_task_runner, impl_task_runner), |
| 61 main_thread_only_vars_unsafe_(this, layer_tree_host->id()), | 65 main_thread_only_vars_unsafe_(this, layer_tree_host->id()), |
| 62 main_thread_or_blocked_vars_unsafe_(layer_tree_host), | 66 main_thread_or_blocked_vars_unsafe_(layer_tree_host), |
| 63 compositor_thread_vars_unsafe_( | 67 compositor_thread_vars_unsafe_( |
| 64 this, | 68 this, |
| 65 layer_tree_host->id(), | 69 layer_tree_host->id(), |
| 66 layer_tree_host->rendering_stats_instrumentation()) { | 70 layer_tree_host->rendering_stats_instrumentation()), |
| 71 external_begin_frame_source_(external_begin_frame_source.Pass()) { |
| 67 TRACE_EVENT0("cc", "ThreadProxy::ThreadProxy"); | 72 TRACE_EVENT0("cc", "ThreadProxy::ThreadProxy"); |
| 68 DCHECK(IsMainThread()); | 73 DCHECK(IsMainThread()); |
| 69 DCHECK(this->layer_tree_host()); | 74 DCHECK(this->layer_tree_host()); |
| 70 } | 75 } |
| 71 | 76 |
| 72 ThreadProxy::MainThreadOnly::MainThreadOnly(ThreadProxy* proxy, | 77 ThreadProxy::MainThreadOnly::MainThreadOnly(ThreadProxy* proxy, |
| 73 int layer_tree_host_id) | 78 int layer_tree_host_id) |
| 74 : layer_tree_host_id(layer_tree_host_id), | 79 : layer_tree_host_id(layer_tree_host_id), |
| 75 animate_requested(false), | 80 animate_requested(false), |
| 76 commit_requested(false), | 81 commit_requested(false), |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 341 | 346 |
| 342 void ThreadProxy::DidSwapBuffersCompleteOnImplThread() { | 347 void ThreadProxy::DidSwapBuffersCompleteOnImplThread() { |
| 343 TRACE_EVENT0("cc", "ThreadProxy::DidSwapBuffersCompleteOnImplThread"); | 348 TRACE_EVENT0("cc", "ThreadProxy::DidSwapBuffersCompleteOnImplThread"); |
| 344 DCHECK(IsImplThread()); | 349 DCHECK(IsImplThread()); |
| 345 impl().scheduler->DidSwapBuffersComplete(); | 350 impl().scheduler->DidSwapBuffersComplete(); |
| 346 Proxy::MainThreadTaskRunner()->PostTask( | 351 Proxy::MainThreadTaskRunner()->PostTask( |
| 347 FROM_HERE, | 352 FROM_HERE, |
| 348 base::Bind(&ThreadProxy::DidCompleteSwapBuffers, main_thread_weak_ptr_)); | 353 base::Bind(&ThreadProxy::DidCompleteSwapBuffers, main_thread_weak_ptr_)); |
| 349 } | 354 } |
| 350 | 355 |
| 351 BeginFrameSource* ThreadProxy::ExternalBeginFrameSource() { | |
| 352 return impl().layer_tree_host_impl.get(); | |
| 353 } | |
| 354 | |
| 355 void ThreadProxy::WillBeginImplFrame(const BeginFrameArgs& args) { | 356 void ThreadProxy::WillBeginImplFrame(const BeginFrameArgs& args) { |
| 356 impl().layer_tree_host_impl->WillBeginImplFrame(args); | 357 impl().layer_tree_host_impl->WillBeginImplFrame(args); |
| 357 } | 358 } |
| 358 | 359 |
| 359 void ThreadProxy::OnCanDrawStateChanged(bool can_draw) { | 360 void ThreadProxy::OnCanDrawStateChanged(bool can_draw) { |
| 360 TRACE_EVENT1( | 361 TRACE_EVENT1( |
| 361 "cc", "ThreadProxy::OnCanDrawStateChanged", "can_draw", can_draw); | 362 "cc", "ThreadProxy::OnCanDrawStateChanged", "can_draw", can_draw); |
| 362 DCHECK(IsImplThread()); | 363 DCHECK(IsImplThread()); |
| 363 impl().scheduler->SetCanDraw(can_draw); | 364 impl().scheduler->SetCanDraw(can_draw); |
| 364 UpdateBackgroundAnimateTicking(); | 365 UpdateBackgroundAnimateTicking(); |
| (...skipping 803 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1168 | 1169 |
| 1169 void ThreadProxy::InitializeImplOnImplThread(CompletionEvent* completion) { | 1170 void ThreadProxy::InitializeImplOnImplThread(CompletionEvent* completion) { |
| 1170 TRACE_EVENT0("cc", "ThreadProxy::InitializeImplOnImplThread"); | 1171 TRACE_EVENT0("cc", "ThreadProxy::InitializeImplOnImplThread"); |
| 1171 DCHECK(IsImplThread()); | 1172 DCHECK(IsImplThread()); |
| 1172 impl().layer_tree_host_impl = | 1173 impl().layer_tree_host_impl = |
| 1173 layer_tree_host()->CreateLayerTreeHostImpl(this); | 1174 layer_tree_host()->CreateLayerTreeHostImpl(this); |
| 1174 SchedulerSettings scheduler_settings(layer_tree_host()->settings()); | 1175 SchedulerSettings scheduler_settings(layer_tree_host()->settings()); |
| 1175 impl().scheduler = Scheduler::Create(this, | 1176 impl().scheduler = Scheduler::Create(this, |
| 1176 scheduler_settings, | 1177 scheduler_settings, |
| 1177 impl().layer_tree_host_id, | 1178 impl().layer_tree_host_id, |
| 1178 ImplThreadTaskRunner()); | 1179 ImplThreadTaskRunner(), |
| 1180 external_begin_frame_source_.Pass()); |
| 1179 impl().scheduler->SetVisible(impl().layer_tree_host_impl->visible()); | 1181 impl().scheduler->SetVisible(impl().layer_tree_host_impl->visible()); |
| 1180 | 1182 |
| 1181 impl_thread_weak_ptr_ = impl().weak_factory.GetWeakPtr(); | 1183 impl_thread_weak_ptr_ = impl().weak_factory.GetWeakPtr(); |
| 1182 completion->Signal(); | 1184 completion->Signal(); |
| 1183 } | 1185 } |
| 1184 | 1186 |
| 1185 void ThreadProxy::DeleteContentsTexturesOnImplThread( | 1187 void ThreadProxy::DeleteContentsTexturesOnImplThread( |
| 1186 CompletionEvent* completion) { | 1188 CompletionEvent* completion) { |
| 1187 TRACE_EVENT0("cc", "ThreadProxy::DeleteContentsTexturesOnImplThread"); | 1189 TRACE_EVENT0("cc", "ThreadProxy::DeleteContentsTexturesOnImplThread"); |
| 1188 DCHECK(IsImplThread()); | 1190 DCHECK(IsImplThread()); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1228 completion->Signal(); | 1230 completion->Signal(); |
| 1229 } | 1231 } |
| 1230 | 1232 |
| 1231 void ThreadProxy::LayerTreeHostClosedOnImplThread(CompletionEvent* completion) { | 1233 void ThreadProxy::LayerTreeHostClosedOnImplThread(CompletionEvent* completion) { |
| 1232 TRACE_EVENT0("cc", "ThreadProxy::LayerTreeHostClosedOnImplThread"); | 1234 TRACE_EVENT0("cc", "ThreadProxy::LayerTreeHostClosedOnImplThread"); |
| 1233 DCHECK(IsImplThread()); | 1235 DCHECK(IsImplThread()); |
| 1234 DCHECK(IsMainThreadBlocked()); | 1236 DCHECK(IsMainThreadBlocked()); |
| 1235 layer_tree_host()->DeleteContentsTexturesOnImplThread( | 1237 layer_tree_host()->DeleteContentsTexturesOnImplThread( |
| 1236 impl().layer_tree_host_impl->resource_provider()); | 1238 impl().layer_tree_host_impl->resource_provider()); |
| 1237 impl().current_resource_update_controller = nullptr; | 1239 impl().current_resource_update_controller = nullptr; |
| 1238 impl().layer_tree_host_impl->SetNeedsBeginFrames(false); | |
| 1239 impl().scheduler = nullptr; | 1240 impl().scheduler = nullptr; |
| 1240 impl().layer_tree_host_impl = nullptr; | 1241 impl().layer_tree_host_impl = nullptr; |
| 1241 impl().weak_factory.InvalidateWeakPtrs(); | 1242 impl().weak_factory.InvalidateWeakPtrs(); |
| 1242 // We need to explicitly cancel the notifier, since it isn't using weak ptrs. | 1243 // We need to explicitly cancel the notifier, since it isn't using weak ptrs. |
| 1243 // TODO(vmpstr): We should see if we can make it use weak ptrs and still keep | 1244 // TODO(vmpstr): We should see if we can make it use weak ptrs and still keep |
| 1244 // the convention of having a weak ptr factory initialized last. Alternatively | 1245 // the convention of having a weak ptr factory initialized last. Alternatively |
| 1245 // we should moved the notifier (and RenewTreePriority) to LTHI. See | 1246 // we should moved the notifier (and RenewTreePriority) to LTHI. See |
| 1246 // crbug.com/411972 | 1247 // crbug.com/411972 |
| 1247 impl().smoothness_priority_expiration_notifier.Cancel(); | 1248 impl().smoothness_priority_expiration_notifier.Cancel(); |
| 1248 impl().contents_texture_manager = NULL; | 1249 impl().contents_texture_manager = NULL; |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1386 | 1387 |
| 1387 impl().timing_history.DidActivateSyncTree(); | 1388 impl().timing_history.DidActivateSyncTree(); |
| 1388 } | 1389 } |
| 1389 | 1390 |
| 1390 void ThreadProxy::DidManageTiles() { | 1391 void ThreadProxy::DidManageTiles() { |
| 1391 DCHECK(IsImplThread()); | 1392 DCHECK(IsImplThread()); |
| 1392 impl().scheduler->DidManageTiles(); | 1393 impl().scheduler->DidManageTiles(); |
| 1393 } | 1394 } |
| 1394 | 1395 |
| 1395 } // namespace cc | 1396 } // namespace cc |
| OLD | NEW |