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

Unified Diff: cc/scheduler/begin_frame_tracker.cc

Issue 787763006: cc: Adding BeginFrameTracker object and removing Now() from LTHI. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Adding documentation as requested by Brian. Created 6 years 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
Index: cc/scheduler/begin_frame_tracker.cc
diff --git a/cc/scheduler/begin_frame_tracker.cc b/cc/scheduler/begin_frame_tracker.cc
new file mode 100644
index 0000000000000000000000000000000000000000..c41000cf4face21055f57b8647f0f4f3c1900f7a
--- /dev/null
+++ b/cc/scheduler/begin_frame_tracker.cc
@@ -0,0 +1,81 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "cc/scheduler/begin_frame_tracker.h"
+
+namespace cc {
+
+BeginFrameTracker::BeginFrameTracker(const tracked_objects::Location& location)
+ : location_(location),
+ location_string_(location.ToString()),
+ current_updated_at_(),
+ current_args_(),
+ current_finished_at_(base::TimeTicks::FromInternalValue(-1)) {
+}
+
+BeginFrameTracker::~BeginFrameTracker() {
+}
+
+void BeginFrameTracker::Start(BeginFrameArgs new_args) {
+ // Trace the frame time being passed between BeginFrameTrackers.
+ TRACE_EVENT_FLOW_STEP0(
+ TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler.frames"), "BeginFrameArgs",
+ new_args.frame_time.ToInternalValue(), location_string_);
+
+ // Trace this specific begin frame tracker Start/Finish times.
+ TRACE_EVENT_ASYNC_BEGIN2(
+ TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler.frames"),
+ location_string_.c_str(), new_args.frame_time.ToInternalValue(),
+ "new args", new_args.AsValue(), "current args", current_args_.AsValue());
+
+ // Check the new BeginFrameArgs are valid and monotonically increasing.
+ DCHECK(new_args.IsValid());
+ DCHECK_LT(current_args_.frame_time, new_args.frame_time);
+
+ DCHECK(HasFinished())
+ << "Tried to start a new frame before finishing an existing frame.";
+ current_updated_at_ = base::TimeTicks::NowFromSystemTraceTime();
+ current_args_ = new_args;
+ current_finished_at_ = base::TimeTicks();
+
+ // TODO(mithro): Add UMA tracking of delta between current_updated_at_ time
+ // and the new_args.frame_time argument. This will give us how long after a
+ // BeginFrameArgs message was created before we started processing it.
+}
+
+const BeginFrameArgs& BeginFrameTracker::Get() const {
+ DCHECK(!HasFinished())
+ << "Tried to use BeginFrameArgs after marking the frame finished.";
+ DCHECK(current_args_.IsValid())
+ << "Tried to use BeginFrameArgs before starting a frame!";
+ return current_args_;
+}
+
+void BeginFrameTracker::Finish() {
+ DCHECK(!HasFinished()) << "Tried to finish an already finished frame";
+ current_finished_at_ = base::TimeTicks::NowFromSystemTraceTime();
+ TRACE_EVENT_ASYNC_END0(TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler.frames"),
+ location_string_.c_str(),
+ current_args_.frame_time.ToInternalValue());
+}
+
+const BeginFrameArgs& BeginFrameTracker::Last() const {
+ DCHECK(current_args_.IsValid())
+ << "Tried to use last BeginFrameArgs before starting a frame!";
+ DCHECK(HasFinished())
+ << "Tried to use last BeginFrameArgs before the frame is finished.";
+ return current_args_;
+}
+
+base::TimeDelta BeginFrameTracker::Interval() const {
+ base::TimeDelta interval = current_args_.interval;
+ // Normal interval will be ~16ms, 200Hz (5ms) screens are the fastest
+ // easily available so anything less than that is likely an error.
+ if (interval < base::TimeDelta::FromMilliseconds(4)) {
brianderson 2014/12/18 21:57:08 250Hz seems like something we could hit eventually
mithro-old 2014/12/18 23:15:05 I picked 250Hz because in theory 240Hz projectors
brianderson 2014/12/19 01:18:25 1kHz seems less risky.
mithro-old 2014/12/19 03:40:55 Done.
+ interval = BeginFrameArgs::DefaultInterval();
+ }
+ return interval;
+}
+
+} // namespace cc

Powered by Google App Engine
This is Rietveld 408576698