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 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 layer_tree_host_impl_->BeginCommit(); | 197 layer_tree_host_impl_->BeginCommit(); |
198 | 198 |
199 if (layer_tree_host_impl_->EvictedUIResourcesExist()) | 199 if (layer_tree_host_impl_->EvictedUIResourcesExist()) |
200 layer_tree_host_->GetUIResourceManager()->RecreateUIResources(); | 200 layer_tree_host_->GetUIResourceManager()->RecreateUIResources(); |
201 | 201 |
202 layer_tree_host_->FinishCommitOnImplThread(layer_tree_host_impl_.get()); | 202 layer_tree_host_->FinishCommitOnImplThread(layer_tree_host_impl_.get()); |
203 | 203 |
204 if (scheduler_on_impl_thread_) | 204 if (scheduler_on_impl_thread_) |
205 scheduler_on_impl_thread_->DidCommit(); | 205 scheduler_on_impl_thread_->DidCommit(); |
206 | 206 |
207 // Issue decode callbacks. | 207 IssueImageDecodeFinishedCallbacks(); |
208 auto completed_decode_callbacks = | |
209 layer_tree_host_impl_->TakeCompletedImageDecodeCallbacks(); | |
210 for (auto& callback : completed_decode_callbacks) | |
211 callback.Run(); | |
212 | |
213 layer_tree_host_impl_->CommitComplete(); | 208 layer_tree_host_impl_->CommitComplete(); |
214 | 209 |
215 // Commit goes directly to the active tree, but we need to synchronously | 210 // Commit goes directly to the active tree, but we need to synchronously |
216 // "activate" the tree still during commit to satisfy any potential | 211 // "activate" the tree still during commit to satisfy any potential |
217 // SetNextCommitWaitsForActivation calls. Unfortunately, the tree | 212 // SetNextCommitWaitsForActivation calls. Unfortunately, the tree |
218 // might not be ready to draw, so DidActivateSyncTree must set | 213 // might not be ready to draw, so DidActivateSyncTree must set |
219 // the flag to force the tree to not draw until textures are ready. | 214 // the flag to force the tree to not draw until textures are ready. |
220 NotifyReadyToActivate(); | 215 NotifyReadyToActivate(); |
221 } | 216 } |
222 } | 217 } |
223 | 218 |
| 219 void SingleThreadProxy::IssueImageDecodeFinishedCallbacks() { |
| 220 DCHECK(task_runner_provider_->IsImplThread()); |
| 221 |
| 222 auto completed_decode_callbacks = |
| 223 layer_tree_host_impl_->TakeCompletedImageDecodeCallbacks(); |
| 224 for (auto& callback : completed_decode_callbacks) |
| 225 callback.Run(); |
| 226 } |
| 227 |
224 void SingleThreadProxy::CommitComplete() { | 228 void SingleThreadProxy::CommitComplete() { |
225 // Commit complete happens on the main side after activate to satisfy any | 229 // Commit complete happens on the main side after activate to satisfy any |
226 // SetNextCommitWaitsForActivation calls. | 230 // SetNextCommitWaitsForActivation calls. |
227 DCHECK(!layer_tree_host_impl_->pending_tree()) | 231 DCHECK(!layer_tree_host_impl_->pending_tree()) |
228 << "Activation is expected to have synchronously occurred by now."; | 232 << "Activation is expected to have synchronously occurred by now."; |
229 DCHECK(commit_blocking_task_runner_); | 233 DCHECK(commit_blocking_task_runner_); |
230 | 234 |
231 DebugScopedSetMainThread main(task_runner_provider_); | 235 DebugScopedSetMainThread main(task_runner_provider_); |
232 commit_blocking_task_runner_.reset(); | 236 commit_blocking_task_runner_.reset(); |
233 layer_tree_host_->CommitComplete(); | 237 layer_tree_host_->CommitComplete(); |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
431 void SingleThreadProxy::OnDrawForCompositorFrameSink( | 435 void SingleThreadProxy::OnDrawForCompositorFrameSink( |
432 bool resourceless_software_draw) { | 436 bool resourceless_software_draw) { |
433 NOTREACHED() << "Implemented by ThreadProxy for synchronous compositor."; | 437 NOTREACHED() << "Implemented by ThreadProxy for synchronous compositor."; |
434 } | 438 } |
435 | 439 |
436 void SingleThreadProxy::NeedsImplSideInvalidation() { | 440 void SingleThreadProxy::NeedsImplSideInvalidation() { |
437 DCHECK(scheduler_on_impl_thread_); | 441 DCHECK(scheduler_on_impl_thread_); |
438 scheduler_on_impl_thread_->SetNeedsImplSideInvalidation(); | 442 scheduler_on_impl_thread_->SetNeedsImplSideInvalidation(); |
439 } | 443 } |
440 | 444 |
| 445 void SingleThreadProxy::NotifyImageDecodeRequestFinished() { |
| 446 // If we don't have a scheduler, then just issue the callbacks here. |
| 447 // Otherwise, schedule a commit. |
| 448 if (!scheduler_on_impl_thread_) { |
| 449 DebugScopedSetMainThreadBlocked main_thread_blocked(task_runner_provider_); |
| 450 DebugScopedSetImplThread impl(task_runner_provider_); |
| 451 |
| 452 IssueImageDecodeFinishedCallbacks(); |
| 453 return; |
| 454 } |
| 455 SetNeedsCommitOnImplThread(); |
| 456 } |
| 457 |
441 void SingleThreadProxy::CompositeImmediately(base::TimeTicks frame_begin_time) { | 458 void SingleThreadProxy::CompositeImmediately(base::TimeTicks frame_begin_time) { |
442 TRACE_EVENT0("cc,benchmark", "SingleThreadProxy::CompositeImmediately"); | 459 TRACE_EVENT0("cc,benchmark", "SingleThreadProxy::CompositeImmediately"); |
443 DCHECK(task_runner_provider_->IsMainThread()); | 460 DCHECK(task_runner_provider_->IsMainThread()); |
444 #if DCHECK_IS_ON() | 461 #if DCHECK_IS_ON() |
445 DCHECK(!inside_impl_frame_); | 462 DCHECK(!inside_impl_frame_); |
446 #endif | 463 #endif |
447 base::AutoReset<bool> inside_composite(&inside_synchronous_composite_, true); | 464 base::AutoReset<bool> inside_composite(&inside_synchronous_composite_, true); |
448 | 465 |
449 if (compositor_frame_sink_lost_) { | 466 if (compositor_frame_sink_lost_) { |
450 RequestNewCompositorFrameSink(); | 467 RequestNewCompositorFrameSink(); |
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
772 void SingleThreadProxy::DidFinishImplFrame() { | 789 void SingleThreadProxy::DidFinishImplFrame() { |
773 layer_tree_host_impl_->DidFinishImplFrame(); | 790 layer_tree_host_impl_->DidFinishImplFrame(); |
774 #if DCHECK_IS_ON() | 791 #if DCHECK_IS_ON() |
775 DCHECK(inside_impl_frame_) | 792 DCHECK(inside_impl_frame_) |
776 << "DidFinishImplFrame called while not inside an impl frame!"; | 793 << "DidFinishImplFrame called while not inside an impl frame!"; |
777 inside_impl_frame_ = false; | 794 inside_impl_frame_ = false; |
778 #endif | 795 #endif |
779 } | 796 } |
780 | 797 |
781 } // namespace cc | 798 } // namespace cc |
OLD | NEW |