| OLD | NEW |
| 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 // 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 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 shared_memory_id, | 195 shared_memory_id, |
| 196 shared_memory_offset); | 196 shared_memory_offset); |
| 197 } | 197 } |
| 198 | 198 |
| 199 private: | 199 private: |
| 200 // Waits until get changes, updating the value of get_. | 200 // Waits until get changes, updating the value of get_. |
| 201 void WaitForGetChange(); | 201 void WaitForGetChange(); |
| 202 | 202 |
| 203 // Returns the number of available entries (they may not be contiguous). | 203 // Returns the number of available entries (they may not be contiguous). |
| 204 int32 AvailableEntries() { | 204 int32 AvailableEntries() { |
| 205 return (get_ - put_ - 1 + entry_count_) % entry_count_; | 205 return (get_ - put_ - 1 + usable_entry_count_) % usable_entry_count_; |
| 206 } | 206 } |
| 207 | 207 |
| 208 // Synchronize with current service state. | 208 // Synchronize with current service state. |
| 209 void SynchronizeState(CommandBuffer::State state); | 209 void SynchronizeState(CommandBuffer::State state); |
| 210 | 210 |
| 211 CommandBuffer* command_buffer_; | 211 CommandBuffer* command_buffer_; |
| 212 Buffer ring_buffer_; | 212 Buffer ring_buffer_; |
| 213 CommandBufferEntry *entries_; | 213 CommandBufferEntry *entries_; |
| 214 int32 entry_count_; | 214 int32 total_entry_count_; // the total number of entries |
| 215 int32 usable_entry_count_; // the usable number (ie, minus space for jump) |
| 215 int32 token_; | 216 int32 token_; |
| 216 int32 last_token_read_; | 217 int32 last_token_read_; |
| 217 int32 get_; | 218 int32 get_; |
| 218 int32 put_; | 219 int32 put_; |
| 219 | 220 |
| 220 friend class CommandBufferHelperTest; | 221 friend class CommandBufferHelperTest; |
| 221 DISALLOW_COPY_AND_ASSIGN(CommandBufferHelper); | 222 DISALLOW_COPY_AND_ASSIGN(CommandBufferHelper); |
| 222 }; | 223 }; |
| 223 | 224 |
| 224 } // namespace gpu | 225 } // namespace gpu |
| 225 | 226 |
| 226 #endif // GPU_COMMAND_BUFFER_CLIENT_CMD_BUFFER_HELPER_H_ | 227 #endif // GPU_COMMAND_BUFFER_CLIENT_CMD_BUFFER_HELPER_H_ |
| OLD | NEW |