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

Unified Diff: cc/trees/thread_proxy.cc

Issue 16871016: cc: Use BeginFrameArgs (Closed) Base URL: http://git.chromium.org/chromium/src.git@bfargs2
Patch Set: Rebase; More tests fixed; Created 7 years, 5 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
« cc/scheduler/scheduler_state_machine.cc ('K') | « cc/trees/thread_proxy.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/trees/thread_proxy.cc
diff --git a/cc/trees/thread_proxy.cc b/cc/trees/thread_proxy.cc
index 5e94ebc8f4ab3291fe3b540a6a3a2ffc0369757b..f18b2b4cbb66f9e6197c4f602cfb28184c3b2b5a 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),
+ frame_did_draw_(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,14 +371,29 @@ void ThreadProxy::SetNeedsBeginFrameOnImplThread(bool enable) {
TRACE_EVENT1("cc", "ThreadProxy::SetNeedsBeginFrameOnImplThread",
"enable", enable);
layer_tree_host_impl_->SetNeedsBeginFrame(enable);
+ layer_tree_host_impl_->UpdateBackgroundAnimateTicking(!enable);
}
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();
+ layer_tree_host_impl_->Animate(monotonic_time, wall_clock_time);
+
+ // Reinitialize for the current frame.
+ frame_did_draw_ = false;
+
scheduler_on_impl_thread_->BeginFrame(args);
}
+void ThreadProxy::DidBeginFrameDeadlineOnImplThread() {
+ layer_tree_host_impl_->UpdateAnimationState(frame_did_draw_);
+ layer_tree_host_impl_->ResetCurrentFrameTimeForNextFrame();
+}
+
void ThreadProxy::OnCanDrawStateChanged(bool can_draw) {
DCHECK(IsImplThread());
TRACE_EVENT1(
@@ -391,7 +407,17 @@ 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(
brianderson 2013/07/09 01:50:48 The meaning of the two arguments to SetHasTrees (h
+ has_pending_tree,
+ layer_tree_host_impl_->active_tree() ?
+ !layer_tree_host_impl_->active_tree()->root_layer() : true);
+
+ if (!has_pending_tree && !deferred_start_commit_on_impl_thread_.is_null()) {
+ Proxy::ImplThreadTaskRunner()->PostTask(
+ FROM_HERE,
+ deferred_start_commit_on_impl_thread_);
+ deferred_start_commit_on_impl_thread_.Reset();
+ }
}
void ThreadProxy::SetNeedsCommitOnImplThread() {
@@ -627,6 +653,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 +662,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 +811,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 +820,24 @@ void ThreadProxy::StartCommitOnImplThread(
if (!layer_tree_host_impl_) {
TRACE_EVENT0("cc", "EarlyOut_NoLayerTree");
completion->Signal();
+
return;
}
+ // We defer forced commits while there is a pending tree here.
brianderson 2013/07/09 01:50:48 I added deferred_start_commit_on_impl_thread_ in o
+ if (layer_tree_host_impl_->pending_tree()) {
+ DCHECK(deferred_start_commit_on_impl_thread_.is_null());
+ deferred_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 +893,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 &&
@@ -871,6 +910,10 @@ void ThreadProxy::ScheduledActionCommit() {
commit_completion_event_on_impl_thread_ = NULL;
}
+ // The commit may have added animations, requiring us to start
+ // background ticking.
+ layer_tree_host_impl_->UpdateBackgroundAnimateTicking(
+ !scheduler_on_impl_thread_->WillDrawIfNeeded());
// SetVisible kicks off the next scheduler action, so this must be last.
scheduler_on_impl_thread_->SetVisible(layer_tree_host_impl_->visible());
}
@@ -912,19 +955,6 @@ ThreadProxy::ScheduledActionDrawAndSwapInternal(bool forced_draw) {
if (!layer_tree_host_impl_->renderer())
return result;
- base::TimeTicks monotonic_time =
- 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();
base::AutoReset<bool> mark_inside(&inside_draw_, true);
@@ -945,7 +975,6 @@ ThreadProxy::ScheduledActionDrawAndSwapInternal(bool forced_draw) {
LayerTreeHostImpl::FrameData frame;
bool draw_frame = false;
- bool start_ready_animations = true;
if (layer_tree_host_impl_->CanDraw() &&
(!drawing_for_readback || can_do_readback)) {
@@ -959,10 +988,10 @@ ThreadProxy::ScheduledActionDrawAndSwapInternal(bool forced_draw) {
if (layer_tree_host_impl_->PrepareToDraw(&frame, readback_rect) ||
forced_draw)
draw_frame = true;
- else
- start_ready_animations = false;
}
+ frame_did_draw_ = draw_frame;
+
if (draw_frame) {
layer_tree_host_impl_->DrawLayers(
&frame,
@@ -971,8 +1000,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 +1117,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 +1127,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();
« cc/scheduler/scheduler_state_machine.cc ('K') | « cc/trees/thread_proxy.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698