Index: cc/debug/smoothness_timing_tracker.h |
diff --git a/cc/debug/smoothness_timing_tracker.h b/cc/debug/smoothness_timing_tracker.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..3114a19cf754bdb8aea61e079217cac77ae63ae2 |
--- /dev/null |
+++ b/cc/debug/smoothness_timing_tracker.h |
@@ -0,0 +1,74 @@ |
+// 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. |
+ |
+#ifndef CC_DEBUG_SMOOTHNESS_TIMING_TRACKER_H_ |
+#define CC_DEBUG_SMOOTHNESS_TIMING_TRACKER_H_ |
+ |
+#include <set> |
+#include <utility> |
+#include <vector> |
+ |
+#include "base/basictypes.h" |
+#include "base/containers/hash_tables.h" |
+#include "base/memory/scoped_ptr.h" |
+#include "base/time/time.h" |
+#include "cc/debug/ring_buffer.h" |
+#include "cc/trees/layer_tree_host_common.h" |
+ |
+namespace cc { |
+ |
+// This class maintains a history of timestamps and rect IDs to communicate |
+// smoothness events back to Blink |
+class SmoothnessTimingTracker { |
+ public: |
+ struct SmoothnessTimingCompositeEvent { |
+ int frame_id_; |
+ int64_t rect_id_; |
+ base::TimeTicks timestamp_; |
+ SmoothnessTimingCompositeEvent(int frame_id, |
+ int64_t rect_id, |
+ base::TimeTicks timestamp) |
+ : frame_id_(frame_id), rect_id_(rect_id), timestamp_(timestamp) {} |
+ SmoothnessTimingCompositeEvent() {} |
+ SmoothnessTimingCompositeEvent(const SmoothnessTimingCompositeEvent& rhs) |
+ : frame_id_(rhs.frame_id_), |
+ rect_id_(rhs.rect_id_), |
+ timestamp_(rhs.timestamp_) {} |
+ SmoothnessTimingCompositeEvent& operator=( |
+ const SmoothnessTimingCompositeEvent& rhs) { |
+ frame_id_ = rhs.frame_id_; |
+ rect_id_ = rhs.rect_id_; |
+ timestamp_ = rhs.timestamp_; |
+ return *this; |
+ } |
+ }; |
+ |
+ static scoped_ptr<SmoothnessTimingTracker> Create(); |
+ |
+ scoped_ptr<CompositeTimingSet> CalculateCompositeCounts(); |
+ |
+ void clear_events() { ring_buffer_.Clear(); } |
+ |
+ int current_frame_number() const { return ring_buffer_.CurrentIndex(); } |
+ size_t time_stamp_history_size() const { return ring_buffer_.BufferSize(); } |
+ |
+ void SaveTimeStamps(base::TimeTicks timestamp, |
+ const std::vector<std::pair<int, int64_t> >& frame_ids); |
+ |
+ typedef RingBuffer<struct SmoothnessTimingCompositeEvent, 4096> |
+ RingBufferType; |
+ RingBufferType::Iterator begin() const { return ring_buffer_.Begin(); } |
+ RingBufferType::Iterator end() const { return ring_buffer_.End(); } |
+ |
+ private: |
+ SmoothnessTimingTracker(); |
+ |
+ RingBufferType ring_buffer_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(SmoothnessTimingTracker); |
+}; |
+ |
+} // namespace cc |
+ |
+#endif // CC_DEBUG_SMOOTHNESS_TIMING_TRACKER_H_ |