OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "gpu/command_buffer/client/mapped_memory.h" | 5 #include "gpu/command_buffer/client/mapped_memory.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <functional> | 8 #include <functional> |
9 | 9 |
10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 for (size_t ii = 0; ii < chunks_.size(); ++ii) { | 110 for (size_t ii = 0; ii < chunks_.size(); ++ii) { |
111 MemoryChunk* chunk = chunks_[ii]; | 111 MemoryChunk* chunk = chunks_[ii]; |
112 if (chunk->IsInChunk(pointer)) { | 112 if (chunk->IsInChunk(pointer)) { |
113 chunk->FreePendingToken(pointer, token); | 113 chunk->FreePendingToken(pointer, token); |
114 return; | 114 return; |
115 } | 115 } |
116 } | 116 } |
117 NOTREACHED(); | 117 NOTREACHED(); |
118 } | 118 } |
119 | 119 |
| 120 void MappedMemoryManager::FreePendingSerial(void *pointer, uint32 serial) { |
| 121 for (size_t ii = 0; ii < chunks_.size(); ++ii) { |
| 122 MemoryChunk* chunk = chunks_[ii]; |
| 123 if (chunk->IsInChunk(pointer)) { |
| 124 chunk->FreePendingSerial(pointer, serial); |
| 125 return; |
| 126 } |
| 127 } |
| 128 NOTREACHED(); |
| 129 } |
| 130 |
120 void MappedMemoryManager::FreeUnused() { | 131 void MappedMemoryManager::FreeUnused() { |
121 CommandBuffer* cmd_buf = helper_->command_buffer(); | 132 CommandBuffer* cmd_buf = helper_->command_buffer(); |
122 MemoryChunkVector::iterator iter = chunks_.begin(); | 133 MemoryChunkVector::iterator iter = chunks_.begin(); |
123 while (iter != chunks_.end()) { | 134 while (iter != chunks_.end()) { |
124 MemoryChunk* chunk = *iter; | 135 MemoryChunk* chunk = *iter; |
125 chunk->FreeUnused(); | 136 chunk->FreeUnused(); |
126 if (!chunk->InUse()) { | 137 if (!chunk->InUse()) { |
127 cmd_buf->DestroyTransferBuffer(chunk->shm_id()); | 138 cmd_buf->DestroyTransferBuffer(chunk->shm_id()); |
128 allocated_memory_ -= chunk->GetSize(); | 139 allocated_memory_ -= chunk->GetSize(); |
129 iter = chunks_.erase(iter); | 140 iter = chunks_.erase(iter); |
130 } else { | 141 } else { |
131 ++iter; | 142 ++iter; |
132 } | 143 } |
133 } | 144 } |
134 } | 145 } |
135 | 146 |
136 } // namespace gpu | 147 } // namespace gpu |
OLD | NEW |