Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(636)

Side by Side Diff: gpu/command_buffer/client/mapped_memory.h

Issue 8369010: Add GLES2Implemention::FreeUnusedSharedMemory (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 #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 <vector> 8 #include <vector>
9 9
10 #include "../common/types.h" 10 #include "../common/types.h"
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 void FreeUnused() { 83 void FreeUnused() {
84 allocator_.FreeUnused(); 84 allocator_.FreeUnused();
85 } 85 }
86 86
87 // Returns true if pointer is in the range of this block. 87 // Returns true if pointer is in the range of this block.
88 bool IsInChunk(void* pointer) const { 88 bool IsInChunk(void* pointer) const {
89 return pointer >= shm_.ptr && 89 return pointer >= shm_.ptr &&
90 pointer < reinterpret_cast<const int8*>(shm_.ptr) + shm_.size; 90 pointer < reinterpret_cast<const int8*>(shm_.ptr) + shm_.size;
91 } 91 }
92 92
93 // Returns true of any memory in this chuck is in use.
94 bool InUse() {
95 return allocator_.InUse();
96 }
97
93 private: 98 private:
94 int32 shm_id_; 99 int32 shm_id_;
95 gpu::Buffer shm_; 100 gpu::Buffer shm_;
96 FencedAllocatorWrapper allocator_; 101 FencedAllocatorWrapper allocator_;
97 102
98 DISALLOW_COPY_AND_ASSIGN(MemoryChunk); 103 DISALLOW_COPY_AND_ASSIGN(MemoryChunk);
99 }; 104 };
100 105
101 // Manages MemoryChucks. 106 // Manages MemoryChucks.
102 class MappedMemoryManager { 107 class MappedMemoryManager {
(...skipping 19 matching lines...) Expand all
122 void Free(void* pointer); 127 void Free(void* pointer);
123 128
124 // Frees a block of memory, pending the passage of a token. That memory won't 129 // Frees a block of memory, pending the passage of a token. That memory won't
125 // be re-allocated until the token has passed through the command stream. 130 // be re-allocated until the token has passed through the command stream.
126 // 131 //
127 // Parameters: 132 // Parameters:
128 // pointer: the pointer to the memory block to free. 133 // pointer: the pointer to the memory block to free.
129 // token: the token value to wait for before re-using the memory. 134 // token: the token value to wait for before re-using the memory.
130 void FreePendingToken(void* pointer, int32 token); 135 void FreePendingToken(void* pointer, int32 token);
131 136
137 // Free Any Shared memory that is not in use.
138 void FreeUnused();
139
140 // Used for testing
141 size_t num_chunks() {
142 return chunks_.size();
143 }
144
132 private: 145 private:
133 typedef std::vector<MemoryChunk*> MemoryChunkVector; 146 typedef std::vector<MemoryChunk*> MemoryChunkVector;
134 147
135 CommandBufferHelper* helper_; 148 CommandBufferHelper* helper_;
136 MemoryChunkVector chunks_; 149 MemoryChunkVector chunks_;
137 150
138 DISALLOW_COPY_AND_ASSIGN(MappedMemoryManager); 151 DISALLOW_COPY_AND_ASSIGN(MappedMemoryManager);
139 }; 152 };
140 153
141 } // namespace gpu 154 } // namespace gpu
142 155
143 #endif // GPU_COMMAND_BUFFER_CLIENT_MAPPED_MEMORY_H_ 156 #endif // GPU_COMMAND_BUFFER_CLIENT_MAPPED_MEMORY_H_
144 157
OLDNEW
« no previous file with comments | « gpu/command_buffer/client/gles2_implementation_unittest.cc ('k') | gpu/command_buffer/client/mapped_memory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698