Index: cc/trees/thread_proxy.cc |
diff --git a/cc/trees/thread_proxy.cc b/cc/trees/thread_proxy.cc |
index f61e7feb73e826b4b2ae6067c29a6ffd0b6a41fa..c58137268e53150b5220bc4306847c85a9d46a12 100644 |
--- a/cc/trees/thread_proxy.cc |
+++ b/cc/trees/thread_proxy.cc |
@@ -28,6 +28,10 @@ const double kContextRecreationTickRate = 0.03; |
// Measured in seconds. |
const double kSmoothnessTakesPriorityExpirationDelay = 0.25; |
+const size_t kDrawDurationHistorySize = 60; |
ajuma
2013/06/06 18:00:35
We might actually want something smaller than this
|
+const double kDrawDurationEstimationPercentile = 100.0; |
+const int kDrawDurationEstimatePaddingInMicroseconds = 0; |
ajuma
2013/06/06 18:00:35
The padding serves 2 purposes: First, by using app
|
+ |
} // namespace |
namespace cc { |
@@ -67,7 +71,8 @@ ThreadProxy::ThreadProxy(LayerTreeHost* layer_tree_host, |
vsync_client_(NULL), |
inside_draw_(false), |
defer_commits_(false), |
- renew_tree_priority_on_impl_thread_pending_(false) { |
+ renew_tree_priority_on_impl_thread_pending_(false), |
+ draw_duration_history_(kDrawDurationHistorySize) { |
TRACE_EVENT0("cc", "ThreadProxy::ThreadProxy"); |
DCHECK(IsMainThread()); |
DCHECK(layer_tree_host_); |
@@ -892,6 +897,7 @@ ScheduledActionDrawAndSwapResult |
ThreadProxy::ScheduledActionDrawAndSwapInternal(bool forced_draw) { |
TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionDrawAndSwap"); |
+ base::TimeTicks start_time = base::TimeTicks::Now(); |
base::AutoReset<bool> mark_inside(&inside_draw_, true); |
ScheduledActionDrawAndSwapResult result; |
@@ -983,8 +989,11 @@ ThreadProxy::ScheduledActionDrawAndSwapInternal(bool forced_draw) { |
base::Bind(&ThreadProxy::DidCommitAndDrawFrame, main_thread_weak_ptr_)); |
} |
- if (draw_frame) |
+ if (draw_frame) { |
CheckOutputSurfaceStatusOnImplThread(); |
+ base::TimeTicks end_time = base::TimeTicks::Now(); |
+ draw_duration_history_.InsertSample(end_time - start_time); |
+ } |
return result; |
} |
@@ -1045,6 +1054,14 @@ void ThreadProxy::DidAnticipatedDrawTimeChange(base::TimeTicks time) { |
layer_tree_host_impl_->ResetCurrentFrameTimeForNextFrame(); |
} |
+base::TimeDelta ThreadProxy::DrawDurationEstimate() { |
+ base::TimeDelta historical_estimate = |
+ draw_duration_history_.Percentile(kDrawDurationEstimationPercentile); |
+ base::TimeDelta padding = base::TimeDelta::FromMicroseconds( |
+ kDrawDurationEstimatePaddingInMicroseconds); |
+ return historical_estimate + padding; |
+} |
+ |
void ThreadProxy::ReadyToFinalizeTextureUpdates() { |
DCHECK(IsImplThread()); |
scheduler_on_impl_thread_->FinishCommit(); |