Index: cc/trees/thread_proxy.cc |
diff --git a/cc/trees/thread_proxy.cc b/cc/trees/thread_proxy.cc |
index 521d4cc199f1802e64d4c25f7beb392b1c2a7040..7d11314351c9a135448cb937ebc40a2895537d58 100644 |
--- a/cc/trees/thread_proxy.cc |
+++ b/cc/trees/thread_proxy.cc |
@@ -76,6 +76,7 @@ ThreadProxy::ThreadProxy( |
manage_tiles_pending_(false), |
weak_factory_on_impl_thread_(this), |
weak_factory_(this), |
+ previous_frame_had_checkerboard_(false), |
begin_frame_sent_to_main_thread_completion_event_on_impl_thread_(NULL), |
readback_request_on_impl_thread_(NULL), |
commit_completion_event_on_impl_thread_(NULL), |
@@ -370,28 +371,54 @@ void ThreadProxy::SetNeedsBeginFrameOnImplThread(bool enable) { |
TRACE_EVENT1("cc", "ThreadProxy::SetNeedsBeginFrameOnImplThread", |
"enable", enable); |
layer_tree_host_impl_->SetNeedsBeginFrame(enable); |
+ layer_tree_host_impl_->UpdateBackgroundAnimateTicking(!enable); |
+ if (!enable) |
+ previous_frame_had_checkerboard_ = false; |
} |
void ThreadProxy::BeginFrameOnImplThread(const BeginFrameArgs& args) { |
DCHECK(IsImplThread()); |
TRACE_EVENT0("cc", "ThreadProxy::BeginFrameOnImplThread"); |
+ |
+ base::TimeTicks monotonic_time = |
+ layer_tree_host_impl_->CurrentFrameTimeTicks(); |
+ base::Time wall_clock_time = layer_tree_host_impl_->CurrentFrameTime(); |
+ if (!previous_frame_had_checkerboard_) |
+ layer_tree_host_impl_->Animate(monotonic_time, wall_clock_time); |
+ |
scheduler_on_impl_thread_->BeginFrame(args); |
} |
+void ThreadProxy::DidFinishBeginFrameOnImplThread() { |
+ layer_tree_host_impl_->ResetCurrentFrameTimeForNextFrame(); |
+ layer_tree_host_impl_->UpdateAnimationState( |
+ !previous_frame_had_checkerboard_); |
+} |
+ |
void ThreadProxy::OnCanDrawStateChanged(bool can_draw) { |
DCHECK(IsImplThread()); |
TRACE_EVENT1( |
"cc", "ThreadProxy::OnCanDrawStateChanged", "can_draw", can_draw); |
scheduler_on_impl_thread_->SetCanDraw(can_draw); |
- layer_tree_host_impl_->UpdateBackgroundAnimateTicking( |
- !scheduler_on_impl_thread_->WillDrawIfNeeded()); |
+// layer_tree_host_impl_->UpdateBackgroundAnimateTicking( |
+// !scheduler_on_impl_thread_->WillDrawIfNeeded()); |
} |
void ThreadProxy::OnHasPendingTreeStateChanged(bool has_pending_tree) { |
DCHECK(IsImplThread()); |
TRACE_EVENT1("cc", "ThreadProxy::OnHasPendingTreeStateChanged", |
"has_pending_tree", has_pending_tree); |
- scheduler_on_impl_thread_->SetHasPendingTree(has_pending_tree); |
+ scheduler_on_impl_thread_->SetHasTrees( |
+ has_pending_tree, |
+ layer_tree_host_impl_->active_tree() ? |
+ !layer_tree_host_impl_->active_tree()->root_layer() : true); |
+ |
+ if (!has_pending_tree && !deffered_start_commit_on_impl_thread_.is_null()) { |
+ Proxy::ImplThreadTaskRunner()->PostTask( |
+ FROM_HERE, |
+ deffered_start_commit_on_impl_thread_); |
+ deffered_start_commit_on_impl_thread_.Reset(); |
+ } |
} |
void ThreadProxy::SetNeedsCommitOnImplThread() { |
@@ -627,6 +654,7 @@ void ThreadProxy::ScheduledActionSendBeginFrameToMainThread() { |
TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionSendBeginFrameToMainThread"); |
scoped_ptr<BeginFrameAndCommitState> begin_frame_state( |
new BeginFrameAndCommitState); |
+ |
begin_frame_state->monotonic_frame_begin_time = |
layer_tree_host_impl_->CurrentPhysicalTimeTicks(); |
begin_frame_state->scroll_info = |
@@ -635,6 +663,8 @@ void ThreadProxy::ScheduledActionSendBeginFrameToMainThread() { |
if (!layer_tree_host_impl_->settings().impl_side_painting) { |
DCHECK_GT(layer_tree_host_impl_->memory_allocation_limit_bytes(), 0u); |
} |
+ |
+ |
begin_frame_state->memory_allocation_limit_bytes = |
layer_tree_host_impl_->memory_allocation_limit_bytes(); |
Proxy::MainThreadTaskRunner()->PostTask( |
@@ -782,8 +812,6 @@ void ThreadProxy::StartCommitOnImplThread( |
CompletionEvent* completion, |
ResourceUpdateQueue* raw_queue, |
scoped_refptr<cc::ContextProvider> offscreen_context_provider) { |
- scoped_ptr<ResourceUpdateQueue> queue(raw_queue); |
- |
TRACE_EVENT0("cc", "ThreadProxy::StartCommitOnImplThread"); |
DCHECK(!commit_completion_event_on_impl_thread_); |
DCHECK(IsImplThread() && IsMainThreadBlocked()); |
@@ -793,9 +821,27 @@ void ThreadProxy::StartCommitOnImplThread( |
if (!layer_tree_host_impl_) { |
TRACE_EVENT0("cc", "EarlyOut_NoLayerTree"); |
completion->Signal(); |
+ |
return; |
} |
+ // TODO(brianderson): We really shouldn't need this hack. |
+ // It's here to fix LayerTreeHostAnimationTestCompositeAndReadbackAnimateCount |
+ // It would be an easy way to initiate commits on the main thread before |
+ // the pending tree is free though =) |
+ if (layer_tree_host_impl_->pending_tree()) { |
+ DCHECK(deffered_start_commit_on_impl_thread_.is_null()); |
+ deffered_start_commit_on_impl_thread_ = |
+ base::Bind(&ThreadProxy::StartCommitOnImplThread, |
+ impl_thread_weak_ptr_, |
+ completion, |
+ raw_queue, |
+ offscreen_context_provider); |
+ return; |
+ } |
+ |
+ scoped_ptr<ResourceUpdateQueue> queue(raw_queue); |
+ |
if (offscreen_context_provider.get()) |
offscreen_context_provider->BindToCurrentThread(); |
layer_tree_host_impl_->resource_provider()-> |
@@ -851,9 +897,6 @@ void ThreadProxy::ScheduledActionCommit() { |
layer_tree_host_->FinishCommitOnImplThread(layer_tree_host_impl_.get()); |
layer_tree_host_impl_->CommitComplete(); |
- layer_tree_host_impl_->UpdateBackgroundAnimateTicking( |
- !scheduler_on_impl_thread_->WillDrawIfNeeded()); |
- |
next_frame_is_newly_committed_frame_on_impl_thread_ = true; |
if (layer_tree_host_->settings().impl_side_painting && |
@@ -912,18 +955,20 @@ ThreadProxy::ScheduledActionDrawAndSwapInternal(bool forced_draw) { |
if (!layer_tree_host_impl_->renderer()) |
return result; |
+/* |
base::TimeTicks monotonic_time = |
- layer_tree_host_impl_->CurrentFrameTimeTicks(); |
+ layer_tree_host_impl_->CurrentFrameTimeTicks(); |
base::Time wall_clock_time = layer_tree_host_impl_->CurrentFrameTime(); |
- // TODO(enne): This should probably happen post-animate. |
if (layer_tree_host_impl_->pending_tree()) { |
layer_tree_host_impl_->ActivatePendingTreeIfNeeded(); |
if (layer_tree_host_impl_->pending_tree()) |
layer_tree_host_impl_->pending_tree()->UpdateDrawProperties(); |
} |
+ |
layer_tree_host_impl_->Animate(monotonic_time, wall_clock_time); |
layer_tree_host_impl_->UpdateBackgroundAnimateTicking(false); |
+*/ |
base::TimeTicks start_time = base::TimeTicks::HighResNow(); |
base::TimeDelta draw_duration_estimate = DrawDurationEstimate(); |
@@ -945,7 +990,7 @@ ThreadProxy::ScheduledActionDrawAndSwapInternal(bool forced_draw) { |
LayerTreeHostImpl::FrameData frame; |
bool draw_frame = false; |
- bool start_ready_animations = true; |
+// bool start_ready_animations = true; |
if (layer_tree_host_impl_->CanDraw() && |
(!drawing_for_readback || can_do_readback)) { |
@@ -959,10 +1004,12 @@ ThreadProxy::ScheduledActionDrawAndSwapInternal(bool forced_draw) { |
if (layer_tree_host_impl_->PrepareToDraw(&frame, readback_rect) || |
forced_draw) |
draw_frame = true; |
- else |
- start_ready_animations = false; |
+// else |
+// start_ready_animations = false; |
} |
+ previous_frame_had_checkerboard_ = !draw_frame; |
+ |
if (draw_frame) { |
layer_tree_host_impl_->DrawLayers( |
&frame, |
@@ -971,8 +1018,6 @@ ThreadProxy::ScheduledActionDrawAndSwapInternal(bool forced_draw) { |
} |
layer_tree_host_impl_->DidDrawAllLayers(frame); |
- layer_tree_host_impl_->UpdateAnimationState(start_ready_animations); |
- |
// Check for a pending CompositeAndReadback. |
if (readback_request_on_impl_thread_) { |
readback_request_on_impl_thread_->success = false; |
@@ -1090,7 +1135,6 @@ void ThreadProxy::DidAnticipatedDrawTimeChange(base::TimeTicks time) { |
if (current_resource_update_controller_on_impl_thread_) |
current_resource_update_controller_on_impl_thread_ |
->PerformMoreUpdates(time); |
- layer_tree_host_impl_->ResetCurrentFrameTimeForNextFrame(); |
} |
base::TimeDelta ThreadProxy::DrawDurationEstimate() { |
@@ -1101,6 +1145,14 @@ base::TimeDelta ThreadProxy::DrawDurationEstimate() { |
return historical_estimate + padding; |
} |
+void ThreadProxy::PostBeginFrameDeadline(const base::Closure &closure, |
+ base::TimeTicks deadline) { |
+ base::TimeDelta delta = deadline - base::TimeTicks::Now(); |
+ if (delta <= base::TimeDelta()) |
+ delta = base::TimeDelta(); |
+ Proxy::ImplThreadTaskRunner()->PostDelayedTask(FROM_HERE, closure, delta); |
+} |
+ |
void ThreadProxy::ReadyToFinalizeTextureUpdates() { |
DCHECK(IsImplThread()); |
scheduler_on_impl_thread_->FinishCommit(); |