| 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 #ifndef GPU_COMMAND_BUFFER_CLIENT_MAPPED_MEMORY_H_ | 5 #ifndef GPU_COMMAND_BUFFER_CLIENT_MAPPED_MEMORY_H_ |
| 6 #define GPU_COMMAND_BUFFER_CLIENT_MAPPED_MEMORY_H_ | 6 #define GPU_COMMAND_BUFFER_CLIENT_MAPPED_MEMORY_H_ |
| 7 | 7 |
| 8 #include "base/memory/scoped_vector.h" | 8 #include "base/memory/scoped_vector.h" |
| 9 #include "gpu/command_buffer/client/fenced_allocator.h" | 9 #include "gpu/command_buffer/client/fenced_allocator.h" |
| 10 #include "gpu/command_buffer/common/buffer.h" | 10 #include "gpu/command_buffer/common/buffer.h" |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 // Frees a block of memory, pending the passage of a token. That memory won't | 72 // Frees a block of memory, pending the passage of a token. That memory won't |
| 73 // be re-allocated until the token has passed through the command stream. | 73 // be re-allocated until the token has passed through the command stream. |
| 74 // | 74 // |
| 75 // Parameters: | 75 // Parameters: |
| 76 // pointer: the pointer to the memory block to free. | 76 // pointer: the pointer to the memory block to free. |
| 77 // token: the token value to wait for before re-using the memory. | 77 // token: the token value to wait for before re-using the memory. |
| 78 void FreePendingToken(void* pointer, unsigned int token) { | 78 void FreePendingToken(void* pointer, unsigned int token) { |
| 79 allocator_.FreePendingToken(pointer, token); | 79 allocator_.FreePendingToken(pointer, token); |
| 80 } | 80 } |
| 81 | 81 |
| 82 void FreePendingAsyncToken(void* pointer, uint32 async_token) { |
| 83 allocator_.FreePendingAsyncToken(pointer, async_token); |
| 84 } |
| 85 |
| 82 // Frees any blocks whose tokens have passed. | 86 // Frees any blocks whose tokens have passed. |
| 83 void FreeUnused() { | 87 void FreeUnused() { |
| 84 allocator_.FreeUnused(); | 88 allocator_.FreeUnused(); |
| 85 } | 89 } |
| 86 | 90 |
| 87 // Returns true if pointer is in the range of this block. | 91 // Returns true if pointer is in the range of this block. |
| 88 bool IsInChunk(void* pointer) const { | 92 bool IsInChunk(void* pointer) const { |
| 89 return pointer >= shm_.ptr && | 93 return pointer >= shm_.ptr && |
| 90 pointer < reinterpret_cast<const int8*>(shm_.ptr) + shm_.size; | 94 pointer < reinterpret_cast<const int8*>(shm_.ptr) + shm_.size; |
| 91 } | 95 } |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 void Free(void* pointer); | 150 void Free(void* pointer); |
| 147 | 151 |
| 148 // Frees a block of memory, pending the passage of a token. That memory won't | 152 // Frees a block of memory, pending the passage of a token. That memory won't |
| 149 // be re-allocated until the token has passed through the command stream. | 153 // be re-allocated until the token has passed through the command stream. |
| 150 // | 154 // |
| 151 // Parameters: | 155 // Parameters: |
| 152 // pointer: the pointer to the memory block to free. | 156 // pointer: the pointer to the memory block to free. |
| 153 // token: the token value to wait for before re-using the memory. | 157 // token: the token value to wait for before re-using the memory. |
| 154 void FreePendingToken(void* pointer, int32 token); | 158 void FreePendingToken(void* pointer, int32 token); |
| 155 | 159 |
| 160 void FreePendingAsyncToken(void *pointer, uint32 async_token); |
| 161 |
| 156 // Free Any Shared memory that is not in use. | 162 // Free Any Shared memory that is not in use. |
| 157 void FreeUnused(); | 163 void FreeUnused(); |
| 158 | 164 |
| 159 // Used for testing | 165 // Used for testing |
| 160 size_t num_chunks() const { | 166 size_t num_chunks() const { |
| 161 return chunks_.size(); | 167 return chunks_.size(); |
| 162 } | 168 } |
| 163 | 169 |
| 164 // Used for testing | 170 // Used for testing |
| 165 size_t allocated_memory() const { | 171 size_t allocated_memory() const { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 176 size_t allocated_memory_; | 182 size_t allocated_memory_; |
| 177 size_t max_free_bytes_; | 183 size_t max_free_bytes_; |
| 178 | 184 |
| 179 DISALLOW_COPY_AND_ASSIGN(MappedMemoryManager); | 185 DISALLOW_COPY_AND_ASSIGN(MappedMemoryManager); |
| 180 }; | 186 }; |
| 181 | 187 |
| 182 } // namespace gpu | 188 } // namespace gpu |
| 183 | 189 |
| 184 #endif // GPU_COMMAND_BUFFER_CLIENT_MAPPED_MEMORY_H_ | 190 #endif // GPU_COMMAND_BUFFER_CLIENT_MAPPED_MEMORY_H_ |
| 185 | 191 |
| OLD | NEW |