| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CC_TREES_FRAME_RATE_COUNTER_H_ | 5 #ifndef CC_TREES_FRAME_RATE_COUNTER_H_ |
| 6 #define CC_TREES_FRAME_RATE_COUNTER_H_ | 6 #define CC_TREES_FRAME_RATE_COUNTER_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| 11 | 11 |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/time/time.h" | 13 #include "base/time/time.h" |
| 14 #include "cc/base/ring_buffer.h" | 14 #include "cc/base/ring_buffer.h" |
| 15 #include "cc/cc_export.h" |
| 15 | 16 |
| 16 namespace cc { | 17 namespace cc { |
| 17 | 18 |
| 18 // This class maintains a history of timestamps, and provides functionality to | 19 // This class maintains a history of timestamps, and provides functionality to |
| 19 // intelligently compute average frames per second. | 20 // intelligently compute average frames per second. |
| 20 class FrameRateCounter { | 21 class CC_EXPORT FrameRateCounter { |
| 21 public: | 22 public: |
| 22 static std::unique_ptr<FrameRateCounter> Create(bool has_impl_thread); | 23 static std::unique_ptr<FrameRateCounter> Create(bool has_impl_thread); |
| 23 | 24 |
| 24 size_t current_frame_number() const { return ring_buffer_.CurrentIndex(); } | 25 size_t current_frame_number() const { return ring_buffer_.CurrentIndex(); } |
| 25 int dropped_frame_count() const { return dropped_frame_count_; } | 26 int dropped_frame_count() const { return dropped_frame_count_; } |
| 26 size_t time_stamp_history_size() const { return ring_buffer_.BufferSize(); } | 27 size_t time_stamp_history_size() const { return ring_buffer_.BufferSize(); } |
| 27 | 28 |
| 28 void SaveTimeStamp(base::TimeTicks timestamp, bool software); | 29 void SaveTimeStamp(base::TimeTicks timestamp, bool software); |
| 29 | 30 |
| 30 // n = 0 returns the oldest frame interval retained in the history, while n = | 31 // n = 0 returns the oldest frame interval retained in the history, while n = |
| (...skipping 20 matching lines...) Expand all Loading... |
| 51 | 52 |
| 52 bool has_impl_thread_; | 53 bool has_impl_thread_; |
| 53 int dropped_frame_count_; | 54 int dropped_frame_count_; |
| 54 | 55 |
| 55 DISALLOW_COPY_AND_ASSIGN(FrameRateCounter); | 56 DISALLOW_COPY_AND_ASSIGN(FrameRateCounter); |
| 56 }; | 57 }; |
| 57 | 58 |
| 58 } // namespace cc | 59 } // namespace cc |
| 59 | 60 |
| 60 #endif // CC_TREES_FRAME_RATE_COUNTER_H_ | 61 #endif // CC_TREES_FRAME_RATE_COUNTER_H_ |
| OLD | NEW |