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

Side by Side Diff: cc/ring_buffer.h

Issue 11817011: cc: add RingBuffer class for timestamp storing in FrameRateCounter (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 7 years, 11 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 unified diff | Download patch
« cc/layer_tree_host_impl.cc ('K') | « cc/layer_tree_host_impl.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2012 The Chromium Authors. All rights reserved.
shawnsingh 2013/01/09 20:55:09 2013 now =)
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CC_RING_BUFFER_H_
shawnsingh 2013/01/09 20:55:09 As I understand, we are trying to make all new fil
6 #define CC_RING_BUFFER_H_
7
8 namespace cc {
9
10 template<typename T, int size>
11 class RingBuffer {
12 public:
13 int bufferSize() const
14 {
15 return size;
16 }
17
18 // n = 0 returns the oldest value and
19 // n = bufferSize() - 1 returns the most recent value.
20 T readBuffer(int n) const
21 {
22 return m_buffer[bufferIndex(m_currentIndex + n)];
23 }
24
25 protected:
26 explicit RingBuffer()
27 : m_currentIndex(0)
28 {
29 }
30
31 void saveToBuffer(T value)
32 {
33 m_buffer[bufferIndex(m_currentIndex)] = value;
34 m_currentIndex++;
35 }
36
37 inline int bufferIndex(int n) const
38 {
39 return (n % size + size) % size;
shawnsingh 2013/01/09 20:55:09 Wouldn't this be equivalent to (n+size) % size, w
40 }
41
42 T m_buffer[size];
43 int m_currentIndex;
44 };
45
46 } // namespace cc
47
48 #endif // CC_RING_BUFFER_H_
OLDNEW
« cc/layer_tree_host_impl.cc ('K') | « cc/layer_tree_host_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698