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> |
11 #include <time.h> | 11 #include <time.h> |
12 | 12 |
13 #include "../../gpu_export.h" | |
14 #include "../common/logging.h" | 13 #include "../common/logging.h" |
15 #include "../common/constants.h" | 14 #include "../common/constants.h" |
16 #include "../common/cmd_buffer_common.h" | 15 #include "../common/cmd_buffer_common.h" |
17 #include "../common/command_buffer.h" | 16 #include "../common/command_buffer.h" |
18 | 17 |
19 namespace gpu { | 18 namespace gpu { |
20 | 19 |
21 // Command buffer helper class. This class simplifies ring buffer management: | 20 // Command buffer helper class. This class simplifies ring buffer management: |
22 // it will allocate the buffer, give it to the buffer interface, and let the | 21 // it will allocate the buffer, give it to the buffer interface, and let the |
23 // user add commands to it, while taking care of the synchronization (put and | 22 // user add commands to it, while taking care of the synchronization (put and |
24 // get). It also provides a way to ensure commands have been executed, through | 23 // get). It also provides a way to ensure commands have been executed, through |
25 // the token mechanism: | 24 // the token mechanism: |
26 // | 25 // |
27 // helper.AddCommand(...); | 26 // helper.AddCommand(...); |
28 // helper.AddCommand(...); | 27 // helper.AddCommand(...); |
29 // int32 token = helper.InsertToken(); | 28 // int32 token = helper.InsertToken(); |
30 // helper.AddCommand(...); | 29 // helper.AddCommand(...); |
31 // helper.AddCommand(...); | 30 // helper.AddCommand(...); |
32 // [...] | 31 // [...] |
33 // | 32 // |
34 // helper.WaitForToken(token); // this doesn't return until the first two | 33 // helper.WaitForToken(token); // this doesn't return until the first two |
35 // // commands have been executed. | 34 // // commands have been executed. |
36 class GPU_EXPORT CommandBufferHelper { | 35 class CommandBufferHelper { |
37 public: | 36 public: |
38 explicit CommandBufferHelper(CommandBuffer* command_buffer); | 37 explicit CommandBufferHelper(CommandBuffer* command_buffer); |
39 virtual ~CommandBufferHelper(); | 38 virtual ~CommandBufferHelper(); |
40 | 39 |
41 // Initializes the CommandBufferHelper. | 40 // Initializes the CommandBufferHelper. |
42 // Parameters: | 41 // Parameters: |
43 // ring_buffer_size: The size of the ring buffer portion of the command | 42 // ring_buffer_size: The size of the ring buffer portion of the command |
44 // buffer. | 43 // buffer. |
45 bool Initialize(int32 ring_buffer_size); | 44 bool Initialize(int32 ring_buffer_size); |
46 | 45 |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 // Using C runtime instead of base because this file cannot depend on base. | 284 // Using C runtime instead of base because this file cannot depend on base. |
286 clock_t last_flush_time_; | 285 clock_t last_flush_time_; |
287 | 286 |
288 friend class CommandBufferHelperTest; | 287 friend class CommandBufferHelperTest; |
289 DISALLOW_COPY_AND_ASSIGN(CommandBufferHelper); | 288 DISALLOW_COPY_AND_ASSIGN(CommandBufferHelper); |
290 }; | 289 }; |
291 | 290 |
292 } // namespace gpu | 291 } // namespace gpu |
293 | 292 |
294 #endif // GPU_COMMAND_BUFFER_CLIENT_CMD_BUFFER_HELPER_H_ | 293 #endif // GPU_COMMAND_BUFFER_CLIENT_CMD_BUFFER_HELPER_H_ |
OLD | NEW |