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 defines the GLES2 command buffer commands. | 5 // This file defines the GLES2 command buffer commands. |
6 | 6 |
7 #ifndef GPU_COMMAND_BUFFER_COMMON_GLES2_CMD_FORMAT_H_ | 7 #ifndef GPU_COMMAND_BUFFER_COMMON_GLES2_CMD_FORMAT_H_ |
8 #define GPU_COMMAND_BUFFER_COMMON_GLES2_CMD_FORMAT_H_ | 8 #define GPU_COMMAND_BUFFER_COMMON_GLES2_CMD_FORMAT_H_ |
9 | 9 |
10 | 10 |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 } | 84 } |
85 | 85 |
86 // Returns the total size in bytes of the SizedResult for a given size of | 86 // Returns the total size in bytes of the SizedResult for a given size of |
87 // results. | 87 // results. |
88 static size_t ComputeSizeFromBytes(size_t size_of_result_in_bytes) { | 88 static size_t ComputeSizeFromBytes(size_t size_of_result_in_bytes) { |
89 return size_of_result_in_bytes + sizeof(uint32); // NOLINT | 89 return size_of_result_in_bytes + sizeof(uint32); // NOLINT |
90 } | 90 } |
91 | 91 |
92 // Returns the maximum number of results for a given buffer size. | 92 // Returns the maximum number of results for a given buffer size. |
93 static uint32 ComputeMaxResults(size_t size_of_buffer) { | 93 static uint32 ComputeMaxResults(size_t size_of_buffer) { |
94 return (size_of_buffer - sizeof(uint32)) / sizeof(T); // NOLINT | 94 return (size_of_buffer >= sizeof(uint32)) ? |
| 95 ((size_of_buffer - sizeof(uint32)) / sizeof(T)) : 0; // NOLINT |
95 } | 96 } |
96 | 97 |
97 // Set the size for a given number of results. | 98 // Set the size for a given number of results. |
98 void SetNumResults(size_t num_results) { | 99 void SetNumResults(size_t num_results) { |
99 size = sizeof(T) * num_results; // NOLINT | 100 size = sizeof(T) * num_results; // NOLINT |
100 } | 101 } |
101 | 102 |
102 // Get the number of elements in the result | 103 // Get the number of elements in the result |
103 int32 GetNumResults() const { | 104 int32 GetNumResults() const { |
104 return size / sizeof(T); // NOLINT | 105 return size / sizeof(T); // NOLINT |
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
532 OffsetOf_GetUniformLocationBucket_location_shm_id_not_12); | 533 OffsetOf_GetUniformLocationBucket_location_shm_id_not_12); |
533 COMPILE_ASSERT(offsetof(GetUniformLocationBucket, location_shm_offset) == 16, | 534 COMPILE_ASSERT(offsetof(GetUniformLocationBucket, location_shm_offset) == 16, |
534 OffsetOf_GetUniformLocationBucket_location_shm_offset_not_16); | 535 OffsetOf_GetUniformLocationBucket_location_shm_offset_not_16); |
535 | 536 |
536 #pragma pack(pop) | 537 #pragma pack(pop) |
537 | 538 |
538 } // namespace gles2 | 539 } // namespace gles2 |
539 } // namespace gpu | 540 } // namespace gpu |
540 | 541 |
541 #endif // GPU_COMMAND_BUFFER_COMMON_GLES2_CMD_FORMAT_H_ | 542 #endif // GPU_COMMAND_BUFFER_COMMON_GLES2_CMD_FORMAT_H_ |
OLD | NEW |