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

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: Drop extra statemachine function 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
« no previous file with comments | « cc/trees/single_thread_proxy.h ('k') | cc/trees/thread_proxy.cc » ('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/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(!ShouldComposite());
265 }
266
262 void SingleThreadProxy::SetNeedsRedrawOnImplThread() { 267 void SingleThreadProxy::SetNeedsRedrawOnImplThread() {
263 layer_tree_host_->ScheduleComposite(); 268 layer_tree_host_->ScheduleComposite();
264 } 269 }
265 270
266 void SingleThreadProxy::DidInitializeVisibleTileOnImplThread() { 271 void SingleThreadProxy::DidInitializeVisibleTileOnImplThread() {
267 // Impl-side painting only. 272 // Impl-side painting only.
268 NOTREACHED(); 273 NOTREACHED();
269 } 274 }
270 275
271 void SingleThreadProxy::SetNeedsCommitOnImplThread() { 276 void SingleThreadProxy::SetNeedsCommitOnImplThread() {
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 layer_tree_host_->UpdateLayers( 382 layer_tree_host_->UpdateLayers(
378 queue.get(), layer_tree_host_impl_->memory_allocation_limit_bytes()); 383 queue.get(), layer_tree_host_impl_->memory_allocation_limit_bytes());
379 384
380 layer_tree_host_->WillCommit(); 385 layer_tree_host_->WillCommit();
381 DoCommit(queue.Pass()); 386 DoCommit(queue.Pass());
382 bool result = DoComposite(offscreen_context_provider, frame_begin_time); 387 bool result = DoComposite(offscreen_context_provider, frame_begin_time);
383 layer_tree_host_->DidBeginFrame(); 388 layer_tree_host_->DidBeginFrame();
384 return result; 389 return result;
385 } 390 }
386 391
392 bool SingleThreadProxy::ShouldComposite() const {
393 DCHECK(Proxy::IsImplThread());
394 return layer_tree_host_impl_->visible() &&
395 layer_tree_host_impl_->CanDraw();
396 }
397
387 bool SingleThreadProxy::DoComposite( 398 bool SingleThreadProxy::DoComposite(
388 scoped_refptr<cc::ContextProvider> offscreen_context_provider, 399 scoped_refptr<cc::ContextProvider> offscreen_context_provider,
389 base::TimeTicks frame_begin_time) { 400 base::TimeTicks frame_begin_time) {
390 DCHECK(!output_surface_lost_); 401 DCHECK(!output_surface_lost_);
391 { 402 {
392 DebugScopedSetImplThread impl(this); 403 DebugScopedSetImplThread impl(this);
393 base::AutoReset<bool> mark_inside(&inside_draw_, true); 404 base::AutoReset<bool> mark_inside(&inside_draw_, true);
394 405
395 layer_tree_host_impl_->resource_provider()-> 406 layer_tree_host_impl_->resource_provider()->
396 set_offscreen_context_provider(offscreen_context_provider); 407 set_offscreen_context_provider(offscreen_context_provider);
397 408
398 if (!layer_tree_host_impl_->visible()) 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 (!ShouldComposite()) {
414 layer_tree_host_impl_->UpdateBackgroundAnimateTicking(true);
399 return false; 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
« no previous file with comments | « cc/trees/single_thread_proxy.h ('k') | cc/trees/thread_proxy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698