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 #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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 DISALLOW_COPY_AND_ASSIGN(MemoryChunk); | 103 DISALLOW_COPY_AND_ASSIGN(MemoryChunk); |
104 }; | 104 }; |
105 | 105 |
106 // Manages MemoryChucks. | 106 // Manages MemoryChucks. |
107 class MappedMemoryManager { | 107 class MappedMemoryManager { |
108 public: | 108 public: |
109 explicit MappedMemoryManager(CommandBufferHelper* helper); | 109 explicit MappedMemoryManager(CommandBufferHelper* helper); |
110 | 110 |
111 ~MappedMemoryManager(); | 111 ~MappedMemoryManager(); |
112 | 112 |
| 113 unsigned int chunk_size_multiple() const { |
| 114 return chunk_size_multiple_; |
| 115 } |
| 116 |
| 117 void set_chunk_size_multiple(unsigned int multiple) { |
| 118 chunk_size_multiple_ = multiple; |
| 119 } |
| 120 |
113 // Allocates a block of memory | 121 // Allocates a block of memory |
114 // Parameters: | 122 // Parameters: |
115 // size: size of memory to allocate. | 123 // size: size of memory to allocate. |
116 // shm_id: pointer to variable to receive the shared memory id. | 124 // shm_id: pointer to variable to receive the shared memory id. |
117 // shm_offset: pointer to variable to receive the shared memory offset. | 125 // shm_offset: pointer to variable to receive the shared memory offset. |
118 // Returns: | 126 // Returns: |
119 // pointer to allocated block of memory. NULL if failure. | 127 // pointer to allocated block of memory. NULL if failure. |
120 void* Alloc( | 128 void* Alloc( |
121 unsigned int size, int32* shm_id, unsigned int* shm_offset); | 129 unsigned int size, int32* shm_id, unsigned int* shm_offset); |
122 | 130 |
(...skipping 15 matching lines...) Expand all Loading... |
138 void FreeUnused(); | 146 void FreeUnused(); |
139 | 147 |
140 // Used for testing | 148 // Used for testing |
141 size_t num_chunks() { | 149 size_t num_chunks() { |
142 return chunks_.size(); | 150 return chunks_.size(); |
143 } | 151 } |
144 | 152 |
145 private: | 153 private: |
146 typedef std::vector<MemoryChunk*> MemoryChunkVector; | 154 typedef std::vector<MemoryChunk*> MemoryChunkVector; |
147 | 155 |
| 156 // size a chunk is rounded up to. |
| 157 unsigned int chunk_size_multiple_; |
148 CommandBufferHelper* helper_; | 158 CommandBufferHelper* helper_; |
149 MemoryChunkVector chunks_; | 159 MemoryChunkVector chunks_; |
150 | 160 |
151 DISALLOW_COPY_AND_ASSIGN(MappedMemoryManager); | 161 DISALLOW_COPY_AND_ASSIGN(MappedMemoryManager); |
152 }; | 162 }; |
153 | 163 |
154 } // namespace gpu | 164 } // namespace gpu |
155 | 165 |
156 #endif // GPU_COMMAND_BUFFER_CLIENT_MAPPED_MEMORY_H_ | 166 #endif // GPU_COMMAND_BUFFER_CLIENT_MAPPED_MEMORY_H_ |
157 | 167 |
OLD | NEW |