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

Unified Diff: cc/trees/thread_proxy.cc

Issue 16574002: Estimate draw duration in SchedulerClient (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 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.h ('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 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();
« cc/scheduler/scheduler.h ('K') | « cc/trees/thread_proxy.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698