* @brief Get the total number of texels in an image. * * This function validates that the total size would fit in a size_t and returns * 0 if it does not. * * @param texels_x Number of texels in the X axis. * @param texels_y Number of texels in the Y axis. * @param texels_z Number of texels in the Z axis. * * @return The number of texels in the image, or zero if total size would not
| 148 | * fit into a size_t. |
| 149 | */ |
| 150 | static size_t get_texels_count( |
| 151 | size_t texels_x, |
| 152 | size_t texels_y, |
| 153 | size_t texels_z |
| 154 | ) { |
| 155 | bool overflow { false }; |
| 156 | |
| 157 | // Compute texel count |
| 158 | size_t texels_count = astc::mul_safe(texels_x, texels_y, overflow); |
| 159 | texels_count = astc::mul_safe(texels_count, texels_z, overflow); |
| 160 | |
| 161 | if (overflow) |
| 162 | { |
| 163 | return 0; |
| 164 | } |
| 165 | |
| 166 | return texels_count; |
| 167 | } |
| 168 | |
| 169 | /** |
| 170 | * @brief Get the total number of blocks in an image. |
no test coverage detected