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