| 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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 | 71 |
| 72 // Gets the size of the largest free block that can be allocated if the | 72 // Gets the size of the largest free block that can be allocated if the |
| 73 // caller can wait. Allocating a block of this size will succeed, but may | 73 // caller can wait. Allocating a block of this size will succeed, but may |
| 74 // block. | 74 // block. |
| 75 unsigned int GetLargestFreeOrPendingSize(); | 75 unsigned int GetLargestFreeOrPendingSize(); |
| 76 | 76 |
| 77 // Checks for consistency inside the book-keeping structures. Used for | 77 // Checks for consistency inside the book-keeping structures. Used for |
| 78 // testing. | 78 // testing. |
| 79 bool CheckConsistency(); | 79 bool CheckConsistency(); |
| 80 | 80 |
| 81 // True if any memory is allocated. |
| 82 bool InUse(); |
| 83 |
| 81 private: | 84 private: |
| 82 // Status of a block of memory, for book-keeping. | 85 // Status of a block of memory, for book-keeping. |
| 83 enum State { | 86 enum State { |
| 84 IN_USE, | 87 IN_USE, |
| 85 FREE, | 88 FREE, |
| 86 FREE_PENDING_TOKEN | 89 FREE_PENDING_TOKEN |
| 87 }; | 90 }; |
| 88 | 91 |
| 89 // Book-keeping sturcture that describes a block of memory. | 92 // Book-keeping sturcture that describes a block of memory. |
| 90 struct Block { | 93 struct Block { |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 unsigned int GetLargestFreeOrPendingSize() { | 227 unsigned int GetLargestFreeOrPendingSize() { |
| 225 return allocator_.GetLargestFreeOrPendingSize(); | 228 return allocator_.GetLargestFreeOrPendingSize(); |
| 226 } | 229 } |
| 227 | 230 |
| 228 // Checks for consistency inside the book-keeping structures. Used for | 231 // Checks for consistency inside the book-keeping structures. Used for |
| 229 // testing. | 232 // testing. |
| 230 bool CheckConsistency() { | 233 bool CheckConsistency() { |
| 231 return allocator_.CheckConsistency(); | 234 return allocator_.CheckConsistency(); |
| 232 } | 235 } |
| 233 | 236 |
| 237 // True if any memory is allocated. |
| 238 bool InUse() { |
| 239 return allocator_.InUse(); |
| 240 } |
| 241 |
| 234 FencedAllocator &allocator() { return allocator_; } | 242 FencedAllocator &allocator() { return allocator_; } |
| 235 | 243 |
| 236 private: | 244 private: |
| 237 FencedAllocator allocator_; | 245 FencedAllocator allocator_; |
| 238 void* base_; | 246 void* base_; |
| 239 DISALLOW_IMPLICIT_CONSTRUCTORS(FencedAllocatorWrapper); | 247 DISALLOW_IMPLICIT_CONSTRUCTORS(FencedAllocatorWrapper); |
| 240 }; | 248 }; |
| 241 | 249 |
| 242 } // namespace gpu | 250 } // namespace gpu |
| 243 | 251 |
| 244 #endif // GPU_COMMAND_BUFFER_CLIENT_FENCED_ALLOCATOR_H_ | 252 #endif // GPU_COMMAND_BUFFER_CLIENT_FENCED_ALLOCATOR_H_ |
| OLD | NEW |