| 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 <stddef.h> |
| 10 #include <stdint.h> | 11 #include <stdint.h> |
| 11 | 12 |
| 12 #include <vector> | 13 #include <vector> |
| 13 | 14 |
| 14 #include "base/bind.h" | 15 #include "base/bind.h" |
| 15 #include "base/logging.h" | 16 #include "base/logging.h" |
| 16 #include "base/macros.h" | 17 #include "base/macros.h" |
| 17 #include "gpu/gpu_export.h" | 18 #include "gpu/gpu_export.h" |
| 18 | 19 |
| 19 namespace gpu { | 20 namespace gpu { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 // Parameters: | 62 // Parameters: |
| 62 // offset: the offset of the memory block to free. | 63 // offset: the offset of the memory block to free. |
| 63 void Free(Offset offset); | 64 void Free(Offset offset); |
| 64 | 65 |
| 65 // Frees a block of memory, pending the passage of a token. That memory won't | 66 // Frees a block of memory, pending the passage of a token. That memory won't |
| 66 // be re-allocated until the token has passed through the command stream. | 67 // be re-allocated until the token has passed through the command stream. |
| 67 // | 68 // |
| 68 // Parameters: | 69 // Parameters: |
| 69 // offset: the offset of the memory block to free. | 70 // offset: the offset of the memory block to free. |
| 70 // token: the token value to wait for before re-using the memory. | 71 // token: the token value to wait for before re-using the memory. |
| 71 void FreePendingToken(Offset offset, int32 token); | 72 void FreePendingToken(Offset offset, int32_t token); |
| 72 | 73 |
| 73 // Frees any blocks pending a token for which the token has been read. | 74 // Frees any blocks pending a token for which the token has been read. |
| 74 void FreeUnused(); | 75 void FreeUnused(); |
| 75 | 76 |
| 76 // Gets the size of the largest free block that is available without waiting. | 77 // Gets the size of the largest free block that is available without waiting. |
| 77 unsigned int GetLargestFreeSize(); | 78 unsigned int GetLargestFreeSize(); |
| 78 | 79 |
| 79 // Gets the size of the largest free block that can be allocated if the | 80 // Gets the size of the largest free block that can be allocated if the |
| 80 // caller can wait. Allocating a block of this size will succeed, but may | 81 // caller can wait. Allocating a block of this size will succeed, but may |
| 81 // block. | 82 // block. |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 DCHECK(pointer); | 198 DCHECK(pointer); |
| 198 allocator_.Free(GetOffset(pointer)); | 199 allocator_.Free(GetOffset(pointer)); |
| 199 } | 200 } |
| 200 | 201 |
| 201 // Frees a block of memory, pending the passage of a token. That memory won't | 202 // Frees a block of memory, pending the passage of a token. That memory won't |
| 202 // be re-allocated until the token has passed through the command stream. | 203 // be re-allocated until the token has passed through the command stream. |
| 203 // | 204 // |
| 204 // Parameters: | 205 // Parameters: |
| 205 // pointer: the pointer to the memory block to free. | 206 // pointer: the pointer to the memory block to free. |
| 206 // token: the token value to wait for before re-using the memory. | 207 // token: the token value to wait for before re-using the memory. |
| 207 void FreePendingToken(void *pointer, int32 token) { | 208 void FreePendingToken(void* pointer, int32_t token) { |
| 208 DCHECK(pointer); | 209 DCHECK(pointer); |
| 209 allocator_.FreePendingToken(GetOffset(pointer), token); | 210 allocator_.FreePendingToken(GetOffset(pointer), token); |
| 210 } | 211 } |
| 211 | 212 |
| 212 // Frees any blocks pending a token for which the token has been read. | 213 // Frees any blocks pending a token for which the token has been read. |
| 213 void FreeUnused() { | 214 void FreeUnused() { |
| 214 allocator_.FreeUnused(); | 215 allocator_.FreeUnused(); |
| 215 } | 216 } |
| 216 | 217 |
| 217 // Gets a pointer to a memory block given the base memory and the offset. | 218 // Gets a pointer to a memory block given the base memory and the offset. |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 | 262 |
| 262 private: | 263 private: |
| 263 FencedAllocator allocator_; | 264 FencedAllocator allocator_; |
| 264 void* base_; | 265 void* base_; |
| 265 DISALLOW_IMPLICIT_CONSTRUCTORS(FencedAllocatorWrapper); | 266 DISALLOW_IMPLICIT_CONSTRUCTORS(FencedAllocatorWrapper); |
| 266 }; | 267 }; |
| 267 | 268 |
| 268 } // namespace gpu | 269 } // namespace gpu |
| 269 | 270 |
| 270 #endif // GPU_COMMAND_BUFFER_CLIENT_FENCED_ALLOCATOR_H_ | 271 #endif // GPU_COMMAND_BUFFER_CLIENT_FENCED_ALLOCATOR_H_ |
| OLD | NEW |