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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/trees/single_thread_proxy.h ('k') | cc/trees/thread_proxy.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/trees/single_thread_proxy.cc
diff --git a/cc/trees/single_thread_proxy.cc b/cc/trees/single_thread_proxy.cc
index 84c24e056246016c950c3479e58a3d781204ca01..07056c4c594ff4e0b337e2cb341e2f9e8d75f0f9 100644
--- a/cc/trees/single_thread_proxy.cc
+++ b/cc/trees/single_thread_proxy.cc
@@ -259,6 +259,11 @@ void SingleThreadProxy::Stop() {
layer_tree_host_ = NULL;
}
+void SingleThreadProxy::OnCanDrawStateChanged(bool can_draw) {
+ DCHECK(Proxy::IsImplThread());
+ layer_tree_host_impl_->UpdateBackgroundAnimateTicking(!ShouldComposite());
+}
+
void SingleThreadProxy::SetNeedsRedrawOnImplThread() {
layer_tree_host_->ScheduleComposite();
}
@@ -384,6 +389,12 @@ bool SingleThreadProxy::CommitAndComposite(base::TimeTicks frame_begin_time) {
return result;
}
+bool SingleThreadProxy::ShouldComposite() const {
+ DCHECK(Proxy::IsImplThread());
+ return layer_tree_host_impl_->visible() &&
+ layer_tree_host_impl_->CanDraw();
+}
+
bool SingleThreadProxy::DoComposite(
scoped_refptr<cc::ContextProvider> offscreen_context_provider,
base::TimeTicks frame_begin_time) {
@@ -395,17 +406,17 @@ bool SingleThreadProxy::DoComposite(
layer_tree_host_impl_->resource_provider()->
set_offscreen_context_provider(offscreen_context_provider);
- if (!layer_tree_host_impl_->visible())
+ // We guard PrepareToDraw() with CanDraw() because it always returns a valid
+ // frame, so can only be used when such a frame is possible. Since
+ // DrawLayers() depends on the result of PrepareToDraw(), it is guarded on
+ // CanDraw() as well.
+ if (!ShouldComposite()) {
+ layer_tree_host_impl_->UpdateBackgroundAnimateTicking(true);
return false;
+ }
layer_tree_host_impl_->Animate(base::TimeTicks::Now(), base::Time::Now());
-
- // We guard prepareToDraw() with canDraw() because it always returns a valid
- // frame, so can only be used when such a frame is possible. Since
- // drawLayers() depends on the result of prepareToDraw(), it is guarded on
- // canDraw() as well.
- if (!layer_tree_host_impl_->CanDraw())
- return false;
+ layer_tree_host_impl_->UpdateBackgroundAnimateTicking(false);
LayerTreeHostImpl::FrameData frame;
layer_tree_host_impl_->PrepareToDraw(&frame);
@@ -413,6 +424,9 @@ bool SingleThreadProxy::DoComposite(
layer_tree_host_impl_->DidDrawAllLayers(frame);
output_surface_lost_ = layer_tree_host_impl_->IsContextLost();
+ bool start_ready_animations = true;
+ layer_tree_host_impl_->UpdateAnimationState(start_ready_animations);
+
layer_tree_host_impl_->BeginNextFrame();
}
« 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