Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(671)

Side by Side Diff: cc/trees/single_thread_proxy.cc

Issue 267783004: Refactoring the way begin frame sources inside scheduler work. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Scheduler now uses frame sources, working on scheduler_unittests. Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/debug/trace_event.h" 8 #include "base/debug/trace_event.h"
9 #include "cc/debug/benchmark_instrumentation.h" 9 #include "cc/debug/benchmark_instrumentation.h"
10 #include "cc/output/context_provider.h" 10 #include "cc/output/context_provider.h"
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 void SingleThreadProxy::SetLayerTreeHostClientReady() { 97 void SingleThreadProxy::SetLayerTreeHostClientReady() {
98 TRACE_EVENT0("cc", "SingleThreadProxy::SetLayerTreeHostClientReady"); 98 TRACE_EVENT0("cc", "SingleThreadProxy::SetLayerTreeHostClientReady");
99 // Scheduling is controlled by the embedder in the single thread case, so 99 // Scheduling is controlled by the embedder in the single thread case, so
100 // nothing to do. 100 // nothing to do.
101 } 101 }
102 102
103 void SingleThreadProxy::SetVisible(bool visible) { 103 void SingleThreadProxy::SetVisible(bool visible) {
104 TRACE_EVENT0("cc", "SingleThreadProxy::SetVisible"); 104 TRACE_EVENT0("cc", "SingleThreadProxy::SetVisible");
105 DebugScopedSetImplThread impl(this); 105 DebugScopedSetImplThread impl(this);
106 layer_tree_host_impl_->SetVisible(visible); 106 layer_tree_host_impl_->SetVisible(visible);
107
108 // Changing visibility could change ShouldComposite().
109 UpdateBackgroundAnimateTicking();
110 } 107 }
111 108
112 void SingleThreadProxy::CreateAndInitializeOutputSurface() { 109 void SingleThreadProxy::CreateAndInitializeOutputSurface() {
113 TRACE_EVENT0( 110 TRACE_EVENT0(
114 "cc", "SingleThreadProxy::CreateAndInitializeOutputSurface"); 111 "cc", "SingleThreadProxy::CreateAndInitializeOutputSurface");
115 DCHECK(Proxy::IsMainThread()); 112 DCHECK(Proxy::IsMainThread());
116 113
117 scoped_ptr<OutputSurface> output_surface = 114 scoped_ptr<OutputSurface> output_surface =
118 layer_tree_host_->CreateOutputSurface(); 115 layer_tree_host_->CreateOutputSurface();
119 116
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 layer_tree_host_impl_->resource_provider()); 245 layer_tree_host_impl_->resource_provider());
249 layer_tree_host_impl_.reset(); 246 layer_tree_host_impl_.reset();
250 } 247 }
251 layer_tree_host_ = NULL; 248 layer_tree_host_ = NULL;
252 } 249 }
253 250
254 void SingleThreadProxy::OnCanDrawStateChanged(bool can_draw) { 251 void SingleThreadProxy::OnCanDrawStateChanged(bool can_draw) {
255 TRACE_EVENT1( 252 TRACE_EVENT1(
256 "cc", "SingleThreadProxy::OnCanDrawStateChanged", "can_draw", can_draw); 253 "cc", "SingleThreadProxy::OnCanDrawStateChanged", "can_draw", can_draw);
257 DCHECK(Proxy::IsImplThread()); 254 DCHECK(Proxy::IsImplThread());
258 UpdateBackgroundAnimateTicking();
259 } 255 }
260 256
261 void SingleThreadProxy::NotifyReadyToActivate() { 257 void SingleThreadProxy::NotifyReadyToActivate() {
262 // Thread-only feature. 258 // Thread-only feature.
263 NOTREACHED(); 259 NOTREACHED();
264 } 260 }
265 261
266 void SingleThreadProxy::SetNeedsRedrawOnImplThread() { 262 void SingleThreadProxy::SetNeedsRedrawOnImplThread() {
267 client_->ScheduleComposite(); 263 client_->ScheduleComposite();
268 } 264 }
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 layer_tree_host_->DidBeginMainFrame(); 443 layer_tree_host_->DidBeginMainFrame();
448 return result; 444 return result;
449 } 445 }
450 446
451 bool SingleThreadProxy::ShouldComposite() const { 447 bool SingleThreadProxy::ShouldComposite() const {
452 DCHECK(Proxy::IsImplThread()); 448 DCHECK(Proxy::IsImplThread());
453 return layer_tree_host_impl_->visible() && 449 return layer_tree_host_impl_->visible() &&
454 layer_tree_host_impl_->CanDraw(); 450 layer_tree_host_impl_->CanDraw();
455 } 451 }
456 452
457 void SingleThreadProxy::UpdateBackgroundAnimateTicking() {
brianderson 2014/05/07 18:09:59 Well this is annoying. SingleThreadProxy is going
mithro-old 2014/05/07 22:02:32 Unsure yet. Do you know if there are unit tests wh
brianderson 2014/05/08 00:55:58 The LayerTreeHost/Impl unit tests should test back
mithro-old 2014/05/09 02:45:58 Guess we will find out shortly.
458 DCHECK(Proxy::IsImplThread());
459 layer_tree_host_impl_->UpdateBackgroundAnimateTicking(
460 !ShouldComposite() && layer_tree_host_impl_->active_tree()->root_layer());
461 }
462
463 bool SingleThreadProxy::DoComposite( 453 bool SingleThreadProxy::DoComposite(
464 base::TimeTicks frame_begin_time, 454 base::TimeTicks frame_begin_time,
465 const gfx::Rect& device_viewport_damage_rect, 455 const gfx::Rect& device_viewport_damage_rect,
466 bool for_readback, 456 bool for_readback,
467 LayerTreeHostImpl::FrameData* frame) { 457 LayerTreeHostImpl::FrameData* frame) {
468 TRACE_EVENT0("cc", "SingleThreadProxy::DoComposite"); 458 TRACE_EVENT0("cc", "SingleThreadProxy::DoComposite");
469 DCHECK(!layer_tree_host_->output_surface_lost()); 459 DCHECK(!layer_tree_host_->output_surface_lost());
470 460
471 bool lost_output_surface = false; 461 bool lost_output_surface = false;
472 { 462 {
473 DebugScopedSetImplThread impl(this); 463 DebugScopedSetImplThread impl(this);
474 base::AutoReset<bool> mark_inside(&inside_draw_, true); 464 base::AutoReset<bool> mark_inside(&inside_draw_, true);
475 465
476 bool can_do_readback = layer_tree_host_impl_->renderer()->CanReadPixels(); 466 bool can_do_readback = layer_tree_host_impl_->renderer()->CanReadPixels();
477 467
478 // We guard PrepareToDraw() with CanDraw() because it always returns a valid 468 // We guard PrepareToDraw() with CanDraw() because it always returns a valid
479 // frame, so can only be used when such a frame is possible. Since 469 // frame, so can only be used when such a frame is possible. Since
480 // DrawLayers() depends on the result of PrepareToDraw(), it is guarded on 470 // DrawLayers() depends on the result of PrepareToDraw(), it is guarded on
481 // CanDraw() as well. 471 // CanDraw() as well.
482 if (!ShouldComposite() || (for_readback && !can_do_readback)) { 472 if (!ShouldComposite() || (for_readback && !can_do_readback)) {
483 UpdateBackgroundAnimateTicking();
484 return false; 473 return false;
485 } 474 }
486 475
487 layer_tree_host_impl_->Animate( 476 layer_tree_host_impl_->Animate(
488 layer_tree_host_impl_->CurrentFrameTimeTicks()); 477 layer_tree_host_impl_->CurrentFrameTimeTicks());
489 UpdateBackgroundAnimateTicking();
490 478
491 if (!layer_tree_host_impl_->IsContextLost()) { 479 if (!layer_tree_host_impl_->IsContextLost()) {
492 layer_tree_host_impl_->PrepareToDraw(frame, device_viewport_damage_rect); 480 layer_tree_host_impl_->PrepareToDraw(frame, device_viewport_damage_rect);
493 layer_tree_host_impl_->DrawLayers(frame, frame_begin_time); 481 layer_tree_host_impl_->DrawLayers(frame, frame_begin_time);
494 layer_tree_host_impl_->DidDrawAllLayers(*frame); 482 layer_tree_host_impl_->DidDrawAllLayers(*frame);
495 } 483 }
496 lost_output_surface = layer_tree_host_impl_->IsContextLost(); 484 lost_output_surface = layer_tree_host_impl_->IsContextLost();
497 485
498 bool start_ready_animations = true; 486 bool start_ready_animations = true;
499 layer_tree_host_impl_->UpdateAnimationState(start_ready_animations); 487 layer_tree_host_impl_->UpdateAnimationState(start_ready_animations);
(...skipping 12 matching lines...) Expand all
512 void SingleThreadProxy::DidSwapFrame() { 500 void SingleThreadProxy::DidSwapFrame() {
513 if (next_frame_is_newly_committed_frame_) { 501 if (next_frame_is_newly_committed_frame_) {
514 next_frame_is_newly_committed_frame_ = false; 502 next_frame_is_newly_committed_frame_ = false;
515 layer_tree_host_->DidCommitAndDrawFrame(); 503 layer_tree_host_->DidCommitAndDrawFrame();
516 } 504 }
517 } 505 }
518 506
519 bool SingleThreadProxy::CommitPendingForTesting() { return false; } 507 bool SingleThreadProxy::CommitPendingForTesting() { return false; }
520 508
521 } // namespace cc 509 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698