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

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

Issue 13613003: cc: Make animations tick regardless of drawing. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: parameter Created 7 years, 8 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/base/thread.h" 9 #include "cc/base/thread.h"
10 #include "cc/output/context_provider.h" 10 #include "cc/output/context_provider.h"
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 DebugScopedSetMainThreadBlocked mainThreadBlocked(this); 252 DebugScopedSetMainThreadBlocked mainThreadBlocked(this);
253 DebugScopedSetImplThread impl(this); 253 DebugScopedSetImplThread impl(this);
254 254
255 layer_tree_host_->DeleteContentsTexturesOnImplThread( 255 layer_tree_host_->DeleteContentsTexturesOnImplThread(
256 layer_tree_host_impl_->resource_provider()); 256 layer_tree_host_impl_->resource_provider());
257 layer_tree_host_impl_.reset(); 257 layer_tree_host_impl_.reset();
258 } 258 }
259 layer_tree_host_ = NULL; 259 layer_tree_host_ = NULL;
260 } 260 }
261 261
262 void SingleThreadProxy::OnCanDrawStateChanged(bool can_draw) {
263 DCHECK(Proxy::IsImplThread());
264 layer_tree_host_impl_->UpdateBackgroundAnimateTicking(
265 !layer_tree_host_impl_->visible() || !can_draw);
266 }
267
262 void SingleThreadProxy::SetNeedsRedrawOnImplThread() { 268 void SingleThreadProxy::SetNeedsRedrawOnImplThread() {
263 layer_tree_host_->ScheduleComposite(); 269 layer_tree_host_->ScheduleComposite();
264 } 270 }
265 271
266 void SingleThreadProxy::DidInitializeVisibleTileOnImplThread() { 272 void SingleThreadProxy::DidInitializeVisibleTileOnImplThread() {
267 // Impl-side painting only. 273 // Impl-side painting only.
268 NOTREACHED(); 274 NOTREACHED();
269 } 275 }
270 276
271 void SingleThreadProxy::SetNeedsCommitOnImplThread() { 277 void SingleThreadProxy::SetNeedsCommitOnImplThread() {
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 scoped_refptr<cc::ContextProvider> offscreen_context_provider, 394 scoped_refptr<cc::ContextProvider> offscreen_context_provider,
389 base::TimeTicks frame_begin_time) { 395 base::TimeTicks frame_begin_time) {
390 DCHECK(!output_surface_lost_); 396 DCHECK(!output_surface_lost_);
391 { 397 {
392 DebugScopedSetImplThread impl(this); 398 DebugScopedSetImplThread impl(this);
393 base::AutoReset<bool> mark_inside(&inside_draw_, true); 399 base::AutoReset<bool> mark_inside(&inside_draw_, true);
394 400
395 layer_tree_host_impl_->resource_provider()-> 401 layer_tree_host_impl_->resource_provider()->
396 set_offscreen_context_provider(offscreen_context_provider); 402 set_offscreen_context_provider(offscreen_context_provider);
397 403
398 if (!layer_tree_host_impl_->visible()) 404 if (!layer_tree_host_impl_->visible()) {
405 layer_tree_host_impl_->UpdateBackgroundAnimateTicking(true);
399 return false; 406 return false;
407 }
408
409 // We guard PrepareToDraw() with CanDraw() because it always returns a valid
410 // frame, so can only be used when such a frame is possible. Since
411 // DrawLayers() depends on the result of PrepareToDraw(), it is guarded on
412 // CanDraw() as well.
413 if (!layer_tree_host_impl_->CanDraw()) {
414 layer_tree_host_impl_->UpdateBackgroundAnimateTicking(true);
415 return false;
416 }
400 417
401 layer_tree_host_impl_->Animate(base::TimeTicks::Now(), base::Time::Now()); 418 layer_tree_host_impl_->Animate(base::TimeTicks::Now(), base::Time::Now());
402 419 layer_tree_host_impl_->UpdateBackgroundAnimateTicking(false);
403 // We guard prepareToDraw() with canDraw() because it always returns a valid
404 // frame, so can only be used when such a frame is possible. Since
405 // drawLayers() depends on the result of prepareToDraw(), it is guarded on
406 // canDraw() as well.
407 if (!layer_tree_host_impl_->CanDraw())
408 return false;
409 420
410 LayerTreeHostImpl::FrameData frame; 421 LayerTreeHostImpl::FrameData frame;
411 layer_tree_host_impl_->PrepareToDraw(&frame); 422 layer_tree_host_impl_->PrepareToDraw(&frame);
412 layer_tree_host_impl_->DrawLayers(&frame, frame_begin_time); 423 layer_tree_host_impl_->DrawLayers(&frame, frame_begin_time);
413 layer_tree_host_impl_->DidDrawAllLayers(frame); 424 layer_tree_host_impl_->DidDrawAllLayers(frame);
414 output_surface_lost_ = layer_tree_host_impl_->IsContextLost(); 425 output_surface_lost_ = layer_tree_host_impl_->IsContextLost();
415 426
427 bool start_ready_animations = true;
428 layer_tree_host_impl_->UpdateAnimationState(start_ready_animations);
429
416 layer_tree_host_impl_->BeginNextFrame(); 430 layer_tree_host_impl_->BeginNextFrame();
417 } 431 }
418 432
419 if (output_surface_lost_) { 433 if (output_surface_lost_) {
420 cc::ContextProvider* offscreen_contexts = layer_tree_host_impl_-> 434 cc::ContextProvider* offscreen_contexts = layer_tree_host_impl_->
421 resource_provider()->offscreen_context_provider(); 435 resource_provider()->offscreen_context_provider();
422 if (offscreen_contexts) 436 if (offscreen_contexts)
423 offscreen_contexts->VerifyContexts(); 437 offscreen_contexts->VerifyContexts();
424 layer_tree_host_->DidLoseOutputSurface(); 438 layer_tree_host_->DidLoseOutputSurface();
425 return false; 439 return false;
(...skipping 11 matching lines...) Expand all
437 451
438 bool SingleThreadProxy::CommitPendingForTesting() { return false; } 452 bool SingleThreadProxy::CommitPendingForTesting() { return false; }
439 453
440 skia::RefPtr<SkPicture> SingleThreadProxy::CapturePicture() { 454 skia::RefPtr<SkPicture> SingleThreadProxy::CapturePicture() {
441 // Impl-side painting only. 455 // Impl-side painting only.
442 NOTREACHED(); 456 NOTREACHED();
443 return skia::RefPtr<SkPicture>(); 457 return skia::RefPtr<SkPicture>();
444 } 458 }
445 459
446 } // namespace cc 460 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698