| 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 |
| 217 private: | 221 private: |
| 218 // Waits until get changes, updating the value of get_. | 222 // Waits until get changes, updating the value of get_. |
| 219 void WaitForGetChange(); | 223 void WaitForGetChange(); |
| 220 | 224 |
| 221 // Returns the number of available entries (they may not be contiguous). | 225 // Returns the number of available entries (they may not be contiguous). |
| 222 int32 AvailableEntries() { | 226 int32 AvailableEntries() { |
| 223 return (get_offset() - put_ - 1 + usable_entry_count_) % | 227 return (get_offset() - put_ - 1 + usable_entry_count_) % |
| 224 usable_entry_count_; | 228 usable_entry_count_; |
| 225 } | 229 } |
| 226 | 230 |
| 231 bool AllocateRingBuffer(); |
| 232 |
| 227 CommandBuffer* command_buffer_; | 233 CommandBuffer* command_buffer_; |
| 234 int32 ring_buffer_id_; |
| 235 int32 ring_buffer_size_; |
| 228 Buffer ring_buffer_; | 236 Buffer ring_buffer_; |
| 229 CommandBufferEntry *entries_; | 237 CommandBufferEntry* entries_; |
| 230 int32 total_entry_count_; // the total number of entries | 238 int32 total_entry_count_; // the total number of entries |
| 231 int32 usable_entry_count_; // the usable number (ie, minus space for jump) | 239 int32 usable_entry_count_; // the usable number (ie, minus space for jump) |
| 232 int32 token_; | 240 int32 token_; |
| 233 int32 put_; | 241 int32 put_; |
| 234 int32 last_put_sent_; | 242 int32 last_put_sent_; |
| 235 int commands_issued_; | 243 int commands_issued_; |
| 236 | 244 |
| 237 // Using C runtime instead of base because this file cannot depend on base. | 245 // Using C runtime instead of base because this file cannot depend on base. |
| 238 clock_t last_flush_time_; | 246 clock_t last_flush_time_; |
| 239 | 247 |
| 240 friend class CommandBufferHelperTest; | 248 friend class CommandBufferHelperTest; |
| 241 DISALLOW_COPY_AND_ASSIGN(CommandBufferHelper); | 249 DISALLOW_COPY_AND_ASSIGN(CommandBufferHelper); |
| 242 }; | 250 }; |
| 243 | 251 |
| 244 } // namespace gpu | 252 } // namespace gpu |
| 245 | 253 |
| 246 #endif // GPU_COMMAND_BUFFER_CLIENT_CMD_BUFFER_HELPER_H_ | 254 #endif // GPU_COMMAND_BUFFER_CLIENT_CMD_BUFFER_HELPER_H_ |
| OLD | NEW |