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

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

Issue 23593003: cc: Avoid updating animations in the background without an active tree (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: nits Created 7 years, 3 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
« no previous file with comments | « cc/trees/single_thread_proxy.h ('k') | cc/trees/thread_proxy.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/output/context_provider.h" 9 #include "cc/output/context_provider.h"
10 #include "cc/output/output_surface.h" 10 #include "cc/output/output_surface.h"
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 void SingleThreadProxy::SetLayerTreeHostClientReady() { 93 void SingleThreadProxy::SetLayerTreeHostClientReady() {
94 // Scheduling is controlled by the embedder in the single thread case, so 94 // Scheduling is controlled by the embedder in the single thread case, so
95 // nothing to do. 95 // nothing to do.
96 } 96 }
97 97
98 void SingleThreadProxy::SetVisible(bool visible) { 98 void SingleThreadProxy::SetVisible(bool visible) {
99 DebugScopedSetImplThread impl(this); 99 DebugScopedSetImplThread impl(this);
100 layer_tree_host_impl_->SetVisible(visible); 100 layer_tree_host_impl_->SetVisible(visible);
101 101
102 // Changing visibility could change ShouldComposite(). 102 // Changing visibility could change ShouldComposite().
103 layer_tree_host_impl_->UpdateBackgroundAnimateTicking(!ShouldComposite()); 103 UpdateBackgroundAnimateTicking();
104 } 104 }
105 105
106 void SingleThreadProxy::CreateAndInitializeOutputSurface() { 106 void SingleThreadProxy::CreateAndInitializeOutputSurface() {
107 TRACE_EVENT0( 107 TRACE_EVENT0(
108 "cc", "SingleThreadProxy::CreateAndInitializeOutputSurface"); 108 "cc", "SingleThreadProxy::CreateAndInitializeOutputSurface");
109 DCHECK(Proxy::IsMainThread()); 109 DCHECK(Proxy::IsMainThread());
110 110
111 scoped_ptr<OutputSurface> output_surface = first_output_surface_.Pass(); 111 scoped_ptr<OutputSurface> output_surface = first_output_surface_.Pass();
112 if (!output_surface) 112 if (!output_surface)
113 output_surface = layer_tree_host_->CreateOutputSurface(); 113 output_surface = layer_tree_host_->CreateOutputSurface();
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 258
259 layer_tree_host_->DeleteContentsTexturesOnImplThread( 259 layer_tree_host_->DeleteContentsTexturesOnImplThread(
260 layer_tree_host_impl_->resource_provider()); 260 layer_tree_host_impl_->resource_provider());
261 layer_tree_host_impl_.reset(); 261 layer_tree_host_impl_.reset();
262 } 262 }
263 layer_tree_host_ = NULL; 263 layer_tree_host_ = NULL;
264 } 264 }
265 265
266 void SingleThreadProxy::OnCanDrawStateChanged(bool can_draw) { 266 void SingleThreadProxy::OnCanDrawStateChanged(bool can_draw) {
267 DCHECK(Proxy::IsImplThread()); 267 DCHECK(Proxy::IsImplThread());
268 layer_tree_host_impl_->UpdateBackgroundAnimateTicking(!ShouldComposite()); 268 UpdateBackgroundAnimateTicking();
269 } 269 }
270 270
271 void SingleThreadProxy::NotifyReadyToActivate() { 271 void SingleThreadProxy::NotifyReadyToActivate() {
272 // Thread-only feature. 272 // Thread-only feature.
273 NOTREACHED(); 273 NOTREACHED();
274 } 274 }
275 275
276 void SingleThreadProxy::SetNeedsRedrawOnImplThread() { 276 void SingleThreadProxy::SetNeedsRedrawOnImplThread() {
277 layer_tree_host_->ScheduleComposite(); 277 layer_tree_host_->ScheduleComposite();
278 } 278 }
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 layer_tree_host_->DidBeginFrame(); 420 layer_tree_host_->DidBeginFrame();
421 return result; 421 return result;
422 } 422 }
423 423
424 bool SingleThreadProxy::ShouldComposite() const { 424 bool SingleThreadProxy::ShouldComposite() const {
425 DCHECK(Proxy::IsImplThread()); 425 DCHECK(Proxy::IsImplThread());
426 return layer_tree_host_impl_->visible() && 426 return layer_tree_host_impl_->visible() &&
427 layer_tree_host_impl_->CanDraw(); 427 layer_tree_host_impl_->CanDraw();
428 } 428 }
429 429
430 void SingleThreadProxy::UpdateBackgroundAnimateTicking() {
431 DCHECK(Proxy::IsImplThread());
432 layer_tree_host_impl_->UpdateBackgroundAnimateTicking(
433 !ShouldComposite() && layer_tree_host_impl_->active_tree()->root_layer());
434 }
435
430 bool SingleThreadProxy::DoComposite( 436 bool SingleThreadProxy::DoComposite(
431 scoped_refptr<cc::ContextProvider> offscreen_context_provider, 437 scoped_refptr<cc::ContextProvider> offscreen_context_provider,
432 base::TimeTicks frame_begin_time, 438 base::TimeTicks frame_begin_time,
433 gfx::Rect device_viewport_damage_rect, 439 gfx::Rect device_viewport_damage_rect,
434 bool for_readback, 440 bool for_readback,
435 LayerTreeHostImpl::FrameData* frame) { 441 LayerTreeHostImpl::FrameData* frame) {
436 DCHECK(!layer_tree_host_->output_surface_lost()); 442 DCHECK(!layer_tree_host_->output_surface_lost());
437 443
438 bool lost_output_surface = false; 444 bool lost_output_surface = false;
439 { 445 {
440 DebugScopedSetImplThread impl(this); 446 DebugScopedSetImplThread impl(this);
441 base::AutoReset<bool> mark_inside(&inside_draw_, true); 447 base::AutoReset<bool> mark_inside(&inside_draw_, true);
442 448
443 layer_tree_host_impl_->SetOffscreenContextProvider( 449 layer_tree_host_impl_->SetOffscreenContextProvider(
444 offscreen_context_provider); 450 offscreen_context_provider);
445 451
446 bool can_do_readback = layer_tree_host_impl_->renderer()->CanReadPixels(); 452 bool can_do_readback = layer_tree_host_impl_->renderer()->CanReadPixels();
447 453
448 // We guard PrepareToDraw() with CanDraw() because it always returns a valid 454 // We guard PrepareToDraw() with CanDraw() because it always returns a valid
449 // frame, so can only be used when such a frame is possible. Since 455 // frame, so can only be used when such a frame is possible. Since
450 // DrawLayers() depends on the result of PrepareToDraw(), it is guarded on 456 // DrawLayers() depends on the result of PrepareToDraw(), it is guarded on
451 // CanDraw() as well. 457 // CanDraw() as well.
452 if (!ShouldComposite() || (for_readback && !can_do_readback)) { 458 if (!ShouldComposite() || (for_readback && !can_do_readback)) {
453 layer_tree_host_impl_->UpdateBackgroundAnimateTicking(true); 459 UpdateBackgroundAnimateTicking();
454 return false; 460 return false;
455 } 461 }
456 462
457 layer_tree_host_impl_->Animate( 463 layer_tree_host_impl_->Animate(
458 layer_tree_host_impl_->CurrentFrameTimeTicks(), 464 layer_tree_host_impl_->CurrentFrameTimeTicks(),
459 layer_tree_host_impl_->CurrentFrameTime()); 465 layer_tree_host_impl_->CurrentFrameTime());
460 layer_tree_host_impl_->UpdateBackgroundAnimateTicking(false); 466 UpdateBackgroundAnimateTicking();
461 467
462 layer_tree_host_impl_->PrepareToDraw(frame, device_viewport_damage_rect); 468 layer_tree_host_impl_->PrepareToDraw(frame, device_viewport_damage_rect);
463 layer_tree_host_impl_->DrawLayers(frame, frame_begin_time); 469 layer_tree_host_impl_->DrawLayers(frame, frame_begin_time);
464 layer_tree_host_impl_->DidDrawAllLayers(*frame); 470 layer_tree_host_impl_->DidDrawAllLayers(*frame);
465 lost_output_surface = layer_tree_host_impl_->IsContextLost(); 471 lost_output_surface = layer_tree_host_impl_->IsContextLost();
466 472
467 bool start_ready_animations = true; 473 bool start_ready_animations = true;
468 layer_tree_host_impl_->UpdateAnimationState(start_ready_animations); 474 layer_tree_host_impl_->UpdateAnimationState(start_ready_animations);
469 475
470 layer_tree_host_impl_->ResetCurrentFrameTimeForNextFrame(); 476 layer_tree_host_impl_->ResetCurrentFrameTimeForNextFrame();
(...skipping 14 matching lines...) Expand all
485 void SingleThreadProxy::DidSwapFrame() { 491 void SingleThreadProxy::DidSwapFrame() {
486 if (next_frame_is_newly_committed_frame_) { 492 if (next_frame_is_newly_committed_frame_) {
487 next_frame_is_newly_committed_frame_ = false; 493 next_frame_is_newly_committed_frame_ = false;
488 layer_tree_host_->DidCommitAndDrawFrame(); 494 layer_tree_host_->DidCommitAndDrawFrame();
489 } 495 }
490 } 496 }
491 497
492 bool SingleThreadProxy::CommitPendingForTesting() { return false; } 498 bool SingleThreadProxy::CommitPendingForTesting() { return false; }
493 499
494 } // namespace cc 500 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/single_thread_proxy.h ('k') | cc/trees/thread_proxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698