Chromium Code Reviews| 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 <list> | |
|
piman
2014/02/07 22:58:20
nit: you don't need this.
| |
| 10 #include <string.h> | 11 #include <string.h> |
| 11 #include <time.h> | 12 #include <time.h> |
| 12 | 13 |
| 14 #include "base/bind.h" | |
|
piman
2014/02/07 22:58:20
nit: or this
| |
| 13 #include "gpu/command_buffer/common/cmd_buffer_common.h" | 15 #include "gpu/command_buffer/common/cmd_buffer_common.h" |
| 14 #include "gpu/command_buffer/common/command_buffer.h" | 16 #include "gpu/command_buffer/common/command_buffer.h" |
| 15 #include "gpu/command_buffer/common/constants.h" | 17 #include "gpu/command_buffer/common/constants.h" |
| 16 #include "gpu/gpu_export.h" | 18 #include "gpu/gpu_export.h" |
| 17 | 19 |
| 18 namespace gpu { | 20 namespace gpu { |
| 19 | 21 |
| 20 // Command buffer helper class. This class simplifies ring buffer management: | 22 // Command buffer helper class. This class simplifies ring buffer management: |
| 21 // it will allocate the buffer, give it to the buffer interface, and let the | 23 // it will allocate the buffer, give it to the buffer interface, and let the |
| 22 // user add commands to it, while taking care of the synchronization (put and | 24 // user add commands to it, while taking care of the synchronization (put and |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 76 | 78 |
| 77 // Inserts a new token into the command buffer. This token either has a value | 79 // Inserts a new token into the command buffer. This token either has a value |
| 78 // different from previously inserted tokens, or ensures that previously | 80 // different from previously inserted tokens, or ensures that previously |
| 79 // inserted tokens with that value have already passed through the command | 81 // inserted tokens with that value have already passed through the command |
| 80 // stream. | 82 // stream. |
| 81 // Returns: | 83 // Returns: |
| 82 // the value of the new token or -1 if the command buffer reader has | 84 // the value of the new token or -1 if the command buffer reader has |
| 83 // shutdown. | 85 // shutdown. |
| 84 int32 InsertToken(); | 86 int32 InsertToken(); |
| 85 | 87 |
| 88 // Returns true if the token has passed. | |
| 89 // Parameters: | |
| 90 // the value of the token to check whether it has passed | |
| 91 bool HasTokenPassed(int32 token) const { | |
| 92 if (token > token_) | |
| 93 return true; // we wrapped | |
| 94 return last_token_read() >= token; | |
| 95 } | |
| 96 | |
| 86 // Waits until the token of a particular value has passed through the command | 97 // 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). | 98 // stream (i.e. commands inserted before that token have been executed). |
| 88 // NOTE: This will call Flush if it needs to block. | 99 // NOTE: This will call Flush if it needs to block. |
| 89 // Parameters: | 100 // Parameters: |
| 90 // the value of the token to wait for. | 101 // the value of the token to wait for. |
| 91 void WaitForToken(int32 token); | 102 void WaitForToken(int32 token); |
| 92 | 103 |
| 93 // Called prior to each command being issued. Waits for a certain amount of | 104 // Called prior to each command being issued. Waits for a certain amount of |
| 94 // space to be available. Returns address of space. | 105 // space to be available. Returns address of space. |
| 95 CommandBufferEntry* GetSpace(uint32 entries); | 106 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. | 272 // Using C runtime instead of base because this file cannot depend on base. |
| 262 clock_t last_flush_time_; | 273 clock_t last_flush_time_; |
| 263 | 274 |
| 264 friend class CommandBufferHelperTest; | 275 friend class CommandBufferHelperTest; |
| 265 DISALLOW_COPY_AND_ASSIGN(CommandBufferHelper); | 276 DISALLOW_COPY_AND_ASSIGN(CommandBufferHelper); |
| 266 }; | 277 }; |
| 267 | 278 |
| 268 } // namespace gpu | 279 } // namespace gpu |
| 269 | 280 |
| 270 #endif // GPU_COMMAND_BUFFER_CLIENT_CMD_BUFFER_HELPER_H_ | 281 #endif // GPU_COMMAND_BUFFER_CLIENT_CMD_BUFFER_HELPER_H_ |
| OLD | NEW |