* @memberof ktxTexture * @internal * @ingroup writer * @~English * @brief Creates valid ASTC encoder swizzle from string. * * @return Valid astcenc_swizzle from string */
| 772 | * @return Valid astcenc_swizzle from string |
| 773 | */ |
| 774 | static astcenc_swizzle |
| 775 | astcSwizzle(const ktxAstcParams ¶ms) { |
| 776 | |
| 777 | astcenc_swizzle swizzle{ASTCENC_SWZ_R, ASTCENC_SWZ_G, ASTCENC_SWZ_B, ASTCENC_SWZ_A}; |
| 778 | |
| 779 | std::vector<astcenc_swz*> swizzle_array{&swizzle.r, &swizzle.g, &swizzle.b, &swizzle.a}; |
| 780 | // For historical reasons params.inputSwizzle[0] == '\0' is interpreted to mean no |
| 781 | // swizzle. The docs says it must match the regular expression /^[rgba01]{4}$/. |
| 782 | if (params.inputSwizzle[0] != '\0') { |
| 783 | std::string inputSwizzle(params.inputSwizzle, sizeof(params.inputSwizzle)); |
| 784 | // TODO: Check for RE match. |
| 785 | for (int i = 0; i < 4; i++) { |
| 786 | if (inputSwizzle[i] == 'r') |
| 787 | *swizzle_array[i] = ASTCENC_SWZ_R; |
| 788 | else if (inputSwizzle[i] == 'g') |
| 789 | *swizzle_array[i] = ASTCENC_SWZ_G; |
| 790 | else if (inputSwizzle[i] == 'b') |
| 791 | *swizzle_array[i] = ASTCENC_SWZ_B; |
| 792 | else if (inputSwizzle[i] == 'a') |
| 793 | *swizzle_array[i] = ASTCENC_SWZ_A; |
| 794 | else if (inputSwizzle[i] == '0') |
| 795 | *swizzle_array[i] = ASTCENC_SWZ_0; |
| 796 | else if (inputSwizzle[i] == '1') |
| 797 | *swizzle_array[i] = ASTCENC_SWZ_1; |
| 798 | } |
| 799 | } else if (params.normalMap) { |
| 800 | return {ASTCENC_SWZ_R, ASTCENC_SWZ_R, ASTCENC_SWZ_R, ASTCENC_SWZ_G}; |
| 801 | } |
| 802 | |
| 803 | return swizzle; |
| 804 | } |
| 805 | |
| 806 | static void |
| 807 | astcBlockDimensions(ktx_uint32_t block_size, |
no outgoing calls
no test coverage detected