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 <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 |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 for (size_t ii = 0; ii < chunks_.size(); ++ii) { | 81 for (size_t ii = 0; ii < chunks_.size(); ++ii) { |
82 MemoryChunk* chunk = chunks_[ii]; | 82 MemoryChunk* chunk = chunks_[ii]; |
83 if (chunk->IsInChunk(pointer)) { | 83 if (chunk->IsInChunk(pointer)) { |
84 chunk->FreePendingToken(pointer, token); | 84 chunk->FreePendingToken(pointer, token); |
85 return; | 85 return; |
86 } | 86 } |
87 } | 87 } |
88 GPU_NOTREACHED(); | 88 GPU_NOTREACHED(); |
89 } | 89 } |
90 | 90 |
| 91 void MappedMemoryManager::FreeUnused() { |
| 92 CommandBuffer* cmd_buf = helper_->command_buffer(); |
| 93 MemoryChunkVector::iterator iter = chunks_.begin(); |
| 94 while (iter != chunks_.end()) { |
| 95 MemoryChunk* chunk = *iter; |
| 96 chunk->FreeUnused(); |
| 97 if (!chunk->InUse()) { |
| 98 cmd_buf->DestroyTransferBuffer(chunk->shm_id()); |
| 99 iter = chunks_.erase(iter); |
| 100 } else { |
| 101 ++iter; |
| 102 } |
| 103 } |
| 104 } |
| 105 |
91 } // namespace gpu | 106 } // namespace gpu |
92 | 107 |
93 | 108 |
94 | 109 |
OLD | NEW |