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 is here so other GLES2 related files can have a common set of | 5 // This file is here so other GLES2 related files can have a common set of |
| 6 // includes where appropriate. | 6 // includes where appropriate. |
| 7 | 7 |
| 8 #ifndef GPU_COMMAND_BUFFER_COMMON_GLES2_CMD_UTILS_H_ | 8 #ifndef GPU_COMMAND_BUFFER_COMMON_GLES2_CMD_UTILS_H_ |
| 9 #define GPU_COMMAND_BUFFER_COMMON_GLES2_CMD_UTILS_H_ | 9 #define GPU_COMMAND_BUFFER_COMMON_GLES2_CMD_UTILS_H_ |
| 10 | 10 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 46 | 46 |
| 47 // Does an add checking for overflow. If there was no overflow returns true. | 47 // Does an add checking for overflow. If there was no overflow returns true. |
| 48 inline bool SafeAddInt32(int32_t a, int32_t b, int32_t* dst) { | 48 inline bool SafeAddInt32(int32_t a, int32_t b, int32_t* dst) { |
| 49 DCHECK(dst); | 49 DCHECK(dst); |
| 50 base::CheckedNumeric<int32_t> checked = a; | 50 base::CheckedNumeric<int32_t> checked = a; |
| 51 checked += b; | 51 checked += b; |
| 52 *dst = checked.ValueOrDefault(0); | 52 *dst = checked.ValueOrDefault(0); |
| 53 return checked.IsValid(); | 53 return checked.IsValid(); |
| 54 } | 54 } |
| 55 | 55 |
| 56 // Returns the address of the first byte after a struct. | |
| 57 template <typename T> | |
| 58 const void* AddressAfterStruct(const T& pod) { | |
| 59 return reinterpret_cast<const uint8_t*>(&pod) + sizeof(pod); | |
| 60 } | |
| 61 | |
| 62 // Returns the address of the frst byte after the struct or NULL if size > | |
|
piman
2016/05/25 23:34:42
nit: frst->first
| |
| 63 // immediate_data_size. | |
| 64 template <typename RETURN_TYPE, typename COMMAND_TYPE> | |
| 65 RETURN_TYPE GetImmediateDataAs(const COMMAND_TYPE& pod, | |
| 66 uint32_t size, | |
| 67 uint32_t immediate_data_size) { | |
| 68 return (size <= immediate_data_size) | |
| 69 ? static_cast<RETURN_TYPE>( | |
| 70 const_cast<void*>(AddressAfterStruct(pod))) | |
| 71 : NULL; | |
| 72 } | |
| 73 | |
| 56 struct GLES2_UTILS_EXPORT PixelStoreParams { | 74 struct GLES2_UTILS_EXPORT PixelStoreParams { |
| 57 PixelStoreParams() | 75 PixelStoreParams() |
| 58 : alignment(4), | 76 : alignment(4), |
| 59 row_length(0), | 77 row_length(0), |
| 60 image_height(0), | 78 image_height(0), |
| 61 skip_pixels(0), | 79 skip_pixels(0), |
| 62 skip_rows(0), | 80 skip_rows(0), |
| 63 skip_images(0) { | 81 skip_images(0) { |
| 64 } | 82 } |
| 65 | 83 |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 298 bool fail_if_major_perf_caveat; | 316 bool fail_if_major_perf_caveat; |
| 299 bool lose_context_when_out_of_memory; | 317 bool lose_context_when_out_of_memory; |
| 300 ContextType context_type; | 318 ContextType context_type; |
| 301 }; | 319 }; |
| 302 | 320 |
| 303 } // namespace gles2 | 321 } // namespace gles2 |
| 304 } // namespace gpu | 322 } // namespace gpu |
| 305 | 323 |
| 306 #endif // GPU_COMMAND_BUFFER_COMMON_GLES2_CMD_UTILS_H_ | 324 #endif // GPU_COMMAND_BUFFER_COMMON_GLES2_CMD_UTILS_H_ |
| 307 | 325 |
| OLD | NEW |