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

Side by Side Diff: cc/ring_buffer.h

Issue 12209022: cc: add rasterize time to continuous painting graph data in impl-side-painting (Closed) Base URL: http://git.chromium.org/chromium/src.git@raster
Patch Set: Rebase to 182752 Created 7 years, 10 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_RING_BUFFER_H_ 5 #ifndef CC_RING_BUFFER_H_
6 #define CC_RING_BUFFER_H_ 6 #define CC_RING_BUFFER_H_
7 7
8 #include "base/logging.h" 8 #include "base/logging.h"
9 9
10 namespace cc { 10 namespace cc {
(...skipping 18 matching lines...) Expand all
29 return BufferIndex(n) < current_index_; 29 return BufferIndex(n) < current_index_;
30 } 30 }
31 31
32 // n = 0 returns the oldest value and 32 // n = 0 returns the oldest value and
33 // n = bufferSize() - 1 returns the most recent value. 33 // n = bufferSize() - 1 returns the most recent value.
34 const T& ReadBuffer(size_t n) const { 34 const T& ReadBuffer(size_t n) const {
35 DCHECK(IsFilledIndex(n)); 35 DCHECK(IsFilledIndex(n));
36 return buffer_[BufferIndex(n)]; 36 return buffer_[BufferIndex(n)];
37 } 37 }
38 38
39 void SaveToBuffer(T value) { 39 T& MutableReadBuffer(size_t n) {
40 DCHECK(IsFilledIndex(n));
41 return buffer_[BufferIndex(n)];
42 }
43
44 void SaveToBuffer(const T& value) {
40 buffer_[BufferIndex(0)] = value; 45 buffer_[BufferIndex(0)] = value;
41 current_index_++; 46 current_index_++;
42 } 47 }
43 48
49 void Clear() {
50 current_index_ = 0;
51 }
52
44 private: 53 private:
45 inline size_t BufferIndex(size_t n) const { 54 inline size_t BufferIndex(size_t n) const {
46 return (current_index_ + n) % size; 55 return (current_index_ + n) % size;
47 } 56 }
48 57
49 T buffer_[size]; 58 T buffer_[size];
50 size_t current_index_; 59 size_t current_index_;
51 }; 60 };
52 61
53 } // namespace cc 62 } // namespace cc
54 63
55 #endif // CC_RING_BUFFER_H_ 64 #endif // CC_RING_BUFFER_H_
OLDNEW
« cc/paint_time_counter.h ('K') | « cc/rendering_stats.cc ('k') | cc/tile_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698