| 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 <stdint.h> | 10 #include <stdint.h> |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 // NOTE: Although this class is intended to be used in the command buffer | 28 // NOTE: Although this class is intended to be used in the command buffer |
| 29 // environment which is multi-process, this class isn't "thread safe", because | 29 // environment which is multi-process, this class isn't "thread safe", because |
| 30 // it isn't meant to be shared across modules. It is thread-compatible though | 30 // it isn't meant to be shared across modules. It is thread-compatible though |
| 31 // (see http://www.corp.google.com/eng/doc/cpp_primer.html#thread_safety). | 31 // (see http://www.corp.google.com/eng/doc/cpp_primer.html#thread_safety). |
| 32 class GPU_EXPORT FencedAllocator { | 32 class GPU_EXPORT FencedAllocator { |
| 33 public: | 33 public: |
| 34 typedef unsigned int Offset; | 34 typedef unsigned int Offset; |
| 35 // Invalid offset, returned by Alloc in case of failure. | 35 // Invalid offset, returned by Alloc in case of failure. |
| 36 static const Offset kInvalidOffset = 0xffffffffU; | 36 static const Offset kInvalidOffset = 0xffffffffU; |
| 37 | 37 |
| 38 // Allocation alignment, must be a power of two. |
| 39 static const unsigned int kAllocAlignment = 16; |
| 40 |
| 38 // Creates a FencedAllocator. Note that the size of the buffer is passed, but | 41 // Creates a FencedAllocator. Note that the size of the buffer is passed, but |
| 39 // not its base address: everything is handled as offsets into the buffer. | 42 // not its base address: everything is handled as offsets into the buffer. |
| 40 FencedAllocator(unsigned int size, | 43 FencedAllocator(unsigned int size, |
| 41 CommandBufferHelper *helper, | 44 CommandBufferHelper *helper, |
| 42 const base::Closure& poll_callback); | 45 const base::Closure& poll_callback); |
| 43 | 46 |
| 44 ~FencedAllocator(); | 47 ~FencedAllocator(); |
| 45 | 48 |
| 46 // Allocates a block of memory. If the buffer is out of directly available | 49 // Allocates a block of memory. If the buffer is out of directly available |
| 47 // memory, this function may wait until memory that was freed "pending a | 50 // memory, this function may wait until memory that was freed "pending a |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 | 260 |
| 258 private: | 261 private: |
| 259 FencedAllocator allocator_; | 262 FencedAllocator allocator_; |
| 260 void* base_; | 263 void* base_; |
| 261 DISALLOW_IMPLICIT_CONSTRUCTORS(FencedAllocatorWrapper); | 264 DISALLOW_IMPLICIT_CONSTRUCTORS(FencedAllocatorWrapper); |
| 262 }; | 265 }; |
| 263 | 266 |
| 264 } // namespace gpu | 267 } // namespace gpu |
| 265 | 268 |
| 266 #endif // GPU_COMMAND_BUFFER_CLIENT_FENCED_ALLOCATOR_H_ | 269 #endif // GPU_COMMAND_BUFFER_CLIENT_FENCED_ALLOCATOR_H_ |
| OLD | NEW |