| 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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 | 145 |
| 146 if (scheduler_on_impl_thread_) | 146 if (scheduler_on_impl_thread_) |
| 147 scheduler_on_impl_thread_->DidLoseOutputSurface(); | 147 scheduler_on_impl_thread_->DidLoseOutputSurface(); |
| 148 return layer_tree_host_impl_->ReleaseOutputSurface(); | 148 return layer_tree_host_impl_->ReleaseOutputSurface(); |
| 149 } | 149 } |
| 150 | 150 |
| 151 void SingleThreadProxy::SetOutputSurface(OutputSurface* output_surface) { | 151 void SingleThreadProxy::SetOutputSurface(OutputSurface* output_surface) { |
| 152 DCHECK(task_runner_provider_->IsMainThread()); | 152 DCHECK(task_runner_provider_->IsMainThread()); |
| 153 DCHECK(layer_tree_host_->output_surface_lost()); | 153 DCHECK(layer_tree_host_->output_surface_lost()); |
| 154 DCHECK(output_surface_creation_requested_); | 154 DCHECK(output_surface_creation_requested_); |
| 155 renderer_capabilities_for_main_thread_ = RendererCapabilities(); |
| 155 | 156 |
| 156 bool success; | 157 bool success; |
| 157 { | 158 { |
| 158 DebugScopedSetMainThreadBlocked main_thread_blocked(task_runner_provider_); | 159 DebugScopedSetMainThreadBlocked main_thread_blocked(task_runner_provider_); |
| 159 DebugScopedSetImplThread impl(task_runner_provider_); | 160 DebugScopedSetImplThread impl(task_runner_provider_); |
| 160 success = layer_tree_host_impl_->InitializeRenderer(output_surface); | 161 success = layer_tree_host_impl_->InitializeRenderer(output_surface); |
| 161 } | 162 } |
| 162 | 163 |
| 163 if (success) { | 164 if (success) { |
| 164 layer_tree_host_->DidInitializeOutputSurface(); | 165 layer_tree_host_->DidInitializeOutputSurface(); |
| 165 if (scheduler_on_impl_thread_) | 166 if (scheduler_on_impl_thread_) |
| 166 scheduler_on_impl_thread_->DidCreateAndInitializeOutputSurface(); | 167 scheduler_on_impl_thread_->DidCreateAndInitializeOutputSurface(); |
| 167 else if (!inside_synchronous_composite_) | 168 else if (!inside_synchronous_composite_) |
| 168 SetNeedsCommit(); | 169 SetNeedsCommit(); |
| 169 output_surface_creation_requested_ = false; | 170 output_surface_creation_requested_ = false; |
| 170 } else { | 171 } else { |
| 171 // DidFailToInitializeOutputSurface is treated as a RequestNewOutputSurface, | 172 // DidFailToInitializeOutputSurface is treated as a RequestNewOutputSurface, |
| 172 // and so output_surface_creation_requested remains true. | 173 // and so output_surface_creation_requested remains true. |
| 173 layer_tree_host_->DidFailToInitializeOutputSurface(); | 174 layer_tree_host_->DidFailToInitializeOutputSurface(); |
| 174 } | 175 } |
| 175 } | 176 } |
| 176 | 177 |
| 178 const RendererCapabilities& SingleThreadProxy::GetRendererCapabilities() const { |
| 179 DCHECK(task_runner_provider_->IsMainThread()); |
| 180 DCHECK(!layer_tree_host_->output_surface_lost()); |
| 181 return renderer_capabilities_for_main_thread_; |
| 182 } |
| 183 |
| 177 void SingleThreadProxy::SetNeedsAnimate() { | 184 void SingleThreadProxy::SetNeedsAnimate() { |
| 178 TRACE_EVENT0("cc", "SingleThreadProxy::SetNeedsAnimate"); | 185 TRACE_EVENT0("cc", "SingleThreadProxy::SetNeedsAnimate"); |
| 179 DCHECK(task_runner_provider_->IsMainThread()); | 186 DCHECK(task_runner_provider_->IsMainThread()); |
| 180 client_->RequestScheduleAnimation(); | 187 client_->RequestScheduleAnimation(); |
| 181 if (animate_requested_) | 188 if (animate_requested_) |
| 182 return; | 189 return; |
| 183 animate_requested_ = true; | 190 animate_requested_ = true; |
| 184 DebugScopedSetImplThread impl(task_runner_provider_); | 191 DebugScopedSetImplThread impl(task_runner_provider_); |
| 185 if (scheduler_on_impl_thread_) | 192 if (scheduler_on_impl_thread_) |
| 186 scheduler_on_impl_thread_->SetNeedsBeginMainFrame(); | 193 scheduler_on_impl_thread_->SetNeedsBeginMainFrame(); |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 443 void SingleThreadProxy::DidPrepareTiles() { | 450 void SingleThreadProxy::DidPrepareTiles() { |
| 444 DCHECK(task_runner_provider_->IsImplThread()); | 451 DCHECK(task_runner_provider_->IsImplThread()); |
| 445 if (scheduler_on_impl_thread_) | 452 if (scheduler_on_impl_thread_) |
| 446 scheduler_on_impl_thread_->DidPrepareTiles(); | 453 scheduler_on_impl_thread_->DidPrepareTiles(); |
| 447 } | 454 } |
| 448 | 455 |
| 449 void SingleThreadProxy::DidCompletePageScaleAnimationOnImplThread() { | 456 void SingleThreadProxy::DidCompletePageScaleAnimationOnImplThread() { |
| 450 layer_tree_host_->DidCompletePageScaleAnimation(); | 457 layer_tree_host_->DidCompletePageScaleAnimation(); |
| 451 } | 458 } |
| 452 | 459 |
| 460 void SingleThreadProxy::UpdateRendererCapabilitiesOnImplThread() { |
| 461 DCHECK(task_runner_provider_->IsImplThread()); |
| 462 renderer_capabilities_for_main_thread_ = |
| 463 layer_tree_host_impl_->GetRendererCapabilities().MainThreadCapabilities(); |
| 464 } |
| 465 |
| 453 void SingleThreadProxy::DidLoseOutputSurfaceOnImplThread() { | 466 void SingleThreadProxy::DidLoseOutputSurfaceOnImplThread() { |
| 454 TRACE_EVENT0("cc", "SingleThreadProxy::DidLoseOutputSurfaceOnImplThread"); | 467 TRACE_EVENT0("cc", "SingleThreadProxy::DidLoseOutputSurfaceOnImplThread"); |
| 455 { | 468 { |
| 456 DebugScopedSetMainThread main(task_runner_provider_); | 469 DebugScopedSetMainThread main(task_runner_provider_); |
| 457 // This must happen before we notify the scheduler as it may try to recreate | 470 // This must happen before we notify the scheduler as it may try to recreate |
| 458 // the output surface if already in BEGIN_IMPL_FRAME_STATE_IDLE. | 471 // the output surface if already in BEGIN_IMPL_FRAME_STATE_IDLE. |
| 459 layer_tree_host_->DidLoseOutputSurface(); | 472 layer_tree_host_->DidLoseOutputSurface(); |
| 460 } | 473 } |
| 461 client_->DidAbortSwapBuffers(); | 474 client_->DidAbortSwapBuffers(); |
| 462 if (scheduler_on_impl_thread_) | 475 if (scheduler_on_impl_thread_) |
| (...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 863 void SingleThreadProxy::DidFinishImplFrame() { | 876 void SingleThreadProxy::DidFinishImplFrame() { |
| 864 layer_tree_host_impl_->DidFinishImplFrame(); | 877 layer_tree_host_impl_->DidFinishImplFrame(); |
| 865 #if DCHECK_IS_ON() | 878 #if DCHECK_IS_ON() |
| 866 DCHECK(inside_impl_frame_) | 879 DCHECK(inside_impl_frame_) |
| 867 << "DidFinishImplFrame called while not inside an impl frame!"; | 880 << "DidFinishImplFrame called while not inside an impl frame!"; |
| 868 inside_impl_frame_ = false; | 881 inside_impl_frame_ = false; |
| 869 #endif | 882 #endif |
| 870 } | 883 } |
| 871 | 884 |
| 872 } // namespace cc | 885 } // namespace cc |
| OLD | NEW |