| 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 15 matching lines...) Expand all Loading... |
| 26 // that token. | 26 // that token. |
| 27 // | 27 // |
| 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 enum : Offset { kInvalidOffset = 0xffffffffU }; |
| 37 | 37 |
| 38 // Allocation alignment, must be a power of two. | 38 // Allocation alignment, must be a power of two. |
| 39 static const unsigned int kAllocAlignment = 16; | 39 enum : unsigned int { kAllocAlignment = 16 }; |
| 40 | 40 |
| 41 // 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 |
| 42 // 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. |
| 43 FencedAllocator(unsigned int size, CommandBufferHelper* helper); | 43 FencedAllocator(unsigned int size, CommandBufferHelper* helper); |
| 44 | 44 |
| 45 ~FencedAllocator(); | 45 ~FencedAllocator(); |
| 46 | 46 |
| 47 // Allocates a block of memory. If the buffer is out of directly available | 47 // Allocates a block of memory. If the buffer is out of directly available |
| 48 // memory, this function may wait until memory that was freed "pending a | 48 // memory, this function may wait until memory that was freed "pending a |
| 49 // token" can be re-used. | 49 // token" can be re-used. |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 | 261 |
| 262 private: | 262 private: |
| 263 FencedAllocator allocator_; | 263 FencedAllocator allocator_; |
| 264 void* base_; | 264 void* base_; |
| 265 DISALLOW_IMPLICIT_CONSTRUCTORS(FencedAllocatorWrapper); | 265 DISALLOW_IMPLICIT_CONSTRUCTORS(FencedAllocatorWrapper); |
| 266 }; | 266 }; |
| 267 | 267 |
| 268 } // namespace gpu | 268 } // namespace gpu |
| 269 | 269 |
| 270 #endif // GPU_COMMAND_BUFFER_CLIENT_FENCED_ALLOCATOR_H_ | 270 #endif // GPU_COMMAND_BUFFER_CLIENT_FENCED_ALLOCATOR_H_ |
| OLD | NEW |