| 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 #include <algorithm> | 5 #include <algorithm> |
| 6 #include <functional> | 6 #include <functional> |
| 7 | 7 |
| 8 #include "../client/mapped_memory.h" | 8 #include "../client/mapped_memory.h" |
| 9 #include "../client/cmd_buffer_helper.h" | 9 #include "../client/cmd_buffer_helper.h" |
| 10 | 10 |
| 11 namespace gpu { | 11 namespace gpu { |
| 12 namespace { | 12 namespace { |
| 13 void DeleteMemoryChunk(MemoryChunk* chunk) { | 13 void DeleteMemoryChunk(MemoryChunk* chunk) { |
| 14 delete chunk; | 14 delete chunk; |
| 15 } | 15 } |
| 16 } | 16 } |
| 17 | 17 |
| 18 MemoryChunk::MemoryChunk( | 18 MemoryChunk::MemoryChunk( |
| 19 int32 shm_id, gpu::Buffer shm, CommandBufferHelper* helper) | 19 int32 shm_id, gpu::Buffer shm, CommandBufferHelper* helper) |
| 20 : shm_id_(shm_id), | 20 : shm_id_(shm_id), |
| 21 shm_(shm), | 21 shm_(shm), |
| 22 allocator_(shm.size, helper, shm.ptr) { | 22 allocator_(shm.size, helper, shm.ptr) { |
| 23 } | 23 } |
| 24 | 24 |
| 25 MappedMemoryManager::MappedMemoryManager(CommandBufferHelper* helper) |
| 26 : helper_(helper) { |
| 27 } |
| 28 |
| 25 MappedMemoryManager::~MappedMemoryManager() { | 29 MappedMemoryManager::~MappedMemoryManager() { |
| 26 std::for_each(chunks_.begin(), | 30 std::for_each(chunks_.begin(), |
| 27 chunks_.end(), | 31 chunks_.end(), |
| 28 std::pointer_to_unary_function<MemoryChunk*, void>( | 32 std::pointer_to_unary_function<MemoryChunk*, void>( |
| 29 DeleteMemoryChunk)); | 33 DeleteMemoryChunk)); |
| 30 } | 34 } |
| 31 | 35 |
| 32 void* MappedMemoryManager::Alloc( | 36 void* MappedMemoryManager::Alloc( |
| 33 unsigned int size, int32* shm_id, unsigned int* shm_offset) { | 37 unsigned int size, int32* shm_id, unsigned int* shm_offset) { |
| 34 GPU_DCHECK(shm_id); | 38 GPU_DCHECK(shm_id); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 return; | 85 return; |
| 82 } | 86 } |
| 83 } | 87 } |
| 84 GPU_NOTREACHED(); | 88 GPU_NOTREACHED(); |
| 85 } | 89 } |
| 86 | 90 |
| 87 } // namespace gpu | 91 } // namespace gpu |
| 88 | 92 |
| 89 | 93 |
| 90 | 94 |
| OLD | NEW |