| 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 FencedAllocator class. | 5 // This file contains the definition of the FencedAllocator class. |
| 6 | 6 |
| 7 #ifndef GPU_COMMAND_BUFFER_CLIENT_FENCED_ALLOCATOR_H_ | 7 #ifndef GPU_COMMAND_BUFFER_CLIENT_FENCED_ALLOCATOR_H_ |
| 8 #define GPU_COMMAND_BUFFER_CLIENT_FENCED_ALLOCATOR_H_ | 8 #define GPU_COMMAND_BUFFER_CLIENT_FENCED_ALLOCATOR_H_ |
| 9 | 9 |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 // NOTE: this will invalidate block indices. | 125 // NOTE: this will invalidate block indices. |
| 126 BlockIndex WaitForTokenAndFreeBlock(BlockIndex index); | 126 BlockIndex WaitForTokenAndFreeBlock(BlockIndex index); |
| 127 | 127 |
| 128 // Allocates a block of memory inside a given block, splitting it in two | 128 // Allocates a block of memory inside a given block, splitting it in two |
| 129 // (unless that block is of the exact requested size). | 129 // (unless that block is of the exact requested size). |
| 130 // NOTE: this will invalidate block indices. | 130 // NOTE: this will invalidate block indices. |
| 131 // Returns the offset of the allocated block (NOTE: this is different from | 131 // Returns the offset of the allocated block (NOTE: this is different from |
| 132 // the other functions that return a block index). | 132 // the other functions that return a block index). |
| 133 Offset AllocInBlock(BlockIndex index, unsigned int size); | 133 Offset AllocInBlock(BlockIndex index, unsigned int size); |
| 134 | 134 |
| 135 // Frees allocations of size = 0. |
| 136 void FreeZeroAlloc(FencedAllocator::Offset offset); |
| 137 |
| 135 CommandBufferHelper *helper_; | 138 CommandBufferHelper *helper_; |
| 136 Container blocks_; | 139 Container blocks_; |
| 140 Offset zero_offset_; |
| 141 std::vector<bool> zero_allocs_; |
| 137 | 142 |
| 138 DISALLOW_IMPLICIT_CONSTRUCTORS(FencedAllocator); | 143 DISALLOW_IMPLICIT_CONSTRUCTORS(FencedAllocator); |
| 139 }; | 144 }; |
| 140 | 145 |
| 141 // This class functions just like FencedAllocator, but its API uses pointers | 146 // This class functions just like FencedAllocator, but its API uses pointers |
| 142 // instead of offsets. | 147 // instead of offsets. |
| 143 class FencedAllocatorWrapper { | 148 class FencedAllocatorWrapper { |
| 144 public: | 149 public: |
| 145 FencedAllocatorWrapper(unsigned int size, | 150 FencedAllocatorWrapper(unsigned int size, |
| 146 CommandBufferHelper* helper, | 151 CommandBufferHelper* helper, |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 | 250 |
| 246 private: | 251 private: |
| 247 FencedAllocator allocator_; | 252 FencedAllocator allocator_; |
| 248 void* base_; | 253 void* base_; |
| 249 DISALLOW_IMPLICIT_CONSTRUCTORS(FencedAllocatorWrapper); | 254 DISALLOW_IMPLICIT_CONSTRUCTORS(FencedAllocatorWrapper); |
| 250 }; | 255 }; |
| 251 | 256 |
| 252 } // namespace gpu | 257 } // namespace gpu |
| 253 | 258 |
| 254 #endif // GPU_COMMAND_BUFFER_CLIENT_FENCED_ALLOCATOR_H_ | 259 #endif // GPU_COMMAND_BUFFER_CLIENT_FENCED_ALLOCATOR_H_ |
| OLD | NEW |