| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #ifndef GPU_COMMAND_BUFFER_COMMON_SYNC_TOKEN_H_ | 5 #ifndef GPU_COMMAND_BUFFER_COMMON_SYNC_TOKEN_H_ |
| 6 #define GPU_COMMAND_BUFFER_COMMON_SYNC_TOKEN_H_ | 6 #define GPU_COMMAND_BUFFER_COMMON_SYNC_TOKEN_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 #include <string.h> | 9 #include <string.h> |
| 10 | 10 |
| 11 #include <tuple> |
| 12 |
| 11 #include "gpu/command_buffer/common/command_buffer_id.h" | 13 #include "gpu/command_buffer/common/command_buffer_id.h" |
| 12 #include "gpu/command_buffer/common/constants.h" | 14 #include "gpu/command_buffer/common/constants.h" |
| 13 #include "gpu/gpu_export.h" | 15 #include "gpu/gpu_export.h" |
| 14 | 16 |
| 15 // From glextchromium.h. | 17 // From glextchromium.h. |
| 16 #ifndef GL_SYNC_TOKEN_SIZE_CHROMIUM | 18 #ifndef GL_SYNC_TOKEN_SIZE_CHROMIUM |
| 17 #define GL_SYNC_TOKEN_SIZE_CHROMIUM 24 | 19 #define GL_SYNC_TOKEN_SIZE_CHROMIUM 24 |
| 18 #endif | 20 #endif |
| 19 | 21 |
| 20 namespace gpu { | 22 namespace gpu { |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 CommandBufferId command_buffer_id() const { return command_buffer_id_; } | 72 CommandBufferId command_buffer_id() const { return command_buffer_id_; } |
| 71 uint64_t release_count() const { return release_count_; } | 73 uint64_t release_count() const { return release_count_; } |
| 72 | 74 |
| 73 // This extra data field can be used by command buffers to add extra | 75 // This extra data field can be used by command buffers to add extra |
| 74 // information to identify unverified sync tokens. The current purpose | 76 // information to identify unverified sync tokens. The current purpose |
| 75 // of this field is only for unverified sync tokens which only exist within | 77 // of this field is only for unverified sync tokens which only exist within |
| 76 // the same process so this information will not survive cross-process IPCs. | 78 // the same process so this information will not survive cross-process IPCs. |
| 77 int32_t extra_data_field() const { return extra_data_field_; } | 79 int32_t extra_data_field() const { return extra_data_field_; } |
| 78 | 80 |
| 79 bool operator<(const SyncToken& other) const { | 81 bool operator<(const SyncToken& other) const { |
| 80 // TODO(dyen): Once all our compilers support c++11, we can replace this | 82 return std::tie(namespace_id_, command_buffer_id_, release_count_) < |
| 81 // long list of comparisons with std::tie(). | 83 std::tie(other.namespace_id_, other.command_buffer_id_, |
| 82 return (namespace_id_ < other.namespace_id()) || | 84 other.release_count_); |
| 83 ((namespace_id_ == other.namespace_id()) && | |
| 84 ((command_buffer_id_ < other.command_buffer_id()) || | |
| 85 ((command_buffer_id_ == other.command_buffer_id()) && | |
| 86 (release_count_ < other.release_count())))); | |
| 87 } | 85 } |
| 88 | 86 |
| 89 bool operator==(const SyncToken& other) const { | 87 bool operator==(const SyncToken& other) const { |
| 90 return verified_flush_ == other.verified_flush() && | 88 return verified_flush_ == other.verified_flush() && |
| 91 namespace_id_ == other.namespace_id() && | 89 namespace_id_ == other.namespace_id() && |
| 92 extra_data_field_ == other.extra_data_field() && | 90 extra_data_field_ == other.extra_data_field() && |
| 93 command_buffer_id_ == other.command_buffer_id() && | 91 command_buffer_id_ == other.command_buffer_id() && |
| 94 release_count_ == other.release_count(); | 92 release_count_ == other.release_count(); |
| 95 } | 93 } |
| 96 | 94 |
| 97 bool operator!=(const SyncToken& other) const { return !(*this == other); } | 95 bool operator!=(const SyncToken& other) const { return !(*this == other); } |
| 98 | 96 |
| 99 private: | 97 private: |
| 100 bool verified_flush_; | 98 bool verified_flush_; |
| 101 CommandBufferNamespace namespace_id_; | 99 CommandBufferNamespace namespace_id_; |
| 102 int32_t extra_data_field_; | 100 int32_t extra_data_field_; |
| 103 CommandBufferId command_buffer_id_; | 101 CommandBufferId command_buffer_id_; |
| 104 uint64_t release_count_; | 102 uint64_t release_count_; |
| 105 }; | 103 }; |
| 106 | 104 |
| 107 static_assert(sizeof(SyncToken) <= GL_SYNC_TOKEN_SIZE_CHROMIUM, | 105 static_assert(sizeof(SyncToken) <= GL_SYNC_TOKEN_SIZE_CHROMIUM, |
| 108 "SyncToken size must not exceed GL_SYNC_TOKEN_SIZE_CHROMIUM"); | 106 "SyncToken size must not exceed GL_SYNC_TOKEN_SIZE_CHROMIUM"); |
| 109 | 107 |
| 110 } // namespace gpu | 108 } // namespace gpu |
| 111 | 109 |
| 112 #endif // GPU_COMMAND_BUFFER_COMMON_SYNC_TOKEN_H_ | 110 #endif // GPU_COMMAND_BUFFER_COMMON_SYNC_TOKEN_H_ |
| OLD | NEW |