OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2009, Google Inc. | 2 * Copyright 2009, Google Inc. |
3 * All rights reserved. | 3 * All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
7 * met: | 7 * met: |
8 * | 8 * |
9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 14 matching lines...) Expand all Loading... |
25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
30 */ | 30 */ |
31 | 31 |
32 | 32 |
33 // This file contains the definition of the FencedAllocator class. | 33 // This file contains the definition of the FencedAllocator class. |
34 | 34 |
35 #ifndef GPU_COMMAND_BUFFER_CLIENT_CROSS_FENCED_ALLOCATOR_H_ | 35 #ifndef GPU_COMMAND_BUFFER_CLIENT_FENCED_ALLOCATOR_H_ |
36 #define GPU_COMMAND_BUFFER_CLIENT_CROSS_FENCED_ALLOCATOR_H_ | 36 #define GPU_COMMAND_BUFFER_CLIENT_FENCED_ALLOCATOR_H_ |
37 | 37 |
38 #include <vector> | 38 #include <vector> |
39 #include "base/basictypes.h" | 39 #include "base/basictypes.h" |
40 #include "gpu/command_buffer/common/logging.h" | 40 #include "gpu/command_buffer/common/logging.h" |
41 | 41 |
42 namespace command_buffer { | 42 namespace gpu { |
43 class CommandBufferHelper; | 43 class CommandBufferHelper; |
44 | 44 |
45 // FencedAllocator provides a mechanism to manage allocations within a fixed | 45 // FencedAllocator provides a mechanism to manage allocations within a fixed |
46 // block of memory (storing the book-keeping externally). Furthermore this | 46 // block of memory (storing the book-keeping externally). Furthermore this |
47 // class allows to free data "pending" the passage of a command buffer token, | 47 // class allows to free data "pending" the passage of a command buffer token, |
48 // that is, the memory won't be reused until the command buffer has processed | 48 // that is, the memory won't be reused until the command buffer has processed |
49 // that token. | 49 // that token. |
50 // | 50 // |
51 // NOTE: Although this class is intended to be used in the command buffer | 51 // NOTE: Although this class is intended to be used in the command buffer |
52 // environment which is multi-process, this class isn't "thread safe", because | 52 // environment which is multi-process, this class isn't "thread safe", because |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 // NOTE: this will invalidate block indices. | 149 // NOTE: this will invalidate block indices. |
150 BlockIndex WaitForTokenAndFreeBlock(BlockIndex index); | 150 BlockIndex WaitForTokenAndFreeBlock(BlockIndex index); |
151 | 151 |
152 // Allocates a block of memory inside a given block, splitting it in two | 152 // Allocates a block of memory inside a given block, splitting it in two |
153 // (unless that block is of the exact requested size). | 153 // (unless that block is of the exact requested size). |
154 // NOTE: this will invalidate block indices. | 154 // NOTE: this will invalidate block indices. |
155 // Returns the offset of the allocated block (NOTE: this is different from | 155 // Returns the offset of the allocated block (NOTE: this is different from |
156 // the other functions that return a block index). | 156 // the other functions that return a block index). |
157 Offset AllocInBlock(BlockIndex index, unsigned int size); | 157 Offset AllocInBlock(BlockIndex index, unsigned int size); |
158 | 158 |
159 command_buffer::CommandBufferHelper *helper_; | 159 gpu::CommandBufferHelper *helper_; |
160 Container blocks_; | 160 Container blocks_; |
161 | 161 |
162 DISALLOW_IMPLICIT_CONSTRUCTORS(FencedAllocator); | 162 DISALLOW_IMPLICIT_CONSTRUCTORS(FencedAllocator); |
163 }; | 163 }; |
164 | 164 |
165 // This class functions just like FencedAllocator, but its API uses pointers | 165 // This class functions just like FencedAllocator, but its API uses pointers |
166 // instead of offsets. | 166 // instead of offsets. |
167 class FencedAllocatorWrapper { | 167 class FencedAllocatorWrapper { |
168 public: | 168 public: |
169 FencedAllocatorWrapper(unsigned int size, | 169 FencedAllocatorWrapper(unsigned int size, |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 } | 254 } |
255 | 255 |
256 FencedAllocator &allocator() { return allocator_; } | 256 FencedAllocator &allocator() { return allocator_; } |
257 | 257 |
258 private: | 258 private: |
259 FencedAllocator allocator_; | 259 FencedAllocator allocator_; |
260 void *base_; | 260 void *base_; |
261 DISALLOW_IMPLICIT_CONSTRUCTORS(FencedAllocatorWrapper); | 261 DISALLOW_IMPLICIT_CONSTRUCTORS(FencedAllocatorWrapper); |
262 }; | 262 }; |
263 | 263 |
264 } // namespace command_buffer | 264 } // namespace gpu |
265 | 265 |
266 #endif // GPU_COMMAND_BUFFER_CLIENT_CROSS_FENCED_ALLOCATOR_H_ | 266 #endif // GPU_COMMAND_BUFFER_CLIENT_FENCED_ALLOCATOR_H_ |
OLD | NEW |