OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 15 matching lines...) Expand all Loading... |
26 // (see http://www.corp.google.com/eng/doc/cpp_primer.html#thread_safety). | 26 // (see http://www.corp.google.com/eng/doc/cpp_primer.html#thread_safety). |
27 class FencedAllocator { | 27 class FencedAllocator { |
28 public: | 28 public: |
29 typedef unsigned int Offset; | 29 typedef unsigned int Offset; |
30 // Invalid offset, returned by Alloc in case of failure. | 30 // Invalid offset, returned by Alloc in case of failure. |
31 static const Offset kInvalidOffset = 0xffffffffU; | 31 static const Offset kInvalidOffset = 0xffffffffU; |
32 | 32 |
33 // Creates a FencedAllocator. Note that the size of the buffer is passed, but | 33 // Creates a FencedAllocator. Note that the size of the buffer is passed, but |
34 // not its base address: everything is handled as offsets into the buffer. | 34 // not its base address: everything is handled as offsets into the buffer. |
35 FencedAllocator(unsigned int size, | 35 FencedAllocator(unsigned int size, |
36 CommandBufferHelper *helper) | 36 CommandBufferHelper *helper); |
37 : helper_(helper) { | |
38 Block block = { FREE, 0, size, kUnusedToken }; | |
39 blocks_.push_back(block); | |
40 } | |
41 | 37 |
42 ~FencedAllocator(); | 38 ~FencedAllocator(); |
43 | 39 |
44 // Allocates a block of memory. If the buffer is out of directly available | 40 // Allocates a block of memory. If the buffer is out of directly available |
45 // memory, this function may wait until memory that was freed "pending a | 41 // memory, this function may wait until memory that was freed "pending a |
46 // token" can be re-used. | 42 // token" can be re-used. |
47 // | 43 // |
48 // Parameters: | 44 // Parameters: |
49 // size: the size of the memory block to allocate. | 45 // size: the size of the memory block to allocate. |
50 // | 46 // |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 | 235 |
240 private: | 236 private: |
241 FencedAllocator allocator_; | 237 FencedAllocator allocator_; |
242 void* base_; | 238 void* base_; |
243 DISALLOW_IMPLICIT_CONSTRUCTORS(FencedAllocatorWrapper); | 239 DISALLOW_IMPLICIT_CONSTRUCTORS(FencedAllocatorWrapper); |
244 }; | 240 }; |
245 | 241 |
246 } // namespace gpu | 242 } // namespace gpu |
247 | 243 |
248 #endif // GPU_COMMAND_BUFFER_CLIENT_FENCED_ALLOCATOR_H_ | 244 #endif // GPU_COMMAND_BUFFER_CLIENT_FENCED_ALLOCATOR_H_ |
OLD | NEW |