OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 // 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 <stdint.h> |
| 11 |
10 #include <deque> | 12 #include <deque> |
11 | 13 |
12 #include "base/logging.h" | 14 #include "base/logging.h" |
13 #include "base/macros.h" | 15 #include "base/macros.h" |
14 #include "gpu/gpu_export.h" | 16 #include "gpu/gpu_export.h" |
15 | 17 |
16 namespace gpu { | 18 namespace gpu { |
17 class CommandBufferHelper; | 19 class CommandBufferHelper; |
18 | 20 |
19 // RingBuffer manages a piece of memory as a ring buffer. Memory is allocated | 21 // RingBuffer manages a piece of memory as a ring buffer. Memory is allocated |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 | 70 |
69 // Gets the size of the largest free block that can be allocated if the | 71 // Gets the size of the largest free block that can be allocated if the |
70 // caller can wait. Allocating a block of this size will succeed, but may | 72 // caller can wait. Allocating a block of this size will succeed, but may |
71 // block. | 73 // block. |
72 unsigned int GetLargestFreeOrPendingSize() { | 74 unsigned int GetLargestFreeOrPendingSize() { |
73 return size_; | 75 return size_; |
74 } | 76 } |
75 | 77 |
76 // Gets a pointer to a memory block given the base memory and the offset. | 78 // Gets a pointer to a memory block given the base memory and the offset. |
77 void* GetPointer(RingBuffer::Offset offset) const { | 79 void* GetPointer(RingBuffer::Offset offset) const { |
78 return static_cast<int8*>(base_) + offset; | 80 return static_cast<int8_t*>(base_) + offset; |
79 } | 81 } |
80 | 82 |
81 // Gets the offset to a memory block given the base memory and the address. | 83 // Gets the offset to a memory block given the base memory and the address. |
82 RingBuffer::Offset GetOffset(void* pointer) const { | 84 RingBuffer::Offset GetOffset(void* pointer) const { |
83 return static_cast<int8*>(pointer) - static_cast<int8*>(base_); | 85 return static_cast<int8_t*>(pointer) - static_cast<int8_t*>(base_); |
84 } | 86 } |
85 | 87 |
86 // Rounds the given size to the alignment in use. | 88 // Rounds the given size to the alignment in use. |
87 unsigned int RoundToAlignment(unsigned int size) { | 89 unsigned int RoundToAlignment(unsigned int size) { |
88 return (size + alignment_ - 1) & ~(alignment_ - 1); | 90 return (size + alignment_ - 1) & ~(alignment_ - 1); |
89 } | 91 } |
90 | 92 |
91 | 93 |
92 private: | 94 private: |
93 enum State { | 95 enum State { |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 | 139 |
138 // The physical address that corresponds to base_offset. | 140 // The physical address that corresponds to base_offset. |
139 void* base_; | 141 void* base_; |
140 | 142 |
141 DISALLOW_IMPLICIT_CONSTRUCTORS(RingBuffer); | 143 DISALLOW_IMPLICIT_CONSTRUCTORS(RingBuffer); |
142 }; | 144 }; |
143 | 145 |
144 } // namespace gpu | 146 } // namespace gpu |
145 | 147 |
146 #endif // GPU_COMMAND_BUFFER_CLIENT_RING_BUFFER_H_ | 148 #endif // GPU_COMMAND_BUFFER_CLIENT_RING_BUFFER_H_ |
OLD | NEW |