OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 | 76 |
77 // Inserts a new token into the command buffer. This token either has a value | 77 // Inserts a new token into the command buffer. This token either has a value |
78 // different from previously inserted tokens, or ensures that previously | 78 // different from previously inserted tokens, or ensures that previously |
79 // inserted tokens with that value have already passed through the command | 79 // inserted tokens with that value have already passed through the command |
80 // stream. | 80 // stream. |
81 // Returns: | 81 // Returns: |
82 // the value of the new token or -1 if the command buffer reader has | 82 // the value of the new token or -1 if the command buffer reader has |
83 // shutdown. | 83 // shutdown. |
84 int32 InsertToken(); | 84 int32 InsertToken(); |
85 | 85 |
| 86 // Returns true if the token has passed. |
| 87 // Parameters: |
| 88 // the value of the token to check whether it has passed |
| 89 bool HasTokenPassed(int32 token) const { |
| 90 if (token > token_) |
| 91 return true; // we wrapped |
| 92 return last_token_read() >= token; |
| 93 } |
| 94 |
86 // Waits until the token of a particular value has passed through the command | 95 // Waits until the token of a particular value has passed through the command |
87 // stream (i.e. commands inserted before that token have been executed). | 96 // stream (i.e. commands inserted before that token have been executed). |
88 // NOTE: This will call Flush if it needs to block. | 97 // NOTE: This will call Flush if it needs to block. |
89 // Parameters: | 98 // Parameters: |
90 // the value of the token to wait for. | 99 // the value of the token to wait for. |
91 void WaitForToken(int32 token); | 100 void WaitForToken(int32 token); |
92 | 101 |
93 // Called prior to each command being issued. Waits for a certain amount of | 102 // Called prior to each command being issued. Waits for a certain amount of |
94 // space to be available. Returns address of space. | 103 // space to be available. Returns address of space. |
95 CommandBufferEntry* GetSpace(uint32 entries); | 104 CommandBufferEntry* GetSpace(uint32 entries); |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 // Using C runtime instead of base because this file cannot depend on base. | 270 // Using C runtime instead of base because this file cannot depend on base. |
262 clock_t last_flush_time_; | 271 clock_t last_flush_time_; |
263 | 272 |
264 friend class CommandBufferHelperTest; | 273 friend class CommandBufferHelperTest; |
265 DISALLOW_COPY_AND_ASSIGN(CommandBufferHelper); | 274 DISALLOW_COPY_AND_ASSIGN(CommandBufferHelper); |
266 }; | 275 }; |
267 | 276 |
268 } // namespace gpu | 277 } // namespace gpu |
269 | 278 |
270 #endif // GPU_COMMAND_BUFFER_CLIENT_CMD_BUFFER_HELPER_H_ | 279 #endif // GPU_COMMAND_BUFFER_CLIENT_CMD_BUFFER_HELPER_H_ |
OLD | NEW |