OLD | NEW |
1 // Copyright (c) 2011 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> |
| 11 |
| 12 #include "../../gpu_export.h" |
11 #include "../common/logging.h" | 13 #include "../common/logging.h" |
12 #include "../common/types.h" | 14 #include "../common/types.h" |
13 | 15 |
14 namespace gpu { | 16 namespace gpu { |
15 class CommandBufferHelper; | 17 class CommandBufferHelper; |
16 | 18 |
17 // FencedAllocator provides a mechanism to manage allocations within a fixed | 19 // FencedAllocator provides a mechanism to manage allocations within a fixed |
18 // block of memory (storing the book-keeping externally). Furthermore this | 20 // block of memory (storing the book-keeping externally). Furthermore this |
19 // class allows to free data "pending" the passage of a command buffer token, | 21 // class allows to free data "pending" the passage of a command buffer token, |
20 // that is, the memory won't be reused until the command buffer has processed | 22 // that is, the memory won't be reused until the command buffer has processed |
21 // that token. | 23 // that token. |
22 // | 24 // |
23 // NOTE: Although this class is intended to be used in the command buffer | 25 // NOTE: Although this class is intended to be used in the command buffer |
24 // environment which is multi-process, this class isn't "thread safe", because | 26 // environment which is multi-process, this class isn't "thread safe", because |
25 // it isn't meant to be shared across modules. It is thread-compatible though | 27 // it isn't meant to be shared across modules. It is thread-compatible though |
26 // (see http://www.corp.google.com/eng/doc/cpp_primer.html#thread_safety). | 28 // (see http://www.corp.google.com/eng/doc/cpp_primer.html#thread_safety). |
27 class FencedAllocator { | 29 class GPU_EXPORT FencedAllocator { |
28 public: | 30 public: |
29 typedef unsigned int Offset; | 31 typedef unsigned int Offset; |
30 // Invalid offset, returned by Alloc in case of failure. | 32 // Invalid offset, returned by Alloc in case of failure. |
31 static const Offset kInvalidOffset = 0xffffffffU; | 33 static const Offset kInvalidOffset = 0xffffffffU; |
32 | 34 |
33 // Creates a FencedAllocator. Note that the size of the buffer is passed, but | 35 // 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. | 36 // not its base address: everything is handled as offsets into the buffer. |
35 FencedAllocator(unsigned int size, | 37 FencedAllocator(unsigned int size, |
36 CommandBufferHelper *helper); | 38 CommandBufferHelper *helper); |
37 | 39 |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 | 245 |
244 private: | 246 private: |
245 FencedAllocator allocator_; | 247 FencedAllocator allocator_; |
246 void* base_; | 248 void* base_; |
247 DISALLOW_IMPLICIT_CONSTRUCTORS(FencedAllocatorWrapper); | 249 DISALLOW_IMPLICIT_CONSTRUCTORS(FencedAllocatorWrapper); |
248 }; | 250 }; |
249 | 251 |
250 } // namespace gpu | 252 } // namespace gpu |
251 | 253 |
252 #endif // GPU_COMMAND_BUFFER_CLIENT_FENCED_ALLOCATOR_H_ | 254 #endif // GPU_COMMAND_BUFFER_CLIENT_FENCED_ALLOCATOR_H_ |
OLD | NEW |