| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 // This file contains the definition of the RingBuffer class. | 5 // This file contains the definition of the RingBuffer class. |
| 6 | 6 |
| 7 #ifndef GPU_COMMAND_BUFFER_CLIENT_RING_BUFFER_H_ | 7 #ifndef GPU_COMMAND_BUFFER_CLIENT_RING_BUFFER_H_ |
| 8 #define GPU_COMMAND_BUFFER_CLIENT_RING_BUFFER_H_ | 8 #define GPU_COMMAND_BUFFER_CLIENT_RING_BUFFER_H_ |
| 9 | 9 |
| 10 #include <deque> | 10 #include <deque> |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 unsigned int GetLargestFreeSizeNoWaiting(); | 54 unsigned int GetLargestFreeSizeNoWaiting(); |
| 55 | 55 |
| 56 // Gets the size of the largest free block that can be allocated if the | 56 // Gets the size of the largest free block that can be allocated if the |
| 57 // caller can wait. Allocating a block of this size will succeed, but may | 57 // caller can wait. Allocating a block of this size will succeed, but may |
| 58 // block. | 58 // block. |
| 59 unsigned int GetLargestFreeOrPendingSize() { | 59 unsigned int GetLargestFreeOrPendingSize() { |
| 60 return size_; | 60 return size_; |
| 61 } | 61 } |
| 62 | 62 |
| 63 private: | 63 private: |
| 64 enum State { |
| 65 IN_USE, |
| 66 PADDING, |
| 67 FREE_PENDING_TOKEN |
| 68 }; |
| 64 // Book-keeping sturcture that describes a block of memory. | 69 // Book-keeping sturcture that describes a block of memory. |
| 65 struct Block { | 70 struct Block { |
| 66 Block(Offset _offset, unsigned int _size) | 71 Block(Offset _offset, unsigned int _size, State _state) |
| 67 : offset(_offset), | 72 : offset(_offset), |
| 68 size(_size), | 73 size(_size), |
| 69 token(0), | 74 token(0), |
| 70 valid(false) { | 75 state(_state) { |
| 71 } | 76 } |
| 72 Offset offset; | 77 Offset offset; |
| 73 unsigned int size; | 78 unsigned int size; |
| 74 unsigned int token; // token to wait for. | 79 unsigned int token; // token to wait for. |
| 75 bool valid; // whether or not token has been set. | 80 State state; |
| 76 }; | 81 }; |
| 77 | 82 |
| 78 typedef std::deque<Block> Container; | 83 typedef std::deque<Block> Container; |
| 79 typedef unsigned int BlockIndex; | 84 typedef unsigned int BlockIndex; |
| 80 | 85 |
| 81 void FreeOldestBlock(); | 86 void FreeOldestBlock(); |
| 82 | 87 |
| 83 CommandBufferHelper* helper_; | 88 CommandBufferHelper* helper_; |
| 84 | 89 |
| 85 // Used blocks are added to the end, blocks are freed from the beginning. | 90 // Used blocks are added to the end, blocks are freed from the beginning. |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 private: | 188 private: |
| 184 RingBuffer allocator_; | 189 RingBuffer allocator_; |
| 185 void* base_; | 190 void* base_; |
| 186 RingBuffer::Offset base_offset_; | 191 RingBuffer::Offset base_offset_; |
| 187 DISALLOW_IMPLICIT_CONSTRUCTORS(RingBufferWrapper); | 192 DISALLOW_IMPLICIT_CONSTRUCTORS(RingBufferWrapper); |
| 188 }; | 193 }; |
| 189 | 194 |
| 190 } // namespace gpu | 195 } // namespace gpu |
| 191 | 196 |
| 192 #endif // GPU_COMMAND_BUFFER_CLIENT_RING_BUFFER_H_ | 197 #endif // GPU_COMMAND_BUFFER_CLIENT_RING_BUFFER_H_ |
| OLD | NEW |