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 // This file contains the command buffer helper class. | 5 // This file contains the command buffer helper class. |
6 | 6 |
7 #ifndef GPU_COMMAND_BUFFER_CLIENT_CMD_BUFFER_HELPER_H_ | 7 #ifndef GPU_COMMAND_BUFFER_CLIENT_CMD_BUFFER_HELPER_H_ |
8 #define GPU_COMMAND_BUFFER_CLIENT_CMD_BUFFER_HELPER_H_ | 8 #define GPU_COMMAND_BUFFER_CLIENT_CMD_BUFFER_HELPER_H_ |
9 | 9 |
10 #include <string.h> | 10 #include <string.h> |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 offset, | 207 offset, |
208 size, | 208 size, |
209 shared_memory_id, | 209 shared_memory_id, |
210 shared_memory_offset); | 210 shared_memory_offset); |
211 } | 211 } |
212 | 212 |
213 CommandBuffer* command_buffer() const { | 213 CommandBuffer* command_buffer() const { |
214 return command_buffer_; | 214 return command_buffer_; |
215 } | 215 } |
216 | 216 |
217 Buffer get_ring_buffer() const { | |
218 return ring_buffer_; | |
219 } | |
220 | |
221 private: | 217 private: |
222 // Waits until get changes, updating the value of get_. | 218 // Waits until get changes, updating the value of get_. |
223 void WaitForGetChange(); | 219 void WaitForGetChange(); |
224 | 220 |
225 // Returns the number of available entries (they may not be contiguous). | 221 // Returns the number of available entries (they may not be contiguous). |
226 int32 AvailableEntries() { | 222 int32 AvailableEntries() { |
227 return (get_offset() - put_ - 1 + usable_entry_count_) % | 223 return (get_offset() - put_ - 1 + usable_entry_count_) % |
228 usable_entry_count_; | 224 usable_entry_count_; |
229 } | 225 } |
230 | 226 |
231 bool AllocateRingBuffer(); | |
232 | |
233 CommandBuffer* command_buffer_; | 227 CommandBuffer* command_buffer_; |
234 int32 ring_buffer_id_; | |
235 int32 ring_buffer_size_; | |
236 Buffer ring_buffer_; | 228 Buffer ring_buffer_; |
237 CommandBufferEntry* entries_; | 229 CommandBufferEntry *entries_; |
238 int32 total_entry_count_; // the total number of entries | 230 int32 total_entry_count_; // the total number of entries |
239 int32 usable_entry_count_; // the usable number (ie, minus space for jump) | 231 int32 usable_entry_count_; // the usable number (ie, minus space for jump) |
240 int32 token_; | 232 int32 token_; |
241 int32 put_; | 233 int32 put_; |
242 int32 last_put_sent_; | 234 int32 last_put_sent_; |
243 int commands_issued_; | 235 int commands_issued_; |
244 | 236 |
245 // Using C runtime instead of base because this file cannot depend on base. | 237 // Using C runtime instead of base because this file cannot depend on base. |
246 clock_t last_flush_time_; | 238 clock_t last_flush_time_; |
247 | 239 |
248 friend class CommandBufferHelperTest; | 240 friend class CommandBufferHelperTest; |
249 DISALLOW_COPY_AND_ASSIGN(CommandBufferHelper); | 241 DISALLOW_COPY_AND_ASSIGN(CommandBufferHelper); |
250 }; | 242 }; |
251 | 243 |
252 } // namespace gpu | 244 } // namespace gpu |
253 | 245 |
254 #endif // GPU_COMMAND_BUFFER_CLIENT_CMD_BUFFER_HELPER_H_ | 246 #endif // GPU_COMMAND_BUFFER_CLIENT_CMD_BUFFER_HELPER_H_ |
OLD | NEW |