| OLD | NEW |
| 1 // Copyright (c) 2011 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 |
| 11 #include <string> | 11 #include <string> |
| 12 |
| 12 #include "../common/types.h" | 13 #include "../common/types.h" |
| 14 #include "gpu/command_buffer/common/gles2_utils_export.h" |
| 13 | 15 |
| 14 namespace gpu { | 16 namespace gpu { |
| 15 namespace gles2 { | 17 namespace gles2 { |
| 16 | 18 |
| 17 // Does a multiply and checks for overflow. If the multiply did not overflow | 19 // Does a multiply and checks for overflow. If the multiply did not overflow |
| 18 // returns true. | 20 // returns true. |
| 19 template <typename T> | 21 template <typename T> |
| 20 inline bool SafeMultiply(T a, T b, T* dst) { | 22 inline bool SafeMultiply(T a, T b, T* dst) { |
| 21 if (b == 0) { | 23 if (b == 0) { |
| 22 *dst = 0; | 24 *dst = 0; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 46 *dst = a + b; | 48 *dst = a + b; |
| 47 return true; | 49 return true; |
| 48 } | 50 } |
| 49 | 51 |
| 50 // A wrapper for SafeAdd to remove the need to cast. | 52 // A wrapper for SafeAdd to remove the need to cast. |
| 51 inline bool SafeAddUint32(uint32 a, uint32 b, uint32* dst) { | 53 inline bool SafeAddUint32(uint32 a, uint32 b, uint32* dst) { |
| 52 return SafeAdd(a, b, dst); | 54 return SafeAdd(a, b, dst); |
| 53 } | 55 } |
| 54 | 56 |
| 55 // Utilties for GLES2 support. | 57 // Utilties for GLES2 support. |
| 56 class GLES2Util { | 58 class GLES2_UTILS_EXPORT GLES2Util { |
| 57 public: | 59 public: |
| 58 static const int kNumFaces = 6; | 60 static const int kNumFaces = 6; |
| 59 | 61 |
| 60 struct EnumToString { | 62 struct EnumToString { |
| 61 uint32 value; | 63 uint32 value; |
| 62 const char* name; | 64 const char* name; |
| 63 }; | 65 }; |
| 64 | 66 |
| 65 GLES2Util() | 67 GLES2Util() |
| 66 : num_compressed_texture_formats_(0), | 68 : num_compressed_texture_formats_(0), |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 | 132 |
| 131 int num_compressed_texture_formats_; | 133 int num_compressed_texture_formats_; |
| 132 int num_shader_binary_formats_; | 134 int num_shader_binary_formats_; |
| 133 }; | 135 }; |
| 134 | 136 |
| 135 } // namespace gles2 | 137 } // namespace gles2 |
| 136 } // namespace gpu | 138 } // namespace gpu |
| 137 | 139 |
| 138 #endif // GPU_COMMAND_BUFFER_COMMON_GLES2_CMD_UTILS_H_ | 140 #endif // GPU_COMMAND_BUFFER_COMMON_GLES2_CMD_UTILS_H_ |
| 139 | 141 |
| OLD | NEW |