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/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/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
9 #include "base/profiler/scoped_tracker.h" | 9 #include "base/profiler/scoped_tracker.h" |
10 #include "base/trace_event/trace_event.h" | 10 #include "base/trace_event/trace_event.h" |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 layer_tree_host_impl_->BeginCommit(); | 200 layer_tree_host_impl_->BeginCommit(); |
201 | 201 |
202 if (layer_tree_host_impl_->EvictedUIResourcesExist()) | 202 if (layer_tree_host_impl_->EvictedUIResourcesExist()) |
203 layer_tree_host_->GetUIResourceManager()->RecreateUIResources(); | 203 layer_tree_host_->GetUIResourceManager()->RecreateUIResources(); |
204 | 204 |
205 layer_tree_host_->FinishCommitOnImplThread(layer_tree_host_impl_.get()); | 205 layer_tree_host_->FinishCommitOnImplThread(layer_tree_host_impl_.get()); |
206 | 206 |
207 if (scheduler_on_impl_thread_) | 207 if (scheduler_on_impl_thread_) |
208 scheduler_on_impl_thread_->DidCommit(); | 208 scheduler_on_impl_thread_->DidCommit(); |
209 | 209 |
210 // Issue decode callbacks. | 210 IssueImageDecodeFinishedCallbacks(); |
211 auto completed_decode_callbacks = | |
212 layer_tree_host_impl_->TakeCompletedImageDecodeCallbacks(); | |
213 for (auto& callback : completed_decode_callbacks) | |
214 callback.Run(); | |
215 | |
216 layer_tree_host_impl_->CommitComplete(); | 211 layer_tree_host_impl_->CommitComplete(); |
217 | 212 |
218 // Commit goes directly to the active tree, but we need to synchronously | 213 // Commit goes directly to the active tree, but we need to synchronously |
219 // "activate" the tree still during commit to satisfy any potential | 214 // "activate" the tree still during commit to satisfy any potential |
220 // SetNextCommitWaitsForActivation calls. Unfortunately, the tree | 215 // SetNextCommitWaitsForActivation calls. Unfortunately, the tree |
221 // might not be ready to draw, so DidActivateSyncTree must set | 216 // might not be ready to draw, so DidActivateSyncTree must set |
222 // the flag to force the tree to not draw until textures are ready. | 217 // the flag to force the tree to not draw until textures are ready. |
223 NotifyReadyToActivate(); | 218 NotifyReadyToActivate(); |
224 } | 219 } |
225 } | 220 } |
226 | 221 |
| 222 void SingleThreadProxy::IssueImageDecodeFinishedCallbacks() { |
| 223 DCHECK(task_runner_provider_->IsImplThread()); |
| 224 |
| 225 auto completed_decode_callbacks = |
| 226 layer_tree_host_impl_->TakeCompletedImageDecodeCallbacks(); |
| 227 for (auto& callback : completed_decode_callbacks) |
| 228 callback.Run(); |
| 229 } |
| 230 |
227 void SingleThreadProxy::CommitComplete() { | 231 void SingleThreadProxy::CommitComplete() { |
228 // Commit complete happens on the main side after activate to satisfy any | 232 // Commit complete happens on the main side after activate to satisfy any |
229 // SetNextCommitWaitsForActivation calls. | 233 // SetNextCommitWaitsForActivation calls. |
230 DCHECK(!layer_tree_host_impl_->pending_tree()) | 234 DCHECK(!layer_tree_host_impl_->pending_tree()) |
231 << "Activation is expected to have synchronously occurred by now."; | 235 << "Activation is expected to have synchronously occurred by now."; |
232 DCHECK(commit_blocking_task_runner_); | 236 DCHECK(commit_blocking_task_runner_); |
233 | 237 |
234 DebugScopedSetMainThread main(task_runner_provider_); | 238 DebugScopedSetMainThread main(task_runner_provider_); |
235 commit_blocking_task_runner_.reset(); | 239 commit_blocking_task_runner_.reset(); |
236 layer_tree_host_->CommitComplete(); | 240 layer_tree_host_->CommitComplete(); |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
439 void SingleThreadProxy::OnDrawForCompositorFrameSink( | 443 void SingleThreadProxy::OnDrawForCompositorFrameSink( |
440 bool resourceless_software_draw) { | 444 bool resourceless_software_draw) { |
441 NOTREACHED() << "Implemented by ThreadProxy for synchronous compositor."; | 445 NOTREACHED() << "Implemented by ThreadProxy for synchronous compositor."; |
442 } | 446 } |
443 | 447 |
444 void SingleThreadProxy::NeedsImplSideInvalidation() { | 448 void SingleThreadProxy::NeedsImplSideInvalidation() { |
445 DCHECK(scheduler_on_impl_thread_); | 449 DCHECK(scheduler_on_impl_thread_); |
446 scheduler_on_impl_thread_->SetNeedsImplSideInvalidation(); | 450 scheduler_on_impl_thread_->SetNeedsImplSideInvalidation(); |
447 } | 451 } |
448 | 452 |
| 453 void SingleThreadProxy::NotifyImageDecodeRequestFinished() { |
| 454 // If we don't have a scheduler, then just issue the callbacks here. |
| 455 // Otherwise, schedule a commit. |
| 456 if (!scheduler_on_impl_thread_) { |
| 457 DebugScopedSetMainThreadBlocked main_thread_blocked(task_runner_provider_); |
| 458 DebugScopedSetImplThread impl(task_runner_provider_); |
| 459 |
| 460 IssueImageDecodeFinishedCallbacks(); |
| 461 return; |
| 462 } |
| 463 SetNeedsCommitOnImplThread(); |
| 464 } |
| 465 |
449 void SingleThreadProxy::CompositeImmediately(base::TimeTicks frame_begin_time) { | 466 void SingleThreadProxy::CompositeImmediately(base::TimeTicks frame_begin_time) { |
450 TRACE_EVENT0("cc,benchmark", "SingleThreadProxy::CompositeImmediately"); | 467 TRACE_EVENT0("cc,benchmark", "SingleThreadProxy::CompositeImmediately"); |
451 DCHECK(task_runner_provider_->IsMainThread()); | 468 DCHECK(task_runner_provider_->IsMainThread()); |
452 #if DCHECK_IS_ON() | 469 #if DCHECK_IS_ON() |
453 DCHECK(!inside_impl_frame_); | 470 DCHECK(!inside_impl_frame_); |
454 #endif | 471 #endif |
455 base::AutoReset<bool> inside_composite(&inside_synchronous_composite_, true); | 472 base::AutoReset<bool> inside_composite(&inside_synchronous_composite_, true); |
456 | 473 |
457 if (compositor_frame_sink_lost_) { | 474 if (compositor_frame_sink_lost_) { |
458 RequestNewCompositorFrameSink(); | 475 RequestNewCompositorFrameSink(); |
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
805 << "DidFinishImplFrame called while not inside an impl frame!"; | 822 << "DidFinishImplFrame called while not inside an impl frame!"; |
806 inside_impl_frame_ = false; | 823 inside_impl_frame_ = false; |
807 #endif | 824 #endif |
808 } | 825 } |
809 | 826 |
810 void SingleThreadProxy::DidReceiveCompositorFrameAck() { | 827 void SingleThreadProxy::DidReceiveCompositorFrameAck() { |
811 layer_tree_host_->DidReceiveCompositorFrameAck(); | 828 layer_tree_host_->DidReceiveCompositorFrameAck(); |
812 } | 829 } |
813 | 830 |
814 } // namespace cc | 831 } // namespace cc |
OLD | NEW |