| 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 29 matching lines...) Expand all Loading... |
| 40 | 40 |
| 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 TaskRunnerProvider* task_runner_provider, |
| 51 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, | |
| 52 scoped_ptr<BeginFrameSource> external_begin_frame_source) { | 51 scoped_ptr<BeginFrameSource> external_begin_frame_source) { |
| 53 return make_scoped_ptr(new ThreadProxy(layer_tree_host, | 52 return make_scoped_ptr(new ThreadProxy(layer_tree_host, task_runner_provider, |
| 54 main_task_runner, | |
| 55 impl_task_runner, | |
| 56 external_begin_frame_source.Pass())); | 53 external_begin_frame_source.Pass())); |
| 57 } | 54 } |
| 58 | 55 |
| 59 ThreadProxy::ThreadProxy( | 56 ThreadProxy::ThreadProxy( |
| 60 LayerTreeHost* layer_tree_host, | 57 LayerTreeHost* layer_tree_host, |
| 61 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, | 58 TaskRunnerProvider* task_runner_provider, |
| 62 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, | |
| 63 scoped_ptr<BeginFrameSource> external_begin_frame_source) | 59 scoped_ptr<BeginFrameSource> external_begin_frame_source) |
| 64 : Proxy(main_task_runner, impl_task_runner), | 60 : task_runner_provider_(task_runner_provider), |
| 65 main_thread_only_vars_unsafe_(this, layer_tree_host), | 61 main_thread_only_vars_unsafe_(this, layer_tree_host), |
| 66 compositor_thread_vars_unsafe_( | 62 compositor_thread_vars_unsafe_( |
| 67 this, | 63 this, |
| 68 layer_tree_host->id(), | 64 layer_tree_host->id(), |
| 69 layer_tree_host->rendering_stats_instrumentation(), | 65 layer_tree_host->rendering_stats_instrumentation(), |
| 70 external_begin_frame_source.Pass()) { | 66 external_begin_frame_source.Pass()) { |
| 71 TRACE_EVENT0("cc", "ThreadProxy::ThreadProxy"); | 67 TRACE_EVENT0("cc", "ThreadProxy::ThreadProxy"); |
| 72 DCHECK(IsMainThread()); | 68 DCHECK(task_runner_provider_); |
| 69 DCHECK(task_runner_provider_->IsMainThread()); |
| 73 DCHECK(this->main().layer_tree_host); | 70 DCHECK(this->main().layer_tree_host); |
| 74 // TODO(khushalsagar): Move this to LayerTreeHost#InitializeThreaded once | 71 // TODO(khushalsagar): Move this to LayerTreeHost#InitializeThreaded once |
| 75 // ThreadProxy is split. LayerTreeHost creates the channel and passes it to | 72 // ThreadProxy is split. LayerTreeHost creates the channel and passes it to |
| 76 // ProxyMain#SetChannel. | 73 // ProxyMain#SetChannel. |
| 77 SetChannel(ThreadedChannel::Create(this, main_task_runner, impl_task_runner)); | 74 SetChannel(ThreadedChannel::Create(this, task_runner_provider_)); |
| 78 } | 75 } |
| 79 | 76 |
| 80 ThreadProxy::MainThreadOnly::MainThreadOnly(ThreadProxy* proxy, | 77 ThreadProxy::MainThreadOnly::MainThreadOnly(ThreadProxy* proxy, |
| 81 LayerTreeHost* layer_tree_host) | 78 LayerTreeHost* layer_tree_host) |
| 82 : layer_tree_host_id(layer_tree_host->id()), | 79 : layer_tree_host_id(layer_tree_host->id()), |
| 83 layer_tree_host(layer_tree_host), | 80 layer_tree_host(layer_tree_host), |
| 84 max_requested_pipeline_stage(NO_PIPELINE_STAGE), | 81 max_requested_pipeline_stage(NO_PIPELINE_STAGE), |
| 85 current_pipeline_stage(NO_PIPELINE_STAGE), | 82 current_pipeline_stage(NO_PIPELINE_STAGE), |
| 86 final_pipeline_stage(NO_PIPELINE_STAGE), | 83 final_pipeline_stage(NO_PIPELINE_STAGE), |
| 87 commit_waits_for_activation(false), | 84 commit_waits_for_activation(false), |
| (...skipping 14 matching lines...) Expand all Loading... |
| 102 int layer_tree_host_id, | 99 int layer_tree_host_id, |
| 103 RenderingStatsInstrumentation* rendering_stats_instrumentation, | 100 RenderingStatsInstrumentation* rendering_stats_instrumentation, |
| 104 scoped_ptr<BeginFrameSource> external_begin_frame_source) | 101 scoped_ptr<BeginFrameSource> external_begin_frame_source) |
| 105 : layer_tree_host_id(layer_tree_host_id), | 102 : layer_tree_host_id(layer_tree_host_id), |
| 106 next_commit_waits_for_activation(false), | 103 next_commit_waits_for_activation(false), |
| 107 commit_completion_event(nullptr), | 104 commit_completion_event(nullptr), |
| 108 next_frame_is_newly_committed_frame(false), | 105 next_frame_is_newly_committed_frame(false), |
| 109 inside_draw(false), | 106 inside_draw(false), |
| 110 input_throttled_until_commit(false), | 107 input_throttled_until_commit(false), |
| 111 smoothness_priority_expiration_notifier( | 108 smoothness_priority_expiration_notifier( |
| 112 proxy->ImplThreadTaskRunner(), | 109 proxy->task_runner_provider() |
| 110 ->ImplThreadTaskRunner(), |
| 113 base::Bind(&ThreadProxy::RenewTreePriority, base::Unretained(proxy)), | 111 base::Bind(&ThreadProxy::RenewTreePriority, base::Unretained(proxy)), |
| 114 base::TimeDelta::FromMilliseconds( | 112 base::TimeDelta::FromMilliseconds( |
| 115 kSmoothnessTakesPriorityExpirationDelay * 1000)), | 113 kSmoothnessTakesPriorityExpirationDelay * 1000)), |
| 116 external_begin_frame_source(external_begin_frame_source.Pass()), | 114 external_begin_frame_source(external_begin_frame_source.Pass()), |
| 117 rendering_stats_instrumentation(rendering_stats_instrumentation), | 115 rendering_stats_instrumentation(rendering_stats_instrumentation), |
| 118 weak_factory(proxy) {} | 116 weak_factory(proxy) {} |
| 119 | 117 |
| 120 ThreadProxy::CompositorThreadOnly::~CompositorThreadOnly() {} | 118 ThreadProxy::CompositorThreadOnly::~CompositorThreadOnly() {} |
| 121 | 119 |
| 122 ThreadProxy::~ThreadProxy() { | 120 ThreadProxy::~ThreadProxy() { |
| 123 TRACE_EVENT0("cc", "ThreadProxy::~ThreadProxy"); | 121 TRACE_EVENT0("cc", "ThreadProxy::~ThreadProxy"); |
| 124 DCHECK(IsMainThread()); | 122 DCHECK(task_runner_provider_->IsMainThread()); |
| 125 DCHECK(!main().started); | 123 DCHECK(!main().started); |
| 126 } | 124 } |
| 127 | 125 |
| 128 void ThreadProxy::SetChannel(scoped_ptr<ThreadedChannel> threaded_channel) { | 126 void ThreadProxy::SetChannel(scoped_ptr<ThreadedChannel> threaded_channel) { |
| 129 threaded_channel_ = threaded_channel.Pass(); | 127 threaded_channel_ = threaded_channel.Pass(); |
| 130 main().channel_main = threaded_channel_.get(); | 128 main().channel_main = threaded_channel_.get(); |
| 131 } | 129 } |
| 132 | 130 |
| 133 void ThreadProxy::FinishAllRendering() { | 131 void ThreadProxy::FinishAllRendering() { |
| 134 DCHECK(Proxy::IsMainThread()); | 132 DCHECK(task_runner_provider_->IsMainThread()); |
| 135 DCHECK(!main().defer_commits); | 133 DCHECK(!main().defer_commits); |
| 136 | 134 |
| 137 // Make sure all GL drawing is finished on the impl thread. | 135 // Make sure all GL drawing is finished on the impl thread. |
| 138 DebugScopedSetMainThreadBlocked main_thread_blocked(this); | 136 DebugScopedSetMainThreadBlocked main_thread_blocked(task_runner_provider_); |
| 139 CompletionEvent completion; | 137 CompletionEvent completion; |
| 140 main().channel_main->FinishAllRenderingOnImpl(&completion); | 138 main().channel_main->FinishAllRenderingOnImpl(&completion); |
| 141 completion.Wait(); | 139 completion.Wait(); |
| 142 } | 140 } |
| 143 | 141 |
| 144 bool ThreadProxy::IsStarted() const { | 142 bool ThreadProxy::IsStarted() const { |
| 145 DCHECK(Proxy::IsMainThread()); | 143 DCHECK(task_runner_provider_->IsMainThread()); |
| 146 return main().started; | 144 return main().started; |
| 147 } | 145 } |
| 148 | 146 |
| 149 bool ThreadProxy::CommitToActiveTree() const { | 147 bool ThreadProxy::CommitToActiveTree() const { |
| 150 // With ThreadProxy, we use a pending tree and activate it once it's ready to | 148 // With ThreadProxy, we use a pending tree and activate it once it's ready to |
| 151 // draw to allow input to modify the active tree and draw during raster. | 149 // draw to allow input to modify the active tree and draw during raster. |
| 152 return false; | 150 return false; |
| 153 } | 151 } |
| 154 | 152 |
| 155 void ThreadProxy::SetVisible(bool visible) { | 153 void ThreadProxy::SetVisible(bool visible) { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 170 } | 168 } |
| 171 | 169 |
| 172 void ThreadProxy::SetThrottleFrameProductionOnImpl(bool throttle) { | 170 void ThreadProxy::SetThrottleFrameProductionOnImpl(bool throttle) { |
| 173 TRACE_EVENT1("cc", "ThreadProxy::SetThrottleFrameProductionOnImplThread", | 171 TRACE_EVENT1("cc", "ThreadProxy::SetThrottleFrameProductionOnImplThread", |
| 174 "throttle", throttle); | 172 "throttle", throttle); |
| 175 impl().scheduler->SetThrottleFrameProduction(throttle); | 173 impl().scheduler->SetThrottleFrameProduction(throttle); |
| 176 } | 174 } |
| 177 | 175 |
| 178 void ThreadProxy::DidLoseOutputSurface() { | 176 void ThreadProxy::DidLoseOutputSurface() { |
| 179 TRACE_EVENT0("cc", "ThreadProxy::DidLoseOutputSurface"); | 177 TRACE_EVENT0("cc", "ThreadProxy::DidLoseOutputSurface"); |
| 180 DCHECK(IsMainThread()); | 178 DCHECK(task_runner_provider_->IsMainThread()); |
| 181 main().layer_tree_host->DidLoseOutputSurface(); | 179 main().layer_tree_host->DidLoseOutputSurface(); |
| 182 } | 180 } |
| 183 | 181 |
| 184 void ThreadProxy::RequestNewOutputSurface() { | 182 void ThreadProxy::RequestNewOutputSurface() { |
| 185 DCHECK(IsMainThread()); | 183 DCHECK(task_runner_provider_->IsMainThread()); |
| 186 main().layer_tree_host->RequestNewOutputSurface(); | 184 main().layer_tree_host->RequestNewOutputSurface(); |
| 187 } | 185 } |
| 188 | 186 |
| 189 void ThreadProxy::SetOutputSurface(OutputSurface* output_surface) { | 187 void ThreadProxy::SetOutputSurface(OutputSurface* output_surface) { |
| 190 main().channel_main->InitializeOutputSurfaceOnImpl(output_surface); | 188 main().channel_main->InitializeOutputSurfaceOnImpl(output_surface); |
| 191 } | 189 } |
| 192 | 190 |
| 193 void ThreadProxy::ReleaseOutputSurface() { | 191 void ThreadProxy::ReleaseOutputSurface() { |
| 194 DCHECK(IsMainThread()); | 192 DCHECK(task_runner_provider_->IsMainThread()); |
| 195 DCHECK(main().layer_tree_host->output_surface_lost()); | 193 DCHECK(main().layer_tree_host->output_surface_lost()); |
| 196 | 194 |
| 197 DebugScopedSetMainThreadBlocked main_thread_blocked(this); | 195 DebugScopedSetMainThreadBlocked main_thread_blocked(task_runner_provider_); |
| 198 CompletionEvent completion; | 196 CompletionEvent completion; |
| 199 main().channel_main->ReleaseOutputSurfaceOnImpl(&completion); | 197 main().channel_main->ReleaseOutputSurfaceOnImpl(&completion); |
| 200 completion.Wait(); | 198 completion.Wait(); |
| 201 } | 199 } |
| 202 | 200 |
| 203 void ThreadProxy::DidInitializeOutputSurface( | 201 void ThreadProxy::DidInitializeOutputSurface( |
| 204 bool success, | 202 bool success, |
| 205 const RendererCapabilities& capabilities) { | 203 const RendererCapabilities& capabilities) { |
| 206 TRACE_EVENT0("cc", "ThreadProxy::DidInitializeOutputSurface"); | 204 TRACE_EVENT0("cc", "ThreadProxy::DidInitializeOutputSurface"); |
| 207 DCHECK(IsMainThread()); | 205 DCHECK(task_runner_provider_->IsMainThread()); |
| 208 | 206 |
| 209 if (!success) { | 207 if (!success) { |
| 210 main().layer_tree_host->DidFailToInitializeOutputSurface(); | 208 main().layer_tree_host->DidFailToInitializeOutputSurface(); |
| 211 return; | 209 return; |
| 212 } | 210 } |
| 213 main().renderer_capabilities_main_thread_copy = capabilities; | 211 main().renderer_capabilities_main_thread_copy = capabilities; |
| 214 main().layer_tree_host->DidInitializeOutputSurface(); | 212 main().layer_tree_host->DidInitializeOutputSurface(); |
| 215 } | 213 } |
| 216 | 214 |
| 217 void ThreadProxy::SetRendererCapabilitiesMainCopy( | 215 void ThreadProxy::SetRendererCapabilitiesMainCopy( |
| 218 const RendererCapabilities& capabilities) { | 216 const RendererCapabilities& capabilities) { |
| 219 main().renderer_capabilities_main_thread_copy = capabilities; | 217 main().renderer_capabilities_main_thread_copy = capabilities; |
| 220 } | 218 } |
| 221 | 219 |
| 222 bool ThreadProxy::SendCommitRequestToImplThreadIfNeeded( | 220 bool ThreadProxy::SendCommitRequestToImplThreadIfNeeded( |
| 223 CommitPipelineStage required_stage) { | 221 CommitPipelineStage required_stage) { |
| 224 DCHECK(IsMainThread()); | 222 DCHECK(task_runner_provider_->IsMainThread()); |
| 225 DCHECK_NE(NO_PIPELINE_STAGE, required_stage); | 223 DCHECK_NE(NO_PIPELINE_STAGE, required_stage); |
| 226 bool already_posted = | 224 bool already_posted = |
| 227 main().max_requested_pipeline_stage != NO_PIPELINE_STAGE; | 225 main().max_requested_pipeline_stage != NO_PIPELINE_STAGE; |
| 228 main().max_requested_pipeline_stage = | 226 main().max_requested_pipeline_stage = |
| 229 std::max(main().max_requested_pipeline_stage, required_stage); | 227 std::max(main().max_requested_pipeline_stage, required_stage); |
| 230 if (already_posted) | 228 if (already_posted) |
| 231 return false; | 229 return false; |
| 232 main().channel_main->SetNeedsCommitOnImpl(); | 230 main().channel_main->SetNeedsCommitOnImpl(); |
| 233 return true; | 231 return true; |
| 234 } | 232 } |
| 235 | 233 |
| 236 void ThreadProxy::SetNeedsCommitOnImpl() { | 234 void ThreadProxy::SetNeedsCommitOnImpl() { |
| 237 SetNeedsCommitOnImplThread(); | 235 SetNeedsCommitOnImplThread(); |
| 238 } | 236 } |
| 239 | 237 |
| 240 void ThreadProxy::DidCompletePageScaleAnimation() { | 238 void ThreadProxy::DidCompletePageScaleAnimation() { |
| 241 DCHECK(IsMainThread()); | 239 DCHECK(task_runner_provider_->IsMainThread()); |
| 242 main().layer_tree_host->DidCompletePageScaleAnimation(); | 240 main().layer_tree_host->DidCompletePageScaleAnimation(); |
| 243 } | 241 } |
| 244 | 242 |
| 245 const RendererCapabilities& ThreadProxy::GetRendererCapabilities() const { | 243 const RendererCapabilities& ThreadProxy::GetRendererCapabilities() const { |
| 246 DCHECK(IsMainThread()); | 244 DCHECK(task_runner_provider_->IsMainThread()); |
| 247 DCHECK(!main().layer_tree_host->output_surface_lost()); | 245 DCHECK(!main().layer_tree_host->output_surface_lost()); |
| 248 return main().renderer_capabilities_main_thread_copy; | 246 return main().renderer_capabilities_main_thread_copy; |
| 249 } | 247 } |
| 250 | 248 |
| 251 void ThreadProxy::SetNeedsAnimate() { | 249 void ThreadProxy::SetNeedsAnimate() { |
| 252 DCHECK(IsMainThread()); | 250 DCHECK(task_runner_provider_->IsMainThread()); |
| 253 if (SendCommitRequestToImplThreadIfNeeded(ANIMATE_PIPELINE_STAGE)) { | 251 if (SendCommitRequestToImplThreadIfNeeded(ANIMATE_PIPELINE_STAGE)) { |
| 254 TRACE_EVENT_INSTANT0("cc", "ThreadProxy::SetNeedsAnimate", | 252 TRACE_EVENT_INSTANT0("cc", "ThreadProxy::SetNeedsAnimate", |
| 255 TRACE_EVENT_SCOPE_THREAD); | 253 TRACE_EVENT_SCOPE_THREAD); |
| 256 } | 254 } |
| 257 } | 255 } |
| 258 | 256 |
| 259 void ThreadProxy::SetNeedsUpdateLayers() { | 257 void ThreadProxy::SetNeedsUpdateLayers() { |
| 260 DCHECK(IsMainThread()); | 258 DCHECK(task_runner_provider_->IsMainThread()); |
| 261 // If we are currently animating, make sure we also update the layers. | 259 // If we are currently animating, make sure we also update the layers. |
| 262 if (main().current_pipeline_stage == ANIMATE_PIPELINE_STAGE) { | 260 if (main().current_pipeline_stage == ANIMATE_PIPELINE_STAGE) { |
| 263 main().final_pipeline_stage = | 261 main().final_pipeline_stage = |
| 264 std::max(main().final_pipeline_stage, UPDATE_LAYERS_PIPELINE_STAGE); | 262 std::max(main().final_pipeline_stage, UPDATE_LAYERS_PIPELINE_STAGE); |
| 265 return; | 263 return; |
| 266 } | 264 } |
| 267 if (SendCommitRequestToImplThreadIfNeeded(UPDATE_LAYERS_PIPELINE_STAGE)) { | 265 if (SendCommitRequestToImplThreadIfNeeded(UPDATE_LAYERS_PIPELINE_STAGE)) { |
| 268 TRACE_EVENT_INSTANT0("cc", "ThreadProxy::SetNeedsUpdateLayers", | 266 TRACE_EVENT_INSTANT0("cc", "ThreadProxy::SetNeedsUpdateLayers", |
| 269 TRACE_EVENT_SCOPE_THREAD); | 267 TRACE_EVENT_SCOPE_THREAD); |
| 270 } | 268 } |
| 271 } | 269 } |
| 272 | 270 |
| 273 void ThreadProxy::SetNeedsCommit() { | 271 void ThreadProxy::SetNeedsCommit() { |
| 274 DCHECK(IsMainThread()); | 272 DCHECK(task_runner_provider_->IsMainThread()); |
| 275 // If we are currently animating, make sure we don't skip the commit. Note | 273 // If we are currently animating, make sure we don't skip the commit. Note |
| 276 // that requesting a commit during the layer update stage means we need to | 274 // that requesting a commit during the layer update stage means we need to |
| 277 // schedule another full commit. | 275 // schedule another full commit. |
| 278 if (main().current_pipeline_stage == ANIMATE_PIPELINE_STAGE) { | 276 if (main().current_pipeline_stage == ANIMATE_PIPELINE_STAGE) { |
| 279 main().final_pipeline_stage = | 277 main().final_pipeline_stage = |
| 280 std::max(main().final_pipeline_stage, COMMIT_PIPELINE_STAGE); | 278 std::max(main().final_pipeline_stage, COMMIT_PIPELINE_STAGE); |
| 281 return; | 279 return; |
| 282 } | 280 } |
| 283 if (SendCommitRequestToImplThreadIfNeeded(COMMIT_PIPELINE_STAGE)) { | 281 if (SendCommitRequestToImplThreadIfNeeded(COMMIT_PIPELINE_STAGE)) { |
| 284 TRACE_EVENT_INSTANT0("cc", "ThreadProxy::SetNeedsCommit", | 282 TRACE_EVENT_INSTANT0("cc", "ThreadProxy::SetNeedsCommit", |
| 285 TRACE_EVENT_SCOPE_THREAD); | 283 TRACE_EVENT_SCOPE_THREAD); |
| 286 } | 284 } |
| 287 } | 285 } |
| 288 | 286 |
| 289 void ThreadProxy::UpdateRendererCapabilitiesOnImplThread() { | 287 void ThreadProxy::UpdateRendererCapabilitiesOnImplThread() { |
| 290 DCHECK(IsImplThread()); | 288 DCHECK(task_runner_provider_->IsImplThread()); |
| 291 impl().channel_impl->SetRendererCapabilitiesMainCopy( | 289 impl().channel_impl->SetRendererCapabilitiesMainCopy( |
| 292 impl() | 290 impl() |
| 293 .layer_tree_host_impl->GetRendererCapabilities() | 291 .layer_tree_host_impl->GetRendererCapabilities() |
| 294 .MainThreadCapabilities()); | 292 .MainThreadCapabilities()); |
| 295 } | 293 } |
| 296 | 294 |
| 297 void ThreadProxy::DidLoseOutputSurfaceOnImplThread() { | 295 void ThreadProxy::DidLoseOutputSurfaceOnImplThread() { |
| 298 TRACE_EVENT0("cc", "ThreadProxy::DidLoseOutputSurfaceOnImplThread"); | 296 TRACE_EVENT0("cc", "ThreadProxy::DidLoseOutputSurfaceOnImplThread"); |
| 299 DCHECK(IsImplThread()); | 297 DCHECK(task_runner_provider_->IsImplThread()); |
| 300 impl().channel_impl->DidLoseOutputSurface(); | 298 impl().channel_impl->DidLoseOutputSurface(); |
| 301 impl().scheduler->DidLoseOutputSurface(); | 299 impl().scheduler->DidLoseOutputSurface(); |
| 302 } | 300 } |
| 303 | 301 |
| 304 void ThreadProxy::CommitVSyncParameters(base::TimeTicks timebase, | 302 void ThreadProxy::CommitVSyncParameters(base::TimeTicks timebase, |
| 305 base::TimeDelta interval) { | 303 base::TimeDelta interval) { |
| 306 impl().scheduler->CommitVSyncParameters(timebase, interval); | 304 impl().scheduler->CommitVSyncParameters(timebase, interval); |
| 307 } | 305 } |
| 308 | 306 |
| 309 void ThreadProxy::SetEstimatedParentDrawTime(base::TimeDelta draw_time) { | 307 void ThreadProxy::SetEstimatedParentDrawTime(base::TimeDelta draw_time) { |
| 310 impl().scheduler->SetEstimatedParentDrawTime(draw_time); | 308 impl().scheduler->SetEstimatedParentDrawTime(draw_time); |
| 311 } | 309 } |
| 312 | 310 |
| 313 void ThreadProxy::SetMaxSwapsPendingOnImplThread(int max) { | 311 void ThreadProxy::SetMaxSwapsPendingOnImplThread(int max) { |
| 314 impl().scheduler->SetMaxSwapsPending(max); | 312 impl().scheduler->SetMaxSwapsPending(max); |
| 315 } | 313 } |
| 316 | 314 |
| 317 void ThreadProxy::DidSwapBuffersOnImplThread() { | 315 void ThreadProxy::DidSwapBuffersOnImplThread() { |
| 318 impl().scheduler->DidSwapBuffers(); | 316 impl().scheduler->DidSwapBuffers(); |
| 319 } | 317 } |
| 320 | 318 |
| 321 void ThreadProxy::DidSwapBuffersCompleteOnImplThread() { | 319 void ThreadProxy::DidSwapBuffersCompleteOnImplThread() { |
| 322 TRACE_EVENT0("cc,benchmark", | 320 TRACE_EVENT0("cc,benchmark", |
| 323 "ThreadProxy::DidSwapBuffersCompleteOnImplThread"); | 321 "ThreadProxy::DidSwapBuffersCompleteOnImplThread"); |
| 324 DCHECK(IsImplThread()); | 322 DCHECK(task_runner_provider_->IsImplThread()); |
| 325 impl().scheduler->DidSwapBuffersComplete(); | 323 impl().scheduler->DidSwapBuffersComplete(); |
| 326 impl().channel_impl->DidCompleteSwapBuffers(); | 324 impl().channel_impl->DidCompleteSwapBuffers(); |
| 327 } | 325 } |
| 328 | 326 |
| 329 void ThreadProxy::WillBeginImplFrame(const BeginFrameArgs& args) { | 327 void ThreadProxy::WillBeginImplFrame(const BeginFrameArgs& args) { |
| 330 impl().layer_tree_host_impl->WillBeginImplFrame(args); | 328 impl().layer_tree_host_impl->WillBeginImplFrame(args); |
| 331 if (impl().last_processed_begin_main_frame_args.IsValid()) { | 329 if (impl().last_processed_begin_main_frame_args.IsValid()) { |
| 332 // Last processed begin main frame args records the frame args that we sent | 330 // Last processed begin main frame args records the frame args that we sent |
| 333 // to the main thread for the last frame that we've processed. If that is | 331 // to the main thread for the last frame that we've processed. If that is |
| 334 // set, that means the current frame is one past the frame in which we've | 332 // set, that means the current frame is one past the frame in which we've |
| 335 // finished the processing. | 333 // finished the processing. |
| 336 impl().layer_tree_host_impl->RecordMainFrameTiming( | 334 impl().layer_tree_host_impl->RecordMainFrameTiming( |
| 337 impl().last_processed_begin_main_frame_args, | 335 impl().last_processed_begin_main_frame_args, |
| 338 impl().layer_tree_host_impl->CurrentBeginFrameArgs()); | 336 impl().layer_tree_host_impl->CurrentBeginFrameArgs()); |
| 339 impl().last_processed_begin_main_frame_args = BeginFrameArgs(); | 337 impl().last_processed_begin_main_frame_args = BeginFrameArgs(); |
| 340 } | 338 } |
| 341 } | 339 } |
| 342 | 340 |
| 343 void ThreadProxy::OnResourcelessSoftareDrawStateChanged( | 341 void ThreadProxy::OnResourcelessSoftareDrawStateChanged( |
| 344 bool resourceless_draw) { | 342 bool resourceless_draw) { |
| 345 DCHECK(IsImplThread()); | 343 DCHECK(task_runner_provider_->IsImplThread()); |
| 346 impl().scheduler->SetResourcelessSoftareDraw(resourceless_draw); | 344 impl().scheduler->SetResourcelessSoftareDraw(resourceless_draw); |
| 347 } | 345 } |
| 348 | 346 |
| 349 void ThreadProxy::OnCanDrawStateChanged(bool can_draw) { | 347 void ThreadProxy::OnCanDrawStateChanged(bool can_draw) { |
| 350 TRACE_EVENT1( | 348 TRACE_EVENT1( |
| 351 "cc", "ThreadProxy::OnCanDrawStateChanged", "can_draw", can_draw); | 349 "cc", "ThreadProxy::OnCanDrawStateChanged", "can_draw", can_draw); |
| 352 DCHECK(IsImplThread()); | 350 DCHECK(task_runner_provider_->IsImplThread()); |
| 353 impl().scheduler->SetCanDraw(can_draw); | 351 impl().scheduler->SetCanDraw(can_draw); |
| 354 } | 352 } |
| 355 | 353 |
| 356 void ThreadProxy::NotifyReadyToActivate() { | 354 void ThreadProxy::NotifyReadyToActivate() { |
| 357 TRACE_EVENT0("cc", "ThreadProxy::NotifyReadyToActivate"); | 355 TRACE_EVENT0("cc", "ThreadProxy::NotifyReadyToActivate"); |
| 358 impl().scheduler->NotifyReadyToActivate(); | 356 impl().scheduler->NotifyReadyToActivate(); |
| 359 } | 357 } |
| 360 | 358 |
| 361 void ThreadProxy::NotifyReadyToDraw() { | 359 void ThreadProxy::NotifyReadyToDraw() { |
| 362 TRACE_EVENT0("cc", "ThreadProxy::NotifyReadyToDraw"); | 360 TRACE_EVENT0("cc", "ThreadProxy::NotifyReadyToDraw"); |
| 363 impl().scheduler->NotifyReadyToDraw(); | 361 impl().scheduler->NotifyReadyToDraw(); |
| 364 } | 362 } |
| 365 | 363 |
| 366 void ThreadProxy::SetNeedsCommitOnImplThread() { | 364 void ThreadProxy::SetNeedsCommitOnImplThread() { |
| 367 TRACE_EVENT0("cc", "ThreadProxy::SetNeedsCommitOnImplThread"); | 365 TRACE_EVENT0("cc", "ThreadProxy::SetNeedsCommitOnImplThread"); |
| 368 DCHECK(IsImplThread()); | 366 DCHECK(task_runner_provider_->IsImplThread()); |
| 369 impl().scheduler->SetNeedsBeginMainFrame(); | 367 impl().scheduler->SetNeedsBeginMainFrame(); |
| 370 } | 368 } |
| 371 | 369 |
| 372 void ThreadProxy::SetVideoNeedsBeginFrames(bool needs_begin_frames) { | 370 void ThreadProxy::SetVideoNeedsBeginFrames(bool needs_begin_frames) { |
| 373 TRACE_EVENT1("cc", "ThreadProxy::SetVideoNeedsBeginFrames", | 371 TRACE_EVENT1("cc", "ThreadProxy::SetVideoNeedsBeginFrames", |
| 374 "needs_begin_frames", needs_begin_frames); | 372 "needs_begin_frames", needs_begin_frames); |
| 375 DCHECK(IsImplThread()); | 373 DCHECK(task_runner_provider_->IsImplThread()); |
| 376 // In tests the layer tree is destroyed after the scheduler is. | 374 // In tests the layer tree is destroyed after the scheduler is. |
| 377 if (impl().scheduler) | 375 if (impl().scheduler) |
| 378 impl().scheduler->SetVideoNeedsBeginFrames(needs_begin_frames); | 376 impl().scheduler->SetVideoNeedsBeginFrames(needs_begin_frames); |
| 379 } | 377 } |
| 380 | 378 |
| 381 void ThreadProxy::PostAnimationEventsToMainThreadOnImplThread( | 379 void ThreadProxy::PostAnimationEventsToMainThreadOnImplThread( |
| 382 scoped_ptr<AnimationEventsVector> events) { | 380 scoped_ptr<AnimationEventsVector> events) { |
| 383 TRACE_EVENT0("cc", | 381 TRACE_EVENT0("cc", |
| 384 "ThreadProxy::PostAnimationEventsToMainThreadOnImplThread"); | 382 "ThreadProxy::PostAnimationEventsToMainThreadOnImplThread"); |
| 385 DCHECK(IsImplThread()); | 383 DCHECK(task_runner_provider_->IsImplThread()); |
| 386 impl().channel_impl->SetAnimationEvents(events.Pass()); | 384 impl().channel_impl->SetAnimationEvents(events.Pass()); |
| 387 } | 385 } |
| 388 | 386 |
| 389 bool ThreadProxy::IsInsideDraw() { return impl().inside_draw; } | 387 bool ThreadProxy::IsInsideDraw() { return impl().inside_draw; } |
| 390 | 388 |
| 391 void ThreadProxy::SetNeedsRedraw(const gfx::Rect& damage_rect) { | 389 void ThreadProxy::SetNeedsRedraw(const gfx::Rect& damage_rect) { |
| 392 TRACE_EVENT0("cc", "ThreadProxy::SetNeedsRedraw"); | 390 TRACE_EVENT0("cc", "ThreadProxy::SetNeedsRedraw"); |
| 393 DCHECK(IsMainThread()); | 391 DCHECK(task_runner_provider_->IsMainThread()); |
| 394 main().channel_main->SetNeedsRedrawOnImpl(damage_rect); | 392 main().channel_main->SetNeedsRedrawOnImpl(damage_rect); |
| 395 } | 393 } |
| 396 | 394 |
| 397 void ThreadProxy::SetNeedsRedrawOnImpl(const gfx::Rect& damage_rect) { | 395 void ThreadProxy::SetNeedsRedrawOnImpl(const gfx::Rect& damage_rect) { |
| 398 DCHECK(IsImplThread()); | 396 DCHECK(task_runner_provider_->IsImplThread()); |
| 399 SetNeedsRedrawRectOnImplThread(damage_rect); | 397 SetNeedsRedrawRectOnImplThread(damage_rect); |
| 400 } | 398 } |
| 401 | 399 |
| 402 void ThreadProxy::SetNextCommitWaitsForActivation() { | 400 void ThreadProxy::SetNextCommitWaitsForActivation() { |
| 403 DCHECK(IsMainThread()); | 401 DCHECK(task_runner_provider_->IsMainThread()); |
| 404 main().commit_waits_for_activation = true; | 402 main().commit_waits_for_activation = true; |
| 405 } | 403 } |
| 406 | 404 |
| 407 void ThreadProxy::SetDeferCommits(bool defer_commits) { | 405 void ThreadProxy::SetDeferCommits(bool defer_commits) { |
| 408 DCHECK(IsMainThread()); | 406 DCHECK(task_runner_provider_->IsMainThread()); |
| 409 if (main().defer_commits == defer_commits) | 407 if (main().defer_commits == defer_commits) |
| 410 return; | 408 return; |
| 411 | 409 |
| 412 main().defer_commits = defer_commits; | 410 main().defer_commits = defer_commits; |
| 413 if (main().defer_commits) | 411 if (main().defer_commits) |
| 414 TRACE_EVENT_ASYNC_BEGIN0("cc", "ThreadProxy::SetDeferCommits", this); | 412 TRACE_EVENT_ASYNC_BEGIN0("cc", "ThreadProxy::SetDeferCommits", this); |
| 415 else | 413 else |
| 416 TRACE_EVENT_ASYNC_END0("cc", "ThreadProxy::SetDeferCommits", this); | 414 TRACE_EVENT_ASYNC_END0("cc", "ThreadProxy::SetDeferCommits", this); |
| 417 | 415 |
| 418 main().channel_main->SetDeferCommitsOnImpl(defer_commits); | 416 main().channel_main->SetDeferCommitsOnImpl(defer_commits); |
| 419 } | 417 } |
| 420 | 418 |
| 421 void ThreadProxy::SetDeferCommitsOnImpl(bool defer_commits) const { | 419 void ThreadProxy::SetDeferCommitsOnImpl(bool defer_commits) const { |
| 422 DCHECK(IsImplThread()); | 420 DCHECK(task_runner_provider_->IsImplThread()); |
| 423 impl().scheduler->SetDeferCommits(defer_commits); | 421 impl().scheduler->SetDeferCommits(defer_commits); |
| 424 } | 422 } |
| 425 | 423 |
| 426 bool ThreadProxy::CommitRequested() const { | 424 bool ThreadProxy::CommitRequested() const { |
| 427 DCHECK(IsMainThread()); | 425 DCHECK(task_runner_provider_->IsMainThread()); |
| 428 // TODO(skyostil): Split this into something like CommitRequested() and | 426 // TODO(skyostil): Split this into something like CommitRequested() and |
| 429 // CommitInProgress(). | 427 // CommitInProgress(). |
| 430 return main().current_pipeline_stage != NO_PIPELINE_STAGE || | 428 return main().current_pipeline_stage != NO_PIPELINE_STAGE || |
| 431 main().max_requested_pipeline_stage >= COMMIT_PIPELINE_STAGE; | 429 main().max_requested_pipeline_stage >= COMMIT_PIPELINE_STAGE; |
| 432 } | 430 } |
| 433 | 431 |
| 434 bool ThreadProxy::BeginMainFrameRequested() const { | 432 bool ThreadProxy::BeginMainFrameRequested() const { |
| 435 DCHECK(IsMainThread()); | 433 DCHECK(task_runner_provider_->IsMainThread()); |
| 436 return main().max_requested_pipeline_stage != NO_PIPELINE_STAGE; | 434 return main().max_requested_pipeline_stage != NO_PIPELINE_STAGE; |
| 437 } | 435 } |
| 438 | 436 |
| 439 void ThreadProxy::SetNeedsRedrawOnImplThread() { | 437 void ThreadProxy::SetNeedsRedrawOnImplThread() { |
| 440 TRACE_EVENT0("cc", "ThreadProxy::SetNeedsRedrawOnImplThread"); | 438 TRACE_EVENT0("cc", "ThreadProxy::SetNeedsRedrawOnImplThread"); |
| 441 DCHECK(IsImplThread()); | 439 DCHECK(task_runner_provider_->IsImplThread()); |
| 442 impl().scheduler->SetNeedsRedraw(); | 440 impl().scheduler->SetNeedsRedraw(); |
| 443 } | 441 } |
| 444 | 442 |
| 445 void ThreadProxy::SetNeedsAnimateOnImplThread() { | 443 void ThreadProxy::SetNeedsAnimateOnImplThread() { |
| 446 TRACE_EVENT0("cc", "ThreadProxy::SetNeedsAnimateOnImplThread"); | 444 TRACE_EVENT0("cc", "ThreadProxy::SetNeedsAnimateOnImplThread"); |
| 447 DCHECK(IsImplThread()); | 445 DCHECK(task_runner_provider_->IsImplThread()); |
| 448 impl().scheduler->SetNeedsAnimate(); | 446 impl().scheduler->SetNeedsAnimate(); |
| 449 } | 447 } |
| 450 | 448 |
| 451 void ThreadProxy::SetNeedsPrepareTilesOnImplThread() { | 449 void ThreadProxy::SetNeedsPrepareTilesOnImplThread() { |
| 452 DCHECK(IsImplThread()); | 450 DCHECK(task_runner_provider_->IsImplThread()); |
| 453 impl().scheduler->SetNeedsPrepareTiles(); | 451 impl().scheduler->SetNeedsPrepareTiles(); |
| 454 } | 452 } |
| 455 | 453 |
| 456 void ThreadProxy::SetNeedsRedrawRectOnImplThread(const gfx::Rect& damage_rect) { | 454 void ThreadProxy::SetNeedsRedrawRectOnImplThread(const gfx::Rect& damage_rect) { |
| 457 DCHECK(IsImplThread()); | 455 DCHECK(task_runner_provider_->IsImplThread()); |
| 458 impl().layer_tree_host_impl->SetViewportDamage(damage_rect); | 456 impl().layer_tree_host_impl->SetViewportDamage(damage_rect); |
| 459 SetNeedsRedrawOnImplThread(); | 457 SetNeedsRedrawOnImplThread(); |
| 460 } | 458 } |
| 461 | 459 |
| 462 void ThreadProxy::MainThreadHasStoppedFlinging() { | 460 void ThreadProxy::MainThreadHasStoppedFlinging() { |
| 463 DCHECK(IsMainThread()); | 461 DCHECK(task_runner_provider_->IsMainThread()); |
| 464 main().channel_main->MainThreadHasStoppedFlingingOnImpl(); | 462 main().channel_main->MainThreadHasStoppedFlingingOnImpl(); |
| 465 } | 463 } |
| 466 | 464 |
| 467 void ThreadProxy::MainThreadHasStoppedFlingingOnImpl() { | 465 void ThreadProxy::MainThreadHasStoppedFlingingOnImpl() { |
| 468 DCHECK(IsImplThread()); | 466 DCHECK(task_runner_provider_->IsImplThread()); |
| 469 impl().layer_tree_host_impl->MainThreadHasStoppedFlinging(); | 467 impl().layer_tree_host_impl->MainThreadHasStoppedFlinging(); |
| 470 } | 468 } |
| 471 | 469 |
| 472 void ThreadProxy::NotifyInputThrottledUntilCommit() { | 470 void ThreadProxy::NotifyInputThrottledUntilCommit() { |
| 473 DCHECK(IsMainThread()); | 471 DCHECK(task_runner_provider_->IsMainThread()); |
| 474 main().channel_main->SetInputThrottledUntilCommitOnImpl(true); | 472 main().channel_main->SetInputThrottledUntilCommitOnImpl(true); |
| 475 } | 473 } |
| 476 | 474 |
| 477 void ThreadProxy::SetInputThrottledUntilCommitOnImpl(bool is_throttled) { | 475 void ThreadProxy::SetInputThrottledUntilCommitOnImpl(bool is_throttled) { |
| 478 DCHECK(IsImplThread()); | 476 DCHECK(task_runner_provider_->IsImplThread()); |
| 479 if (is_throttled == impl().input_throttled_until_commit) | 477 if (is_throttled == impl().input_throttled_until_commit) |
| 480 return; | 478 return; |
| 481 impl().input_throttled_until_commit = is_throttled; | 479 impl().input_throttled_until_commit = is_throttled; |
| 482 RenewTreePriority(); | 480 RenewTreePriority(); |
| 483 } | 481 } |
| 484 | 482 |
| 485 ThreadProxy::MainThreadOnly& ThreadProxy::main() { | 483 ThreadProxy::MainThreadOnly& ThreadProxy::main() { |
| 486 DCHECK(IsMainThread()); | 484 DCHECK(task_runner_provider_->IsMainThread()); |
| 487 return main_thread_only_vars_unsafe_; | 485 return main_thread_only_vars_unsafe_; |
| 488 } | 486 } |
| 489 const ThreadProxy::MainThreadOnly& ThreadProxy::main() const { | 487 const ThreadProxy::MainThreadOnly& ThreadProxy::main() const { |
| 490 DCHECK(IsMainThread()); | 488 DCHECK(task_runner_provider_->IsMainThread()); |
| 491 return main_thread_only_vars_unsafe_; | 489 return main_thread_only_vars_unsafe_; |
| 492 } | 490 } |
| 493 | 491 |
| 494 ThreadProxy::BlockedMainCommitOnly& ThreadProxy::blocked_main_commit() { | 492 ThreadProxy::BlockedMainCommitOnly& ThreadProxy::blocked_main_commit() { |
| 495 DCHECK(IsMainThreadBlocked()); | |
| 496 DCHECK(impl().commit_completion_event); | 493 DCHECK(impl().commit_completion_event); |
| 494 DCHECK(task_runner_provider_->IsMainThreadBlocked()); |
| 497 return main_thread_blocked_commit_vars_unsafe_; | 495 return main_thread_blocked_commit_vars_unsafe_; |
| 498 } | 496 } |
| 499 | 497 |
| 500 ThreadProxy::CompositorThreadOnly& ThreadProxy::impl() { | 498 ThreadProxy::CompositorThreadOnly& ThreadProxy::impl() { |
| 501 DCHECK(IsImplThread()); | 499 DCHECK(task_runner_provider_->IsImplThread()); |
| 502 return compositor_thread_vars_unsafe_; | 500 return compositor_thread_vars_unsafe_; |
| 503 } | 501 } |
| 504 | 502 |
| 505 const ThreadProxy::CompositorThreadOnly& ThreadProxy::impl() const { | 503 const ThreadProxy::CompositorThreadOnly& ThreadProxy::impl() const { |
| 506 DCHECK(IsImplThread()); | 504 DCHECK(task_runner_provider_->IsImplThread()); |
| 507 return compositor_thread_vars_unsafe_; | 505 return compositor_thread_vars_unsafe_; |
| 508 } | 506 } |
| 509 | 507 |
| 510 void ThreadProxy::Start() { | 508 void ThreadProxy::Start() { |
| 511 DCHECK(IsMainThread()); | 509 DCHECK(task_runner_provider_->IsMainThread()); |
| 512 DCHECK(Proxy::HasImplThread()); | 510 DCHECK(task_runner_provider_->HasImplThread()); |
| 513 | 511 |
| 514 // Create LayerTreeHostImpl. | 512 // Create LayerTreeHostImpl. |
| 515 DebugScopedSetMainThreadBlocked main_thread_blocked(this); | 513 DebugScopedSetMainThreadBlocked main_thread_blocked(task_runner_provider_); |
| 516 CompletionEvent completion; | 514 CompletionEvent completion; |
| 517 main().channel_main->InitializeImplOnImpl(&completion, | 515 main().channel_main->InitializeImplOnImpl(&completion, |
| 518 main().layer_tree_host); | 516 main().layer_tree_host); |
| 519 completion.Wait(); | 517 completion.Wait(); |
| 520 | 518 |
| 521 main_thread_weak_ptr_ = main().weak_factory.GetWeakPtr(); | 519 main_thread_weak_ptr_ = main().weak_factory.GetWeakPtr(); |
| 522 | 520 |
| 523 main().started = true; | 521 main().started = true; |
| 524 } | 522 } |
| 525 | 523 |
| 526 void ThreadProxy::Stop() { | 524 void ThreadProxy::Stop() { |
| 527 TRACE_EVENT0("cc", "ThreadProxy::Stop"); | 525 TRACE_EVENT0("cc", "ThreadProxy::Stop"); |
| 528 DCHECK(IsMainThread()); | 526 DCHECK(task_runner_provider_->IsMainThread()); |
| 529 DCHECK(main().started); | 527 DCHECK(main().started); |
| 530 | 528 |
| 531 // Synchronously finishes pending GL operations and deletes the impl. | 529 // Synchronously finishes pending GL operations and deletes the impl. |
| 532 // The two steps are done as separate post tasks, so that tasks posted | 530 // The two steps are done as separate post tasks, so that tasks posted |
| 533 // by the GL implementation due to the Finish can be executed by the | 531 // by the GL implementation due to the Finish can be executed by the |
| 534 // renderer before shutting it down. | 532 // renderer before shutting it down. |
| 535 { | 533 { |
| 536 DebugScopedSetMainThreadBlocked main_thread_blocked(this); | 534 DebugScopedSetMainThreadBlocked main_thread_blocked(task_runner_provider_); |
| 537 CompletionEvent completion; | 535 CompletionEvent completion; |
| 538 main().channel_main->FinishGLOnImpl(&completion); | 536 main().channel_main->FinishGLOnImpl(&completion); |
| 539 completion.Wait(); | 537 completion.Wait(); |
| 540 } | 538 } |
| 541 { | 539 { |
| 542 DebugScopedSetMainThreadBlocked main_thread_blocked(this); | 540 DebugScopedSetMainThreadBlocked main_thread_blocked(task_runner_provider_); |
| 543 | 541 |
| 544 CompletionEvent completion; | 542 CompletionEvent completion; |
| 545 main().channel_main->LayerTreeHostClosedOnImpl(&completion); | 543 main().channel_main->LayerTreeHostClosedOnImpl(&completion); |
| 546 completion.Wait(); | 544 completion.Wait(); |
| 547 } | 545 } |
| 548 | 546 |
| 549 main().weak_factory.InvalidateWeakPtrs(); | 547 main().weak_factory.InvalidateWeakPtrs(); |
| 550 main().layer_tree_host = nullptr; | 548 main().layer_tree_host = nullptr; |
| 551 main().started = false; | 549 main().started = false; |
| 552 } | 550 } |
| 553 | 551 |
| 554 bool ThreadProxy::SupportsImplScrolling() const { | 552 bool ThreadProxy::SupportsImplScrolling() const { |
| 555 return true; | 553 return true; |
| 556 } | 554 } |
| 557 | 555 |
| 558 void ThreadProxy::FinishAllRenderingOnImpl(CompletionEvent* completion) { | 556 void ThreadProxy::FinishAllRenderingOnImpl(CompletionEvent* completion) { |
| 559 TRACE_EVENT0("cc", "ThreadProxy::FinishAllRenderingOnImplThread"); | 557 TRACE_EVENT0("cc", "ThreadProxy::FinishAllRenderingOnImplThread"); |
| 560 DCHECK(IsImplThread()); | 558 DCHECK(task_runner_provider_->IsImplThread()); |
| 561 impl().layer_tree_host_impl->FinishAllRendering(); | 559 impl().layer_tree_host_impl->FinishAllRendering(); |
| 562 completion->Signal(); | 560 completion->Signal(); |
| 563 } | 561 } |
| 564 | 562 |
| 565 void ThreadProxy::ScheduledActionSendBeginMainFrame() { | 563 void ThreadProxy::ScheduledActionSendBeginMainFrame() { |
| 566 unsigned int begin_frame_id = nextBeginFrameId++; | 564 unsigned int begin_frame_id = nextBeginFrameId++; |
| 567 benchmark_instrumentation::ScopedBeginFrameTask begin_frame_task( | 565 benchmark_instrumentation::ScopedBeginFrameTask begin_frame_task( |
| 568 benchmark_instrumentation::kSendBeginFrame, begin_frame_id); | 566 benchmark_instrumentation::kSendBeginFrame, begin_frame_id); |
| 569 scoped_ptr<BeginMainFrameAndCommitState> begin_main_frame_state( | 567 scoped_ptr<BeginMainFrameAndCommitState> begin_main_frame_state( |
| 570 new BeginMainFrameAndCommitState); | 568 new BeginMainFrameAndCommitState); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 589 void ThreadProxy::SendBeginMainFrameNotExpectedSoon() { | 587 void ThreadProxy::SendBeginMainFrameNotExpectedSoon() { |
| 590 impl().channel_impl->BeginMainFrameNotExpectedSoon(); | 588 impl().channel_impl->BeginMainFrameNotExpectedSoon(); |
| 591 } | 589 } |
| 592 | 590 |
| 593 void ThreadProxy::BeginMainFrame( | 591 void ThreadProxy::BeginMainFrame( |
| 594 scoped_ptr<BeginMainFrameAndCommitState> begin_main_frame_state) { | 592 scoped_ptr<BeginMainFrameAndCommitState> begin_main_frame_state) { |
| 595 benchmark_instrumentation::ScopedBeginFrameTask begin_frame_task( | 593 benchmark_instrumentation::ScopedBeginFrameTask begin_frame_task( |
| 596 benchmark_instrumentation::kDoBeginFrame, | 594 benchmark_instrumentation::kDoBeginFrame, |
| 597 begin_main_frame_state->begin_frame_id); | 595 begin_main_frame_state->begin_frame_id); |
| 598 TRACE_EVENT_SYNTHETIC_DELAY_BEGIN("cc.BeginMainFrame"); | 596 TRACE_EVENT_SYNTHETIC_DELAY_BEGIN("cc.BeginMainFrame"); |
| 599 DCHECK(IsMainThread()); | 597 DCHECK(task_runner_provider_->IsMainThread()); |
| 600 DCHECK_EQ(NO_PIPELINE_STAGE, main().current_pipeline_stage); | 598 DCHECK_EQ(NO_PIPELINE_STAGE, main().current_pipeline_stage); |
| 601 | 599 |
| 602 if (main().defer_commits) { | 600 if (main().defer_commits) { |
| 603 TRACE_EVENT_INSTANT0("cc", "EarlyOut_DeferCommit", | 601 TRACE_EVENT_INSTANT0("cc", "EarlyOut_DeferCommit", |
| 604 TRACE_EVENT_SCOPE_THREAD); | 602 TRACE_EVENT_SCOPE_THREAD); |
| 605 main().channel_main->BeginMainFrameAbortedOnImpl( | 603 main().channel_main->BeginMainFrameAbortedOnImpl( |
| 606 CommitEarlyOutReason::ABORTED_DEFERRED_COMMIT); | 604 CommitEarlyOutReason::ABORTED_DEFERRED_COMMIT); |
| 607 return; | 605 return; |
| 608 } | 606 } |
| 609 | 607 |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 679 return; | 677 return; |
| 680 } | 678 } |
| 681 | 679 |
| 682 // Notify the impl thread that the main thread is ready to commit. This will | 680 // Notify the impl thread that the main thread is ready to commit. This will |
| 683 // begin the commit process, which is blocking from the main thread's | 681 // begin the commit process, which is blocking from the main thread's |
| 684 // point of view, but asynchronously performed on the impl thread, | 682 // point of view, but asynchronously performed on the impl thread, |
| 685 // coordinated by the Scheduler. | 683 // coordinated by the Scheduler. |
| 686 { | 684 { |
| 687 TRACE_EVENT0("cc", "ThreadProxy::BeginMainFrame::commit"); | 685 TRACE_EVENT0("cc", "ThreadProxy::BeginMainFrame::commit"); |
| 688 | 686 |
| 689 DebugScopedSetMainThreadBlocked main_thread_blocked(this); | 687 DebugScopedSetMainThreadBlocked main_thread_blocked(task_runner_provider_); |
| 690 | 688 |
| 691 // This CapturePostTasks should be destroyed before CommitComplete() is | 689 // This CapturePostTasks should be destroyed before CommitComplete() is |
| 692 // called since that goes out to the embedder, and we want the embedder | 690 // called since that goes out to the embedder, and we want the embedder |
| 693 // to receive its callbacks before that. | 691 // to receive its callbacks before that. |
| 694 BlockingTaskRunner::CapturePostTasks blocked( | 692 BlockingTaskRunner::CapturePostTasks blocked( |
| 695 blocking_main_thread_task_runner()); | 693 task_runner_provider_->blocking_main_thread_task_runner()); |
| 696 | 694 |
| 697 CompletionEvent completion; | 695 CompletionEvent completion; |
| 698 main().channel_main->StartCommitOnImpl(&completion, main().layer_tree_host, | 696 main().channel_main->StartCommitOnImpl(&completion, main().layer_tree_host, |
| 699 main().commit_waits_for_activation); | 697 main().commit_waits_for_activation); |
| 700 completion.Wait(); | 698 completion.Wait(); |
| 701 main().commit_waits_for_activation = false; | 699 main().commit_waits_for_activation = false; |
| 702 } | 700 } |
| 703 | 701 |
| 704 main().current_pipeline_stage = NO_PIPELINE_STAGE; | 702 main().current_pipeline_stage = NO_PIPELINE_STAGE; |
| 705 main().layer_tree_host->CommitComplete(); | 703 main().layer_tree_host->CommitComplete(); |
| 706 main().layer_tree_host->DidBeginMainFrame(); | 704 main().layer_tree_host->DidBeginMainFrame(); |
| 707 } | 705 } |
| 708 | 706 |
| 709 void ThreadProxy::BeginMainFrameNotExpectedSoon() { | 707 void ThreadProxy::BeginMainFrameNotExpectedSoon() { |
| 710 TRACE_EVENT0("cc", "ThreadProxy::BeginMainFrameNotExpectedSoon"); | 708 TRACE_EVENT0("cc", "ThreadProxy::BeginMainFrameNotExpectedSoon"); |
| 711 DCHECK(IsMainThread()); | 709 DCHECK(task_runner_provider_->IsMainThread()); |
| 712 main().layer_tree_host->BeginMainFrameNotExpectedSoon(); | 710 main().layer_tree_host->BeginMainFrameNotExpectedSoon(); |
| 713 } | 711 } |
| 714 | 712 |
| 715 void ThreadProxy::StartCommitOnImpl(CompletionEvent* completion, | 713 void ThreadProxy::StartCommitOnImpl(CompletionEvent* completion, |
| 716 LayerTreeHost* layer_tree_host, | 714 LayerTreeHost* layer_tree_host, |
| 717 bool hold_commit_for_activation) { | 715 bool hold_commit_for_activation) { |
| 718 TRACE_EVENT0("cc", "ThreadProxy::StartCommitOnImplThread"); | 716 TRACE_EVENT0("cc", "ThreadProxy::StartCommitOnImplThread"); |
| 719 DCHECK(!impl().commit_completion_event); | 717 DCHECK(!impl().commit_completion_event); |
| 720 DCHECK(IsImplThread() && IsMainThreadBlocked()); | 718 DCHECK(task_runner_provider_->IsImplThread() && |
| 719 task_runner_provider_->IsMainThreadBlocked()); |
| 721 DCHECK(impl().scheduler); | 720 DCHECK(impl().scheduler); |
| 722 DCHECK(impl().scheduler->CommitPending()); | 721 DCHECK(impl().scheduler->CommitPending()); |
| 723 | 722 |
| 724 if (hold_commit_for_activation) { | 723 if (hold_commit_for_activation) { |
| 725 // This commit may be aborted. Store the value for | 724 // This commit may be aborted. Store the value for |
| 726 // hold_commit_for_activation so that whenever the next commit is started, | 725 // hold_commit_for_activation so that whenever the next commit is started, |
| 727 // the main thread will be unblocked only after pending tree activation. | 726 // the main thread will be unblocked only after pending tree activation. |
| 728 impl().next_commit_waits_for_activation = hold_commit_for_activation; | 727 impl().next_commit_waits_for_activation = hold_commit_for_activation; |
| 729 } | 728 } |
| 730 | 729 |
| 731 if (!impl().layer_tree_host_impl) { | 730 if (!impl().layer_tree_host_impl) { |
| 732 TRACE_EVENT_INSTANT0( | 731 TRACE_EVENT_INSTANT0( |
| 733 "cc", "EarlyOut_NoLayerTree", TRACE_EVENT_SCOPE_THREAD); | 732 "cc", "EarlyOut_NoLayerTree", TRACE_EVENT_SCOPE_THREAD); |
| 734 completion->Signal(); | 733 completion->Signal(); |
| 735 return; | 734 return; |
| 736 } | 735 } |
| 737 | 736 |
| 738 // Ideally, we should inform to impl thread when BeginMainFrame is started. | 737 // Ideally, we should inform to impl thread when BeginMainFrame is started. |
| 739 // But, we can avoid a PostTask in here. | 738 // But, we can avoid a PostTask in here. |
| 740 impl().scheduler->NotifyBeginMainFrameStarted(); | 739 impl().scheduler->NotifyBeginMainFrameStarted(); |
| 741 impl().commit_completion_event = completion; | 740 impl().commit_completion_event = completion; |
| 742 DCHECK(!blocked_main_commit().layer_tree_host); | 741 DCHECK(!blocked_main_commit().layer_tree_host); |
| 743 blocked_main_commit().layer_tree_host = layer_tree_host; | 742 blocked_main_commit().layer_tree_host = layer_tree_host; |
| 744 impl().scheduler->NotifyReadyToCommit(); | 743 impl().scheduler->NotifyReadyToCommit(); |
| 745 } | 744 } |
| 746 | 745 |
| 747 void ThreadProxy::BeginMainFrameAbortedOnImpl(CommitEarlyOutReason reason) { | 746 void ThreadProxy::BeginMainFrameAbortedOnImpl(CommitEarlyOutReason reason) { |
| 748 TRACE_EVENT1("cc", "ThreadProxy::BeginMainFrameAbortedOnImplThread", "reason", | 747 TRACE_EVENT1("cc", "ThreadProxy::BeginMainFrameAbortedOnImplThread", "reason", |
| 749 CommitEarlyOutReasonToString(reason)); | 748 CommitEarlyOutReasonToString(reason)); |
| 750 DCHECK(IsImplThread()); | 749 DCHECK(task_runner_provider_->IsImplThread()); |
| 751 DCHECK(impl().scheduler); | 750 DCHECK(impl().scheduler); |
| 752 DCHECK(impl().scheduler->CommitPending()); | 751 DCHECK(impl().scheduler->CommitPending()); |
| 753 DCHECK(!impl().layer_tree_host_impl->pending_tree()); | 752 DCHECK(!impl().layer_tree_host_impl->pending_tree()); |
| 754 | 753 |
| 755 if (CommitEarlyOutHandledCommit(reason)) { | 754 if (CommitEarlyOutHandledCommit(reason)) { |
| 756 SetInputThrottledUntilCommitOnImpl(false); | 755 SetInputThrottledUntilCommitOnImpl(false); |
| 757 impl().last_processed_begin_main_frame_args = | 756 impl().last_processed_begin_main_frame_args = |
| 758 impl().last_begin_main_frame_args; | 757 impl().last_begin_main_frame_args; |
| 759 } | 758 } |
| 760 impl().layer_tree_host_impl->BeginMainFrameAborted(reason); | 759 impl().layer_tree_host_impl->BeginMainFrameAborted(reason); |
| 761 impl().scheduler->BeginMainFrameAborted(reason); | 760 impl().scheduler->BeginMainFrameAborted(reason); |
| 762 } | 761 } |
| 763 | 762 |
| 764 void ThreadProxy::ScheduledActionAnimate() { | 763 void ThreadProxy::ScheduledActionAnimate() { |
| 765 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionAnimate"); | 764 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionAnimate"); |
| 766 DCHECK(IsImplThread()); | 765 DCHECK(task_runner_provider_->IsImplThread()); |
| 767 | 766 |
| 768 impl().layer_tree_host_impl->Animate(); | 767 impl().layer_tree_host_impl->Animate(); |
| 769 } | 768 } |
| 770 | 769 |
| 771 void ThreadProxy::ScheduledActionCommit() { | 770 void ThreadProxy::ScheduledActionCommit() { |
| 772 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionCommit"); | 771 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionCommit"); |
| 773 DCHECK(IsImplThread()); | 772 DCHECK(task_runner_provider_->IsImplThread()); |
| 774 DCHECK(IsMainThreadBlocked()); | 773 DCHECK(task_runner_provider_->IsMainThreadBlocked()); |
| 775 DCHECK(impl().commit_completion_event); | 774 DCHECK(impl().commit_completion_event); |
| 776 DCHECK(blocked_main_commit().layer_tree_host); | 775 DCHECK(blocked_main_commit().layer_tree_host); |
| 777 | 776 |
| 778 impl().layer_tree_host_impl->BeginCommit(); | 777 impl().layer_tree_host_impl->BeginCommit(); |
| 779 blocked_main_commit().layer_tree_host->FinishCommitOnImplThread( | 778 blocked_main_commit().layer_tree_host->FinishCommitOnImplThread( |
| 780 impl().layer_tree_host_impl.get()); | 779 impl().layer_tree_host_impl.get()); |
| 781 | 780 |
| 782 // Remove the LayerTreeHost reference before the completion event is signaled | 781 // Remove the LayerTreeHost reference before the completion event is signaled |
| 783 // and cleared. This is necessary since blocked_main_commit() allows access | 782 // and cleared. This is necessary since blocked_main_commit() allows access |
| 784 // only while we have the completion event to ensure the main thread is | 783 // only while we have the completion event to ensure the main thread is |
| (...skipping 16 matching lines...) Expand all Loading... |
| 801 // often a good bit of work to update the tree and prepare the new frame. | 800 // often a good bit of work to update the tree and prepare the new frame. |
| 802 impl().layer_tree_host_impl->CommitComplete(); | 801 impl().layer_tree_host_impl->CommitComplete(); |
| 803 | 802 |
| 804 SetInputThrottledUntilCommitOnImpl(false); | 803 SetInputThrottledUntilCommitOnImpl(false); |
| 805 | 804 |
| 806 impl().next_frame_is_newly_committed_frame = true; | 805 impl().next_frame_is_newly_committed_frame = true; |
| 807 } | 806 } |
| 808 | 807 |
| 809 void ThreadProxy::ScheduledActionActivateSyncTree() { | 808 void ThreadProxy::ScheduledActionActivateSyncTree() { |
| 810 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionActivateSyncTree"); | 809 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionActivateSyncTree"); |
| 811 DCHECK(IsImplThread()); | 810 DCHECK(task_runner_provider_->IsImplThread()); |
| 812 impl().layer_tree_host_impl->ActivateSyncTree(); | 811 impl().layer_tree_host_impl->ActivateSyncTree(); |
| 813 } | 812 } |
| 814 | 813 |
| 815 void ThreadProxy::ScheduledActionBeginOutputSurfaceCreation() { | 814 void ThreadProxy::ScheduledActionBeginOutputSurfaceCreation() { |
| 816 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionBeginOutputSurfaceCreation"); | 815 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionBeginOutputSurfaceCreation"); |
| 817 DCHECK(IsImplThread()); | 816 DCHECK(task_runner_provider_->IsImplThread()); |
| 818 impl().channel_impl->RequestNewOutputSurface(); | 817 impl().channel_impl->RequestNewOutputSurface(); |
| 819 } | 818 } |
| 820 | 819 |
| 821 DrawResult ThreadProxy::DrawSwapInternal(bool forced_draw) { | 820 DrawResult ThreadProxy::DrawSwapInternal(bool forced_draw) { |
| 822 TRACE_EVENT_SYNTHETIC_DELAY("cc.DrawAndSwap"); | 821 TRACE_EVENT_SYNTHETIC_DELAY("cc.DrawAndSwap"); |
| 823 DrawResult result; | 822 DrawResult result; |
| 824 | 823 |
| 825 DCHECK(IsImplThread()); | 824 DCHECK(task_runner_provider_->IsImplThread()); |
| 826 DCHECK(impl().layer_tree_host_impl.get()); | 825 DCHECK(impl().layer_tree_host_impl.get()); |
| 827 | 826 |
| 828 base::AutoReset<bool> mark_inside(&impl().inside_draw, true); | 827 base::AutoReset<bool> mark_inside(&impl().inside_draw, true); |
| 829 | 828 |
| 830 if (impl().layer_tree_host_impl->pending_tree()) { | 829 if (impl().layer_tree_host_impl->pending_tree()) { |
| 831 bool update_lcd_text = false; | 830 bool update_lcd_text = false; |
| 832 impl().layer_tree_host_impl->pending_tree()->UpdateDrawProperties( | 831 impl().layer_tree_host_impl->pending_tree()->UpdateDrawProperties( |
| 833 update_lcd_text); | 832 update_lcd_text); |
| 834 } | 833 } |
| 835 | 834 |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 914 void ThreadProxy::SendBeginFramesToChildren(const BeginFrameArgs& args) { | 913 void ThreadProxy::SendBeginFramesToChildren(const BeginFrameArgs& args) { |
| 915 NOTREACHED() << "Only used by SingleThreadProxy"; | 914 NOTREACHED() << "Only used by SingleThreadProxy"; |
| 916 } | 915 } |
| 917 | 916 |
| 918 void ThreadProxy::SetAuthoritativeVSyncInterval( | 917 void ThreadProxy::SetAuthoritativeVSyncInterval( |
| 919 const base::TimeDelta& interval) { | 918 const base::TimeDelta& interval) { |
| 920 NOTREACHED() << "Only used by SingleThreadProxy"; | 919 NOTREACHED() << "Only used by SingleThreadProxy"; |
| 921 } | 920 } |
| 922 | 921 |
| 923 void ThreadProxy::DidCommitAndDrawFrame() { | 922 void ThreadProxy::DidCommitAndDrawFrame() { |
| 924 DCHECK(IsMainThread()); | 923 DCHECK(task_runner_provider_->IsMainThread()); |
| 925 main().layer_tree_host->DidCommitAndDrawFrame(); | 924 main().layer_tree_host->DidCommitAndDrawFrame(); |
| 926 } | 925 } |
| 927 | 926 |
| 928 void ThreadProxy::DidCompleteSwapBuffers() { | 927 void ThreadProxy::DidCompleteSwapBuffers() { |
| 929 DCHECK(IsMainThread()); | 928 DCHECK(task_runner_provider_->IsMainThread()); |
| 930 main().layer_tree_host->DidCompleteSwapBuffers(); | 929 main().layer_tree_host->DidCompleteSwapBuffers(); |
| 931 } | 930 } |
| 932 | 931 |
| 933 void ThreadProxy::SetAnimationEvents(scoped_ptr<AnimationEventsVector> events) { | 932 void ThreadProxy::SetAnimationEvents(scoped_ptr<AnimationEventsVector> events) { |
| 934 TRACE_EVENT0("cc", "ThreadProxy::SetAnimationEvents"); | 933 TRACE_EVENT0("cc", "ThreadProxy::SetAnimationEvents"); |
| 935 DCHECK(IsMainThread()); | 934 DCHECK(task_runner_provider_->IsMainThread()); |
| 936 main().layer_tree_host->SetAnimationEvents(events.Pass()); | 935 main().layer_tree_host->SetAnimationEvents(events.Pass()); |
| 937 } | 936 } |
| 938 | 937 |
| 939 void ThreadProxy::InitializeImplOnImpl(CompletionEvent* completion, | 938 void ThreadProxy::InitializeImplOnImpl(CompletionEvent* completion, |
| 940 LayerTreeHost* layer_tree_host) { | 939 LayerTreeHost* layer_tree_host) { |
| 941 TRACE_EVENT0("cc", "ThreadProxy::InitializeImplOnImplThread"); | 940 TRACE_EVENT0("cc", "ThreadProxy::InitializeImplOnImplThread"); |
| 942 DCHECK(IsImplThread()); | 941 DCHECK(task_runner_provider_->IsImplThread()); |
| 943 DCHECK(IsMainThreadBlocked()); | 942 DCHECK(task_runner_provider_->IsMainThreadBlocked()); |
| 944 DCHECK(layer_tree_host); | 943 DCHECK(layer_tree_host); |
| 945 | 944 |
| 946 // TODO(khushalsagar): ThreadedChannel will create ProxyImpl here and pass a | 945 // TODO(khushalsagar): ThreadedChannel will create ProxyImpl here and pass a |
| 947 // reference to itself. | 946 // reference to itself. |
| 948 impl().channel_impl = threaded_channel_.get(); | 947 impl().channel_impl = threaded_channel_.get(); |
| 949 | 948 |
| 950 impl().layer_tree_host_impl = layer_tree_host->CreateLayerTreeHostImpl(this); | 949 impl().layer_tree_host_impl = layer_tree_host->CreateLayerTreeHostImpl(this); |
| 951 | 950 |
| 952 SchedulerSettings scheduler_settings( | 951 SchedulerSettings scheduler_settings( |
| 953 layer_tree_host->settings().ToSchedulerSettings()); | 952 layer_tree_host->settings().ToSchedulerSettings()); |
| 954 | 953 |
| 955 scoped_ptr<CompositorTimingHistory> compositor_timing_history( | 954 scoped_ptr<CompositorTimingHistory> compositor_timing_history( |
| 956 new CompositorTimingHistory(CompositorTimingHistory::RENDERER_UMA, | 955 new CompositorTimingHistory(CompositorTimingHistory::RENDERER_UMA, |
| 957 impl().rendering_stats_instrumentation)); | 956 impl().rendering_stats_instrumentation)); |
| 958 | 957 |
| 959 impl().scheduler = Scheduler::Create( | 958 impl().scheduler = |
| 960 this, scheduler_settings, impl().layer_tree_host_id, | 959 Scheduler::Create(this, scheduler_settings, impl().layer_tree_host_id, |
| 961 ImplThreadTaskRunner(), impl().external_begin_frame_source.get(), | 960 task_runner_provider_->ImplThreadTaskRunner(), |
| 962 compositor_timing_history.Pass()); | 961 impl().external_begin_frame_source.get(), |
| 962 compositor_timing_history.Pass()); |
| 963 | 963 |
| 964 DCHECK_EQ(impl().scheduler->visible(), | 964 DCHECK_EQ(impl().scheduler->visible(), |
| 965 impl().layer_tree_host_impl->visible()); | 965 impl().layer_tree_host_impl->visible()); |
| 966 impl_thread_weak_ptr_ = impl().weak_factory.GetWeakPtr(); | 966 impl_thread_weak_ptr_ = impl().weak_factory.GetWeakPtr(); |
| 967 completion->Signal(); | 967 completion->Signal(); |
| 968 } | 968 } |
| 969 | 969 |
| 970 void ThreadProxy::InitializeOutputSurfaceOnImpl(OutputSurface* output_surface) { | 970 void ThreadProxy::InitializeOutputSurfaceOnImpl(OutputSurface* output_surface) { |
| 971 TRACE_EVENT0("cc", "ThreadProxy::InitializeOutputSurfaceOnImplThread"); | 971 TRACE_EVENT0("cc", "ThreadProxy::InitializeOutputSurfaceOnImplThread"); |
| 972 DCHECK(IsImplThread()); | 972 DCHECK(task_runner_provider_->IsImplThread()); |
| 973 | 973 |
| 974 LayerTreeHostImpl* host_impl = impl().layer_tree_host_impl.get(); | 974 LayerTreeHostImpl* host_impl = impl().layer_tree_host_impl.get(); |
| 975 bool success = host_impl->InitializeRenderer(output_surface); | 975 bool success = host_impl->InitializeRenderer(output_surface); |
| 976 RendererCapabilities capabilities; | 976 RendererCapabilities capabilities; |
| 977 if (success) { | 977 if (success) { |
| 978 capabilities = | 978 capabilities = |
| 979 host_impl->GetRendererCapabilities().MainThreadCapabilities(); | 979 host_impl->GetRendererCapabilities().MainThreadCapabilities(); |
| 980 } | 980 } |
| 981 | 981 |
| 982 impl().channel_impl->DidInitializeOutputSurface(success, capabilities); | 982 impl().channel_impl->DidInitializeOutputSurface(success, capabilities); |
| 983 | 983 |
| 984 if (success) | 984 if (success) |
| 985 impl().scheduler->DidCreateAndInitializeOutputSurface(); | 985 impl().scheduler->DidCreateAndInitializeOutputSurface(); |
| 986 } | 986 } |
| 987 | 987 |
| 988 void ThreadProxy::ReleaseOutputSurfaceOnImpl(CompletionEvent* completion) { | 988 void ThreadProxy::ReleaseOutputSurfaceOnImpl(CompletionEvent* completion) { |
| 989 DCHECK(IsImplThread()); | 989 DCHECK(task_runner_provider_->IsImplThread()); |
| 990 | 990 |
| 991 // Unlike DidLoseOutputSurfaceOnImplThread, we don't need to call | 991 // Unlike DidLoseOutputSurfaceOnImplThread, we don't need to call |
| 992 // LayerTreeHost::DidLoseOutputSurface since it already knows. | 992 // LayerTreeHost::DidLoseOutputSurface since it already knows. |
| 993 impl().scheduler->DidLoseOutputSurface(); | 993 impl().scheduler->DidLoseOutputSurface(); |
| 994 impl().layer_tree_host_impl->ReleaseOutputSurface(); | 994 impl().layer_tree_host_impl->ReleaseOutputSurface(); |
| 995 completion->Signal(); | 995 completion->Signal(); |
| 996 } | 996 } |
| 997 | 997 |
| 998 void ThreadProxy::FinishGLOnImpl(CompletionEvent* completion) { | 998 void ThreadProxy::FinishGLOnImpl(CompletionEvent* completion) { |
| 999 TRACE_EVENT0("cc", "ThreadProxy::FinishGLOnImplThread"); | 999 TRACE_EVENT0("cc", "ThreadProxy::FinishGLOnImplThread"); |
| 1000 DCHECK(IsImplThread()); | 1000 DCHECK(task_runner_provider_->IsImplThread()); |
| 1001 if (impl().layer_tree_host_impl->output_surface()) { | 1001 if (impl().layer_tree_host_impl->output_surface()) { |
| 1002 ContextProvider* context_provider = | 1002 ContextProvider* context_provider = |
| 1003 impl().layer_tree_host_impl->output_surface()->context_provider(); | 1003 impl().layer_tree_host_impl->output_surface()->context_provider(); |
| 1004 if (context_provider) | 1004 if (context_provider) |
| 1005 context_provider->ContextGL()->Finish(); | 1005 context_provider->ContextGL()->Finish(); |
| 1006 } | 1006 } |
| 1007 completion->Signal(); | 1007 completion->Signal(); |
| 1008 } | 1008 } |
| 1009 | 1009 |
| 1010 void ThreadProxy::LayerTreeHostClosedOnImpl(CompletionEvent* completion) { | 1010 void ThreadProxy::LayerTreeHostClosedOnImpl(CompletionEvent* completion) { |
| 1011 TRACE_EVENT0("cc", "ThreadProxy::LayerTreeHostClosedOnImplThread"); | 1011 TRACE_EVENT0("cc", "ThreadProxy::LayerTreeHostClosedOnImplThread"); |
| 1012 DCHECK(IsImplThread()); | 1012 DCHECK(task_runner_provider_->IsImplThread()); |
| 1013 DCHECK(IsMainThreadBlocked()); | 1013 DCHECK(task_runner_provider_->IsMainThreadBlocked()); |
| 1014 impl().scheduler = nullptr; | 1014 impl().scheduler = nullptr; |
| 1015 impl().external_begin_frame_source = nullptr; | 1015 impl().external_begin_frame_source = nullptr; |
| 1016 impl().layer_tree_host_impl = nullptr; | 1016 impl().layer_tree_host_impl = nullptr; |
| 1017 impl().weak_factory.InvalidateWeakPtrs(); | 1017 impl().weak_factory.InvalidateWeakPtrs(); |
| 1018 // We need to explicitly shutdown the notifier to destroy any weakptrs it is | 1018 // We need to explicitly shutdown the notifier to destroy any weakptrs it is |
| 1019 // holding while still on the compositor thread. This also ensures any | 1019 // holding while still on the compositor thread. This also ensures any |
| 1020 // callbacks holding a ThreadProxy pointer are cancelled. | 1020 // callbacks holding a ThreadProxy pointer are cancelled. |
| 1021 impl().smoothness_priority_expiration_notifier.Shutdown(); | 1021 impl().smoothness_priority_expiration_notifier.Shutdown(); |
| 1022 completion->Signal(); | 1022 completion->Signal(); |
| 1023 } | 1023 } |
| 1024 | 1024 |
| 1025 bool ThreadProxy::MainFrameWillHappenForTesting() { | 1025 bool ThreadProxy::MainFrameWillHappenForTesting() { |
| 1026 DCHECK(IsMainThread()); | 1026 DCHECK(task_runner_provider_->IsMainThread()); |
| 1027 bool main_frame_will_happen = false; | 1027 bool main_frame_will_happen = false; |
| 1028 { | 1028 { |
| 1029 DebugScopedSetMainThreadBlocked main_thread_blocked(this); | 1029 DebugScopedSetMainThreadBlocked main_thread_blocked(task_runner_provider_); |
| 1030 CompletionEvent completion; | 1030 CompletionEvent completion; |
| 1031 main().channel_main->MainFrameWillHappenOnImplForTesting( | 1031 main().channel_main->MainFrameWillHappenOnImplForTesting( |
| 1032 &completion, &main_frame_will_happen); | 1032 &completion, &main_frame_will_happen); |
| 1033 completion.Wait(); | 1033 completion.Wait(); |
| 1034 } | 1034 } |
| 1035 return main_frame_will_happen; | 1035 return main_frame_will_happen; |
| 1036 } | 1036 } |
| 1037 | 1037 |
| 1038 void ThreadProxy::SetChildrenNeedBeginFrames(bool children_need_begin_frames) { | 1038 void ThreadProxy::SetChildrenNeedBeginFrames(bool children_need_begin_frames) { |
| 1039 NOTREACHED() << "Only used by SingleThreadProxy"; | 1039 NOTREACHED() << "Only used by SingleThreadProxy"; |
| 1040 } | 1040 } |
| 1041 | 1041 |
| 1042 void ThreadProxy::MainFrameWillHappenOnImplForTesting( | 1042 void ThreadProxy::MainFrameWillHappenOnImplForTesting( |
| 1043 CompletionEvent* completion, | 1043 CompletionEvent* completion, |
| 1044 bool* main_frame_will_happen) { | 1044 bool* main_frame_will_happen) { |
| 1045 DCHECK(IsImplThread()); | 1045 DCHECK(task_runner_provider_->IsImplThread()); |
| 1046 if (impl().layer_tree_host_impl->output_surface()) { | 1046 if (impl().layer_tree_host_impl->output_surface()) { |
| 1047 *main_frame_will_happen = impl().scheduler->MainFrameForTestingWillHappen(); | 1047 *main_frame_will_happen = impl().scheduler->MainFrameForTestingWillHappen(); |
| 1048 } else { | 1048 } else { |
| 1049 *main_frame_will_happen = false; | 1049 *main_frame_will_happen = false; |
| 1050 } | 1050 } |
| 1051 completion->Signal(); | 1051 completion->Signal(); |
| 1052 } | 1052 } |
| 1053 | 1053 |
| 1054 void ThreadProxy::RenewTreePriority() { | 1054 void ThreadProxy::RenewTreePriority() { |
| 1055 DCHECK(IsImplThread()); | 1055 DCHECK(task_runner_provider_->IsImplThread()); |
| 1056 bool smoothness_takes_priority = | 1056 bool smoothness_takes_priority = |
| 1057 impl().layer_tree_host_impl->pinch_gesture_active() || | 1057 impl().layer_tree_host_impl->pinch_gesture_active() || |
| 1058 impl().layer_tree_host_impl->page_scale_animation_active() || | 1058 impl().layer_tree_host_impl->page_scale_animation_active() || |
| 1059 impl().layer_tree_host_impl->IsActivelyScrolling(); | 1059 impl().layer_tree_host_impl->IsActivelyScrolling(); |
| 1060 | 1060 |
| 1061 // Schedule expiration if smoothness currently takes priority. | 1061 // Schedule expiration if smoothness currently takes priority. |
| 1062 if (smoothness_takes_priority) | 1062 if (smoothness_takes_priority) |
| 1063 impl().smoothness_priority_expiration_notifier.Schedule(); | 1063 impl().smoothness_priority_expiration_notifier.Schedule(); |
| 1064 | 1064 |
| 1065 // We use the same priority for both trees by default. | 1065 // We use the same priority for both trees by default. |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1097 if (impl().layer_tree_host_impl->output_surface()) { | 1097 if (impl().layer_tree_host_impl->output_surface()) { |
| 1098 impl() | 1098 impl() |
| 1099 .layer_tree_host_impl->output_surface() | 1099 .layer_tree_host_impl->output_surface() |
| 1100 ->UpdateSmoothnessTakesPriority(priority == SMOOTHNESS_TAKES_PRIORITY); | 1100 ->UpdateSmoothnessTakesPriority(priority == SMOOTHNESS_TAKES_PRIORITY); |
| 1101 } | 1101 } |
| 1102 } | 1102 } |
| 1103 | 1103 |
| 1104 void ThreadProxy::PostDelayedAnimationTaskOnImplThread( | 1104 void ThreadProxy::PostDelayedAnimationTaskOnImplThread( |
| 1105 const base::Closure& task, | 1105 const base::Closure& task, |
| 1106 base::TimeDelta delay) { | 1106 base::TimeDelta delay) { |
| 1107 Proxy::ImplThreadTaskRunner()->PostDelayedTask(FROM_HERE, task, delay); | 1107 task_runner_provider_->ImplThreadTaskRunner()->PostDelayedTask(FROM_HERE, |
| 1108 task, delay); |
| 1108 } | 1109 } |
| 1109 | 1110 |
| 1110 void ThreadProxy::DidActivateSyncTree() { | 1111 void ThreadProxy::DidActivateSyncTree() { |
| 1111 TRACE_EVENT0("cc", "ThreadProxy::DidActivateSyncTreeOnImplThread"); | 1112 TRACE_EVENT0("cc", "ThreadProxy::DidActivateSyncTreeOnImplThread"); |
| 1112 DCHECK(IsImplThread()); | 1113 DCHECK(task_runner_provider_->IsImplThread()); |
| 1113 | 1114 |
| 1114 if (impl().next_commit_waits_for_activation) { | 1115 if (impl().next_commit_waits_for_activation) { |
| 1115 TRACE_EVENT_INSTANT0( | 1116 TRACE_EVENT_INSTANT0( |
| 1116 "cc", "ReleaseCommitbyActivation", TRACE_EVENT_SCOPE_THREAD); | 1117 "cc", "ReleaseCommitbyActivation", TRACE_EVENT_SCOPE_THREAD); |
| 1117 DCHECK(impl().commit_completion_event); | 1118 DCHECK(impl().commit_completion_event); |
| 1118 impl().commit_completion_event->Signal(); | 1119 impl().commit_completion_event->Signal(); |
| 1119 impl().commit_completion_event = nullptr; | 1120 impl().commit_completion_event = nullptr; |
| 1120 impl().next_commit_waits_for_activation = false; | 1121 impl().next_commit_waits_for_activation = false; |
| 1121 } | 1122 } |
| 1122 | 1123 |
| 1123 impl().last_processed_begin_main_frame_args = | 1124 impl().last_processed_begin_main_frame_args = |
| 1124 impl().last_begin_main_frame_args; | 1125 impl().last_begin_main_frame_args; |
| 1125 } | 1126 } |
| 1126 | 1127 |
| 1127 void ThreadProxy::WillPrepareTiles() { | 1128 void ThreadProxy::WillPrepareTiles() { |
| 1128 DCHECK(IsImplThread()); | 1129 DCHECK(task_runner_provider_->IsImplThread()); |
| 1129 impl().scheduler->WillPrepareTiles(); | 1130 impl().scheduler->WillPrepareTiles(); |
| 1130 } | 1131 } |
| 1131 | 1132 |
| 1132 void ThreadProxy::DidPrepareTiles() { | 1133 void ThreadProxy::DidPrepareTiles() { |
| 1133 DCHECK(IsImplThread()); | 1134 DCHECK(task_runner_provider_->IsImplThread()); |
| 1134 impl().scheduler->DidPrepareTiles(); | 1135 impl().scheduler->DidPrepareTiles(); |
| 1135 } | 1136 } |
| 1136 | 1137 |
| 1137 void ThreadProxy::DidCompletePageScaleAnimationOnImplThread() { | 1138 void ThreadProxy::DidCompletePageScaleAnimationOnImplThread() { |
| 1138 DCHECK(IsImplThread()); | 1139 DCHECK(task_runner_provider_->IsImplThread()); |
| 1139 impl().channel_impl->DidCompletePageScaleAnimation(); | 1140 impl().channel_impl->DidCompletePageScaleAnimation(); |
| 1140 } | 1141 } |
| 1141 | 1142 |
| 1142 void ThreadProxy::OnDrawForOutputSurface() { | 1143 void ThreadProxy::OnDrawForOutputSurface() { |
| 1143 DCHECK(IsImplThread()); | 1144 DCHECK(task_runner_provider_->IsImplThread()); |
| 1144 impl().scheduler->OnDrawForOutputSurface(); | 1145 impl().scheduler->OnDrawForOutputSurface(); |
| 1145 } | 1146 } |
| 1146 | 1147 |
| 1147 void ThreadProxy::UpdateTopControlsState(TopControlsState constraints, | 1148 void ThreadProxy::UpdateTopControlsState(TopControlsState constraints, |
| 1148 TopControlsState current, | 1149 TopControlsState current, |
| 1149 bool animate) { | 1150 bool animate) { |
| 1150 main().channel_main->UpdateTopControlsStateOnImpl(constraints, current, | 1151 main().channel_main->UpdateTopControlsStateOnImpl(constraints, current, |
| 1151 animate); | 1152 animate); |
| 1152 } | 1153 } |
| 1153 | 1154 |
| 1154 void ThreadProxy::UpdateTopControlsStateOnImpl(TopControlsState constraints, | 1155 void ThreadProxy::UpdateTopControlsStateOnImpl(TopControlsState constraints, |
| 1155 TopControlsState current, | 1156 TopControlsState current, |
| 1156 bool animate) { | 1157 bool animate) { |
| 1157 DCHECK(IsImplThread()); | 1158 DCHECK(task_runner_provider_->IsImplThread()); |
| 1158 impl().layer_tree_host_impl->top_controls_manager()->UpdateTopControlsState( | 1159 impl().layer_tree_host_impl->top_controls_manager()->UpdateTopControlsState( |
| 1159 constraints, current, animate); | 1160 constraints, current, animate); |
| 1160 } | 1161 } |
| 1161 | 1162 |
| 1162 void ThreadProxy::PostFrameTimingEventsOnImplThread( | 1163 void ThreadProxy::PostFrameTimingEventsOnImplThread( |
| 1163 scoped_ptr<FrameTimingTracker::CompositeTimingSet> composite_events, | 1164 scoped_ptr<FrameTimingTracker::CompositeTimingSet> composite_events, |
| 1164 scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events) { | 1165 scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events) { |
| 1165 DCHECK(IsImplThread()); | 1166 DCHECK(task_runner_provider_->IsImplThread()); |
| 1166 impl().channel_impl->PostFrameTimingEventsOnMain(composite_events.Pass(), | 1167 impl().channel_impl->PostFrameTimingEventsOnMain(composite_events.Pass(), |
| 1167 main_frame_events.Pass()); | 1168 main_frame_events.Pass()); |
| 1168 } | 1169 } |
| 1169 | 1170 |
| 1170 void ThreadProxy::PostFrameTimingEventsOnMain( | 1171 void ThreadProxy::PostFrameTimingEventsOnMain( |
| 1171 scoped_ptr<FrameTimingTracker::CompositeTimingSet> composite_events, | 1172 scoped_ptr<FrameTimingTracker::CompositeTimingSet> composite_events, |
| 1172 scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events) { | 1173 scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events) { |
| 1173 DCHECK(IsMainThread()); | 1174 DCHECK(task_runner_provider_->IsMainThread()); |
| 1174 main().layer_tree_host->RecordFrameTimingEvents(composite_events.Pass(), | 1175 main().layer_tree_host->RecordFrameTimingEvents(composite_events.Pass(), |
| 1175 main_frame_events.Pass()); | 1176 main_frame_events.Pass()); |
| 1176 } | 1177 } |
| 1177 | 1178 |
| 1178 base::WeakPtr<ProxyMain> ThreadProxy::GetMainWeakPtr() { | 1179 base::WeakPtr<ProxyMain> ThreadProxy::GetMainWeakPtr() { |
| 1179 return main_thread_weak_ptr_; | 1180 return main_thread_weak_ptr_; |
| 1180 } | 1181 } |
| 1181 | 1182 |
| 1182 base::WeakPtr<ProxyImpl> ThreadProxy::GetImplWeakPtr() { | 1183 base::WeakPtr<ProxyImpl> ThreadProxy::GetImplWeakPtr() { |
| 1183 return impl_thread_weak_ptr_; | 1184 return impl_thread_weak_ptr_; |
| 1184 } | 1185 } |
| 1185 | 1186 |
| 1186 } // namespace cc | 1187 } // namespace cc |
| OLD | NEW |