| 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 "base/synchronization/lock.h" |
| 13 #include "base/time/time.h" | 14 #include "base/time/time.h" |
| 14 #include "gpu/command_buffer/common/cmd_buffer_common.h" | 15 #include "gpu/command_buffer/common/cmd_buffer_common.h" |
| 15 #include "gpu/command_buffer/common/command_buffer.h" | 16 #include "gpu/command_buffer/common/command_buffer.h" |
| 16 #include "gpu/command_buffer/common/constants.h" | 17 #include "gpu/command_buffer/common/constants.h" |
| 17 #include "gpu/gpu_export.h" | 18 #include "gpu/gpu_export.h" |
| 18 | 19 |
| 19 namespace gpu { | 20 namespace gpu { |
| 20 | 21 |
| 21 #if !defined(OS_ANDROID) | 22 #if !defined(OS_ANDROID) |
| 22 #define CMD_HELPER_PERIODIC_FLUSH_CHECK | 23 #define CMD_HELPER_PERIODIC_FLUSH_CHECK |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 // Asynchronously flushes the commands, setting the put pointer to let the | 65 // Asynchronously flushes the commands, setting the put pointer to let the |
| 65 // buffer interface know that new commands have been added. After a flush | 66 // buffer interface know that new commands have been added. After a flush |
| 66 // returns, the command buffer service is aware of all pending commands. | 67 // returns, the command buffer service is aware of all pending commands. |
| 67 void Flush(); | 68 void Flush(); |
| 68 | 69 |
| 69 // Waits until all the commands have been executed. Returns whether it | 70 // Waits until all the commands have been executed. Returns whether it |
| 70 // was successful. The function will fail if the command buffer service has | 71 // was successful. The function will fail if the command buffer service has |
| 71 // disconnected. | 72 // disconnected. |
| 72 bool Finish(); | 73 bool Finish(); |
| 73 | 74 |
| 75 void SetSafeFlushPoint(); |
| 76 void SafeFlush(); |
| 77 |
| 74 // Waits until a given number of available entries are available. | 78 // Waits until a given number of available entries are available. |
| 75 // Parameters: | 79 // Parameters: |
| 76 // count: number of entries needed. This value must be at most | 80 // count: number of entries needed. This value must be at most |
| 77 // the size of the buffer minus one. | 81 // the size of the buffer minus one. |
| 78 void WaitForAvailableEntries(int32 count); | 82 void WaitForAvailableEntries(int32 count); |
| 79 | 83 |
| 80 // Inserts a new token into the command buffer. This token either has a value | 84 // Inserts a new token into the command buffer. This token either has a value |
| 81 // different from previously inserted tokens, or ensures that previously | 85 // different from previously inserted tokens, or ensures that previously |
| 82 // inserted tokens with that value have already passed through the command | 86 // inserted tokens with that value have already passed through the command |
| 83 // stream. | 87 // stream. |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 313 #endif | 317 #endif |
| 314 | 318 |
| 315 CommandBuffer* command_buffer_; | 319 CommandBuffer* command_buffer_; |
| 316 int32 ring_buffer_id_; | 320 int32 ring_buffer_id_; |
| 317 int32 ring_buffer_size_; | 321 int32 ring_buffer_size_; |
| 318 scoped_refptr<gpu::Buffer> ring_buffer_; | 322 scoped_refptr<gpu::Buffer> ring_buffer_; |
| 319 CommandBufferEntry* entries_; | 323 CommandBufferEntry* entries_; |
| 320 int32 total_entry_count_; // the total number of entries | 324 int32 total_entry_count_; // the total number of entries |
| 321 int32 immediate_entry_count_; | 325 int32 immediate_entry_count_; |
| 322 int32 token_; | 326 int32 token_; |
| 327 base::Lock flush_lock_; |
| 323 int32 put_; | 328 int32 put_; |
| 324 int32 last_put_sent_; | 329 int32 last_put_sent_; |
| 330 int32 safe_put_point_; |
| 325 | 331 |
| 326 #if defined(CMD_HELPER_PERIODIC_FLUSH_CHECK) | 332 #if defined(CMD_HELPER_PERIODIC_FLUSH_CHECK) |
| 327 int commands_issued_; | 333 int commands_issued_; |
| 328 #endif | 334 #endif |
| 329 | 335 |
| 330 bool usable_; | 336 bool usable_; |
| 331 bool context_lost_; | 337 bool context_lost_; |
| 332 bool flush_automatically_; | 338 bool flush_automatically_; |
| 333 | 339 |
| 334 base::TimeTicks last_flush_time_; | 340 base::TimeTicks last_flush_time_; |
| 335 | 341 |
| 336 // Incremented every time the helper flushes the command buffer. | 342 // Incremented every time the helper flushes the command buffer. |
| 337 // Can be used to track when prior commands have been flushed. | 343 // Can be used to track when prior commands have been flushed. |
| 338 uint32 flush_generation_; | 344 uint32 flush_generation_; |
| 339 | 345 |
| 340 friend class CommandBufferHelperTest; | 346 friend class CommandBufferHelperTest; |
| 341 DISALLOW_COPY_AND_ASSIGN(CommandBufferHelper); | 347 DISALLOW_COPY_AND_ASSIGN(CommandBufferHelper); |
| 342 }; | 348 }; |
| 343 | 349 |
| 344 } // namespace gpu | 350 } // namespace gpu |
| 345 | 351 |
| 346 #endif // GPU_COMMAND_BUFFER_CLIENT_CMD_BUFFER_HELPER_H_ | 352 #endif // GPU_COMMAND_BUFFER_CLIENT_CMD_BUFFER_HELPER_H_ |
| OLD | NEW |