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 21 matching lines...) Expand all Loading... |
32 LayerTreeHostSingleThreadClient* client, | 32 LayerTreeHostSingleThreadClient* client, |
33 TaskRunnerProvider* task_runner_provider) { | 33 TaskRunnerProvider* task_runner_provider) { |
34 return base::WrapUnique( | 34 return base::WrapUnique( |
35 new SingleThreadProxy(layer_tree_host, client, task_runner_provider)); | 35 new SingleThreadProxy(layer_tree_host, client, task_runner_provider)); |
36 } | 36 } |
37 | 37 |
38 SingleThreadProxy::SingleThreadProxy(LayerTreeHostInProcess* layer_tree_host, | 38 SingleThreadProxy::SingleThreadProxy(LayerTreeHostInProcess* layer_tree_host, |
39 LayerTreeHostSingleThreadClient* client, | 39 LayerTreeHostSingleThreadClient* client, |
40 TaskRunnerProvider* task_runner_provider) | 40 TaskRunnerProvider* task_runner_provider) |
41 : layer_tree_host_(layer_tree_host), | 41 : layer_tree_host_(layer_tree_host), |
42 client_(client), | 42 single_thread_client_(client), |
43 task_runner_provider_(task_runner_provider), | 43 task_runner_provider_(task_runner_provider), |
44 next_frame_is_newly_committed_frame_(false), | 44 next_frame_is_newly_committed_frame_(false), |
45 #if DCHECK_IS_ON() | 45 #if DCHECK_IS_ON() |
46 inside_impl_frame_(false), | 46 inside_impl_frame_(false), |
47 #endif | 47 #endif |
48 inside_draw_(false), | 48 inside_draw_(false), |
49 defer_commits_(false), | 49 defer_commits_(false), |
50 animate_requested_(false), | 50 animate_requested_(false), |
51 commit_requested_(false), | 51 commit_requested_(false), |
52 inside_synchronous_composite_(false), | 52 inside_synchronous_composite_(false), |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 // DidFailToInitializeCompositorFrameSink is treated as a | 149 // DidFailToInitializeCompositorFrameSink is treated as a |
150 // RequestNewCompositorFrameSink, and so | 150 // RequestNewCompositorFrameSink, and so |
151 // compositor_frame_sink_creation_requested remains true. | 151 // compositor_frame_sink_creation_requested remains true. |
152 layer_tree_host_->DidFailToInitializeCompositorFrameSink(); | 152 layer_tree_host_->DidFailToInitializeCompositorFrameSink(); |
153 } | 153 } |
154 } | 154 } |
155 | 155 |
156 void SingleThreadProxy::SetNeedsAnimate() { | 156 void SingleThreadProxy::SetNeedsAnimate() { |
157 TRACE_EVENT0("cc", "SingleThreadProxy::SetNeedsAnimate"); | 157 TRACE_EVENT0("cc", "SingleThreadProxy::SetNeedsAnimate"); |
158 DCHECK(task_runner_provider_->IsMainThread()); | 158 DCHECK(task_runner_provider_->IsMainThread()); |
159 client_->RequestScheduleAnimation(); | 159 single_thread_client_->RequestScheduleAnimation(); |
160 if (animate_requested_) | 160 if (animate_requested_) |
161 return; | 161 return; |
162 animate_requested_ = true; | 162 animate_requested_ = true; |
163 DebugScopedSetImplThread impl(task_runner_provider_); | 163 DebugScopedSetImplThread impl(task_runner_provider_); |
164 if (scheduler_on_impl_thread_) | 164 if (scheduler_on_impl_thread_) |
165 scheduler_on_impl_thread_->SetNeedsBeginMainFrame(); | 165 scheduler_on_impl_thread_->SetNeedsBeginMainFrame(); |
166 } | 166 } |
167 | 167 |
168 void SingleThreadProxy::SetNeedsUpdateLayers() { | 168 void SingleThreadProxy::SetNeedsUpdateLayers() { |
169 TRACE_EVENT0("cc", "SingleThreadProxy::SetNeedsUpdateLayers"); | 169 TRACE_EVENT0("cc", "SingleThreadProxy::SetNeedsUpdateLayers"); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 DebugScopedSetMainThread main(task_runner_provider_); | 222 DebugScopedSetMainThread main(task_runner_provider_); |
223 commit_blocking_task_runner_.reset(); | 223 commit_blocking_task_runner_.reset(); |
224 layer_tree_host_->CommitComplete(); | 224 layer_tree_host_->CommitComplete(); |
225 layer_tree_host_->DidBeginMainFrame(); | 225 layer_tree_host_->DidBeginMainFrame(); |
226 | 226 |
227 next_frame_is_newly_committed_frame_ = true; | 227 next_frame_is_newly_committed_frame_ = true; |
228 } | 228 } |
229 | 229 |
230 void SingleThreadProxy::SetNeedsCommit() { | 230 void SingleThreadProxy::SetNeedsCommit() { |
231 DCHECK(task_runner_provider_->IsMainThread()); | 231 DCHECK(task_runner_provider_->IsMainThread()); |
232 client_->RequestScheduleComposite(); | 232 single_thread_client_->RequestScheduleComposite(); |
233 if (commit_requested_) | 233 if (commit_requested_) |
234 return; | 234 return; |
235 commit_requested_ = true; | 235 commit_requested_ = true; |
236 DebugScopedSetImplThread impl(task_runner_provider_); | 236 DebugScopedSetImplThread impl(task_runner_provider_); |
237 if (scheduler_on_impl_thread_) | 237 if (scheduler_on_impl_thread_) |
238 scheduler_on_impl_thread_->SetNeedsBeginMainFrame(); | 238 scheduler_on_impl_thread_->SetNeedsBeginMainFrame(); |
239 } | 239 } |
240 | 240 |
241 void SingleThreadProxy::SetNeedsRedraw(const gfx::Rect& damage_rect) { | 241 void SingleThreadProxy::SetNeedsRedraw(const gfx::Rect& damage_rect) { |
242 TRACE_EVENT0("cc", "SingleThreadProxy::SetNeedsRedraw"); | 242 TRACE_EVENT0("cc", "SingleThreadProxy::SetNeedsRedraw"); |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 } | 324 } |
325 | 325 |
326 void SingleThreadProxy::NotifyReadyToDraw() { | 326 void SingleThreadProxy::NotifyReadyToDraw() { |
327 TRACE_EVENT0("cc", "SingleThreadProxy::NotifyReadyToDraw"); | 327 TRACE_EVENT0("cc", "SingleThreadProxy::NotifyReadyToDraw"); |
328 DebugScopedSetImplThread impl(task_runner_provider_); | 328 DebugScopedSetImplThread impl(task_runner_provider_); |
329 if (scheduler_on_impl_thread_) | 329 if (scheduler_on_impl_thread_) |
330 scheduler_on_impl_thread_->NotifyReadyToDraw(); | 330 scheduler_on_impl_thread_->NotifyReadyToDraw(); |
331 } | 331 } |
332 | 332 |
333 void SingleThreadProxy::SetNeedsRedrawOnImplThread() { | 333 void SingleThreadProxy::SetNeedsRedrawOnImplThread() { |
334 client_->RequestScheduleComposite(); | 334 single_thread_client_->RequestScheduleComposite(); |
335 if (scheduler_on_impl_thread_) | 335 if (scheduler_on_impl_thread_) |
336 scheduler_on_impl_thread_->SetNeedsRedraw(); | 336 scheduler_on_impl_thread_->SetNeedsRedraw(); |
337 } | 337 } |
338 | 338 |
339 void SingleThreadProxy::SetNeedsOneBeginImplFrameOnImplThread() { | 339 void SingleThreadProxy::SetNeedsOneBeginImplFrameOnImplThread() { |
340 TRACE_EVENT0("cc", | 340 TRACE_EVENT0("cc", |
341 "SingleThreadProxy::SetNeedsOneBeginImplFrameOnImplThread"); | 341 "SingleThreadProxy::SetNeedsOneBeginImplFrameOnImplThread"); |
342 client_->RequestScheduleComposite(); | 342 single_thread_client_->RequestScheduleComposite(); |
343 if (scheduler_on_impl_thread_) | 343 if (scheduler_on_impl_thread_) |
344 scheduler_on_impl_thread_->SetNeedsOneBeginImplFrame(); | 344 scheduler_on_impl_thread_->SetNeedsOneBeginImplFrame(); |
345 } | 345 } |
346 | 346 |
347 void SingleThreadProxy::SetNeedsPrepareTilesOnImplThread() { | 347 void SingleThreadProxy::SetNeedsPrepareTilesOnImplThread() { |
348 TRACE_EVENT0("cc", "SingleThreadProxy::SetNeedsPrepareTilesOnImplThread"); | 348 TRACE_EVENT0("cc", "SingleThreadProxy::SetNeedsPrepareTilesOnImplThread"); |
349 if (scheduler_on_impl_thread_) | 349 if (scheduler_on_impl_thread_) |
350 scheduler_on_impl_thread_->SetNeedsPrepareTiles(); | 350 scheduler_on_impl_thread_->SetNeedsPrepareTiles(); |
351 } | 351 } |
352 | 352 |
353 void SingleThreadProxy::SetNeedsCommitOnImplThread() { | 353 void SingleThreadProxy::SetNeedsCommitOnImplThread() { |
354 client_->RequestScheduleComposite(); | 354 single_thread_client_->RequestScheduleComposite(); |
355 if (scheduler_on_impl_thread_) | 355 if (scheduler_on_impl_thread_) |
356 scheduler_on_impl_thread_->SetNeedsBeginMainFrame(); | 356 scheduler_on_impl_thread_->SetNeedsBeginMainFrame(); |
357 } | 357 } |
358 | 358 |
359 void SingleThreadProxy::SetVideoNeedsBeginFrames(bool needs_begin_frames) { | 359 void SingleThreadProxy::SetVideoNeedsBeginFrames(bool needs_begin_frames) { |
360 TRACE_EVENT1("cc", "SingleThreadProxy::SetVideoNeedsBeginFrames", | 360 TRACE_EVENT1("cc", "SingleThreadProxy::SetVideoNeedsBeginFrames", |
361 "needs_begin_frames", needs_begin_frames); | 361 "needs_begin_frames", needs_begin_frames); |
362 // In tests the layer tree is destroyed after the scheduler is. | 362 // In tests the layer tree is destroyed after the scheduler is. |
363 if (scheduler_on_impl_thread_) | 363 if (scheduler_on_impl_thread_) |
364 scheduler_on_impl_thread_->SetVideoNeedsBeginFrames(needs_begin_frames); | 364 scheduler_on_impl_thread_->SetVideoNeedsBeginFrames(needs_begin_frames); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
402 | 402 |
403 void SingleThreadProxy::DidLoseCompositorFrameSinkOnImplThread() { | 403 void SingleThreadProxy::DidLoseCompositorFrameSinkOnImplThread() { |
404 TRACE_EVENT0("cc", | 404 TRACE_EVENT0("cc", |
405 "SingleThreadProxy::DidLoseCompositorFrameSinkOnImplThread"); | 405 "SingleThreadProxy::DidLoseCompositorFrameSinkOnImplThread"); |
406 { | 406 { |
407 DebugScopedSetMainThread main(task_runner_provider_); | 407 DebugScopedSetMainThread main(task_runner_provider_); |
408 // This must happen before we notify the scheduler as it may try to recreate | 408 // This must happen before we notify the scheduler as it may try to recreate |
409 // the output surface if already in BEGIN_IMPL_FRAME_STATE_IDLE. | 409 // the output surface if already in BEGIN_IMPL_FRAME_STATE_IDLE. |
410 layer_tree_host_->DidLoseCompositorFrameSink(); | 410 layer_tree_host_->DidLoseCompositorFrameSink(); |
411 } | 411 } |
412 client_->DidAbortSwapBuffers(); | 412 single_thread_client_->DidLoseCompositorFrameSink(); |
413 if (scheduler_on_impl_thread_) | 413 if (scheduler_on_impl_thread_) |
414 scheduler_on_impl_thread_->DidLoseCompositorFrameSink(); | 414 scheduler_on_impl_thread_->DidLoseCompositorFrameSink(); |
415 compositor_frame_sink_lost_ = true; | 415 compositor_frame_sink_lost_ = true; |
416 } | 416 } |
417 | 417 |
418 void SingleThreadProxy::SetBeginFrameSource(BeginFrameSource* source) { | 418 void SingleThreadProxy::SetBeginFrameSource(BeginFrameSource* source) { |
419 if (scheduler_on_impl_thread_) | 419 if (scheduler_on_impl_thread_) |
420 scheduler_on_impl_thread_->SetBeginFrameSource(source); | 420 scheduler_on_impl_thread_->SetBeginFrameSource(source); |
421 } | 421 } |
422 | 422 |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
545 BlockingTaskRunner::CapturePostTasks blocked( | 545 BlockingTaskRunner::CapturePostTasks blocked( |
546 task_runner_provider_->blocking_main_thread_task_runner()); | 546 task_runner_provider_->blocking_main_thread_task_runner()); |
547 | 547 |
548 draw_result = layer_tree_host_impl_->PrepareToDraw(frame); | 548 draw_result = layer_tree_host_impl_->PrepareToDraw(frame); |
549 draw_frame = draw_result == DRAW_SUCCESS; | 549 draw_frame = draw_result == DRAW_SUCCESS; |
550 if (draw_frame) { | 550 if (draw_frame) { |
551 if (layer_tree_host_impl_->DrawLayers(frame)) { | 551 if (layer_tree_host_impl_->DrawLayers(frame)) { |
552 if (scheduler_on_impl_thread_) | 552 if (scheduler_on_impl_thread_) |
553 // Drawing implies we submitted a frame to the CompositorFrameSink. | 553 // Drawing implies we submitted a frame to the CompositorFrameSink. |
554 scheduler_on_impl_thread_->DidSubmitCompositorFrame(); | 554 scheduler_on_impl_thread_->DidSubmitCompositorFrame(); |
555 client_->DidPostSwapBuffers(); | 555 single_thread_client_->DidSubmitCompositorFrame(); |
556 } | 556 } |
557 } | 557 } |
558 layer_tree_host_impl_->DidDrawAllLayers(*frame); | 558 layer_tree_host_impl_->DidDrawAllLayers(*frame); |
559 | 559 |
560 bool start_ready_animations = draw_frame; | 560 bool start_ready_animations = draw_frame; |
561 layer_tree_host_impl_->UpdateAnimationState(start_ready_animations); | 561 layer_tree_host_impl_->UpdateAnimationState(start_ready_animations); |
562 } | 562 } |
563 DidCommitAndDrawFrame(); | 563 DidCommitAndDrawFrame(); |
564 | 564 |
565 return draw_result; | 565 return draw_result; |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
743 void SingleThreadProxy::DidFinishImplFrame() { | 743 void SingleThreadProxy::DidFinishImplFrame() { |
744 layer_tree_host_impl_->DidFinishImplFrame(); | 744 layer_tree_host_impl_->DidFinishImplFrame(); |
745 #if DCHECK_IS_ON() | 745 #if DCHECK_IS_ON() |
746 DCHECK(inside_impl_frame_) | 746 DCHECK(inside_impl_frame_) |
747 << "DidFinishImplFrame called while not inside an impl frame!"; | 747 << "DidFinishImplFrame called while not inside an impl frame!"; |
748 inside_impl_frame_ = false; | 748 inside_impl_frame_ = false; |
749 #endif | 749 #endif |
750 } | 750 } |
751 | 751 |
752 } // namespace cc | 752 } // namespace cc |
OLD | NEW |