| 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 "gpu/command_buffer/common/logging.h" | 10 #include "gpu/command_buffer/common/logging.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 // helper.AddCommand(...); | 24 // helper.AddCommand(...); |
| 25 // int32 token = helper.InsertToken(); | 25 // int32 token = helper.InsertToken(); |
| 26 // helper.AddCommand(...); | 26 // helper.AddCommand(...); |
| 27 // helper.AddCommand(...); | 27 // helper.AddCommand(...); |
| 28 // [...] | 28 // [...] |
| 29 // | 29 // |
| 30 // helper.WaitForToken(token); // this doesn't return until the first two | 30 // helper.WaitForToken(token); // this doesn't return until the first two |
| 31 // // commands have been executed. | 31 // // commands have been executed. |
| 32 class CommandBufferHelper { | 32 class CommandBufferHelper { |
| 33 public: | 33 public: |
| 34 explicit CommandBufferHelper(gpu::CommandBuffer* command_buffer); | 34 explicit CommandBufferHelper(CommandBuffer* command_buffer); |
| 35 virtual ~CommandBufferHelper(); | 35 virtual ~CommandBufferHelper(); |
| 36 | 36 |
| 37 bool Initialize(); | 37 bool Initialize(); |
| 38 | 38 |
| 39 // Flushes the commands, setting the put pointer to let the buffer interface | 39 // Flushes the commands, setting the put pointer to let the buffer interface |
| 40 // know that new commands have been added. After a flush returns, the command | 40 // know that new commands have been added. After a flush returns, the command |
| 41 // buffer service is aware of all pending commands and it is guaranteed to | 41 // buffer service is aware of all pending commands and it is guaranteed to |
| 42 // have made some progress in processing them. Returns whether the flush was | 42 // have made some progress in processing them. Returns whether the flush was |
| 43 // successful. The flush will fail if the command buffer service has | 43 // successful. The flush will fail if the command buffer service has |
| 44 // disconnected. | 44 // disconnected. |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 | 163 |
| 164 private: | 164 private: |
| 165 // Waits until get changes, updating the value of get_. | 165 // Waits until get changes, updating the value of get_. |
| 166 void WaitForGetChange(); | 166 void WaitForGetChange(); |
| 167 | 167 |
| 168 // Returns the number of available entries (they may not be contiguous). | 168 // Returns the number of available entries (they may not be contiguous). |
| 169 int32 AvailableEntries() { | 169 int32 AvailableEntries() { |
| 170 return (get_ - put_ - 1 + entry_count_) % entry_count_; | 170 return (get_ - put_ - 1 + entry_count_) % entry_count_; |
| 171 } | 171 } |
| 172 | 172 |
| 173 gpu::CommandBuffer* command_buffer_; | 173 CommandBuffer* command_buffer_; |
| 174 ::base::SharedMemory* ring_buffer_; | 174 Buffer ring_buffer_; |
| 175 CommandBufferEntry *entries_; | 175 CommandBufferEntry *entries_; |
| 176 int32 entry_count_; | 176 int32 entry_count_; |
| 177 int32 token_; | 177 int32 token_; |
| 178 int32 last_token_read_; | 178 int32 last_token_read_; |
| 179 int32 get_; | 179 int32 get_; |
| 180 int32 put_; | 180 int32 put_; |
| 181 | 181 |
| 182 friend class CommandBufferHelperTest; | 182 friend class CommandBufferHelperTest; |
| 183 DISALLOW_COPY_AND_ASSIGN(CommandBufferHelper); | 183 DISALLOW_COPY_AND_ASSIGN(CommandBufferHelper); |
| 184 }; | 184 }; |
| 185 | 185 |
| 186 } // namespace gpu | 186 } // namespace gpu |
| 187 | 187 |
| 188 #endif // GPU_COMMAND_BUFFER_CLIENT_CMD_BUFFER_HELPER_H_ | 188 #endif // GPU_COMMAND_BUFFER_CLIENT_CMD_BUFFER_HELPER_H_ |
| OLD | NEW |