| 90 | | // Limitation check functions |
| 91 | | bool DXT1() const; |
| 92 | | bool DXT3() const; |
| 93 | | bool DXT5() const; |
| 94 | | bool OpenGLSize() const; |
| 95 | | bool SupportedFormat() const; |
| 96 | | |
| 97 | | // Vertical flipping functions |
| 98 | | void VFlip_DXT1() const; |
| 99 | | void VFlip_DXT3() const; |
| 100 | | void VFlip_DXT5() const; |
| 101 | | |
| 102 | | // Block vertical flipping functions |
| 103 | | void BVF_Color_H2(void * const pBlock) const; // V. flip one color block with its virtual height == 2 |
| 104 | | void BVF_Color_H4(void * const pBlock) const; // V. flip one color block with its virtual height == 4 |
| 105 | | void BVF_Color(void * const pBlock1, void * const pBlock2) const; // V. flip and swap two color blocks, with their virtual height == 4 |
| 106 | | void BVF_Alpha_DXT3_H2(void * const pBlock) const; // V. flip one alpha (DXT3) block with its virtual height == 2 |
| 107 | | void BVF_Alpha_DXT3_H4(void * const pBlock) const; // V. flip one alpha (DXT3) block with its virtual height == 4 |
| 108 | | void BVF_Alpha_DXT3(void * const pBlock1, void * const pBlock2) const; // V. flip and swap two alpha (DXT3) blocks, with their virtual height == 4 |
| 109 | | void BVF_Alpha_DXT5_H2(void * const pBlock) const; // V. flip one alpha (DXT5) block with its virtual height == 2 |
| 110 | | void BVF_Alpha_DXT5_H4(void * const pBlock) const; // V. flip one alpha (DXT5) block with its virtual height == 4 |
| 111 | | void BVF_Alpha_DXT5(void * const pBlock1, void * const pBlock2) const; // V. flip and swap two alpha (DXT5) blocks, with their virtual height == 4 |
| 112 | | |
| 113 | | // Block localization functions |
| 114 | | void * GetBlock(size_t i, size_t j, size_t BlockSize) const; |
| 115 | | |
| 116 | | // mighty const and var |
| 117 | | static const size_t BSIZE_DXT1 = 8; |
| 118 | | static const size_t BSIZE_DXT3 = 16; |
| 119 | | static const size_t BSIZE_DXT5 = 16; |
| 120 | | static const size_t BSIZE_ALPHA_DXT3 = 8; |
| 121 | | static const size_t BSIZE_ALPHA_DXT5 = 8; |
| 122 | | |
| 123 | | const size_t m_Width; |
| 124 | | const size_t m_Height; |
| 125 | | const GLenum m_Format; |
| 126 | | void * const m_pPixels; |
| | 90 | // Limitation check functions |
| | 91 | bool DXT1() const; |
| | 92 | bool DXT3() const; |
| | 93 | bool DXT5() const; |
| | 94 | bool OpenGLSize() const; |
| | 95 | bool SupportedFormat() const; |
| | 96 | |
| | 97 | // Vertical flipping functions |
| | 98 | void VFlip_DXT1() const; |
| | 99 | void VFlip_DXT3() const; |
| | 100 | void VFlip_DXT5() const; |
| | 101 | |
| | 102 | // Block vertical flipping functions |
| | 103 | void BVF_Color_H2(void * const pBlock) const; // V. flip one color block with its virtual height == 2 |
| | 104 | void BVF_Color_H4(void * const pBlock) const; // V. flip one color block with its virtual height == 4 |
| | 105 | void BVF_Color(void * const pBlock1, void * const pBlock2) const; // V. flip and swap two color blocks, with their virtual height == 4 |
| | 106 | void BVF_Alpha_DXT3_H2(void * const pBlock) const; // V. flip one alpha (DXT3) block with its virtual height == 2 |
| | 107 | void BVF_Alpha_DXT3_H4(void * const pBlock) const; // V. flip one alpha (DXT3) block with its virtual height == 4 |
| | 108 | void BVF_Alpha_DXT3(void * const pBlock1, void * const pBlock2) const; // V. flip and swap two alpha (DXT3) blocks, with their virtual height == 4 |
| | 109 | void BVF_Alpha_DXT5_H2(void * const pBlock) const; // V. flip one alpha (DXT5) block with its virtual height == 2 |
| | 110 | void BVF_Alpha_DXT5_H4(void * const pBlock) const; // V. flip one alpha (DXT5) block with its virtual height == 4 |
| | 111 | void BVF_Alpha_DXT5(void * const pBlock1, void * const pBlock2) const; // V. flip and swap two alpha (DXT5) blocks, with their virtual height == 4 |
| | 112 | |
| | 113 | // Block localization functions |
| | 114 | void * GetBlock(size_t i, size_t j, size_t BlockSize) const; |
| | 115 | |
| | 116 | // mighty const and var |
| | 117 | static const size_t BSIZE_DXT1; |
| | 118 | static const size_t BSIZE_DXT3; |
| | 119 | static const size_t BSIZE_DXT5; |
| | 120 | static const size_t BSIZE_ALPHA_DXT3; |
| | 121 | static const size_t BSIZE_ALPHA_DXT5; |
| | 122 | |
| | 123 | const size_t m_Width; |
| | 124 | const size_t m_Height; |
| | 125 | const GLenum m_Format; |
| | 126 | void * const m_pPixels; |
| 188 | | // Swap the "2 colors" header (32bits each header) |
| 189 | | __int32 * const pHdr1 = (__int32 * const) pBlock1; |
| 190 | | __int32 * const pHdr2 = (__int32 * const) pBlock2; |
| 191 | | |
| 192 | | std::swap(* pHdr1, * pHdr2); |
| 193 | | |
| 194 | | // Now swap the pixel values |
| 195 | | __int8 * const pP1 = ((__int8 * const) pBlock1) + 4; |
| 196 | | __int8 * const pP2 = ((__int8 * const) pBlock2) + 4; |
| 197 | | |
| 198 | | std::swap(pP1[0], pP2[3]); |
| 199 | | std::swap(pP1[1], pP2[2]); |
| 200 | | std::swap(pP1[2], pP2[1]); |
| 201 | | std::swap(pP1[3], pP2[0]); |
| | 188 | // Swap the "2 colors" header (32bits each header) |
| | 189 | __int32 * const pHdr1 = (__int32 * const) pBlock1; |
| | 190 | __int32 * const pHdr2 = (__int32 * const) pBlock2; |
| | 191 | |
| | 192 | std::swap(* pHdr1, * pHdr2); |
| | 193 | |
| | 194 | // Now swap the pixel values |
| | 195 | __int8 * const pP1 = ((__int8 * const) pBlock1) + 4; |
| | 196 | __int8 * const pP2 = ((__int8 * const) pBlock2) + 4; |
| | 197 | |
| | 198 | std::swap(pP1[0], pP2[3]); |
| | 199 | std::swap(pP1[1], pP2[2]); |
| | 200 | std::swap(pP1[2], pP2[1]); |
| | 201 | std::swap(pP1[3], pP2[0]); |
| 223 | | // Swap all the pixel values |
| 224 | | __int16 * const pP1 = (__int16 * const) pBlock1; |
| 225 | | __int16 * const pP2 = (__int16 * const) pBlock2; |
| 226 | | |
| 227 | | std::swap(pP1[0], pP2[3]); |
| 228 | | std::swap(pP1[1], pP2[2]); |
| 229 | | std::swap(pP1[2], pP2[1]); |
| 230 | | std::swap(pP1[3], pP2[0]); |
| | 223 | // Swap all the pixel values |
| | 224 | __int16 * const pP1 = (__int16 * const) pBlock1; |
| | 225 | __int16 * const pP2 = (__int16 * const) pBlock2; |
| | 226 | |
| | 227 | std::swap(pP1[0], pP2[3]); |
| | 228 | std::swap(pP1[1], pP2[2]); |
| | 229 | std::swap(pP1[2], pP2[1]); |
| | 230 | std::swap(pP1[3], pP2[0]); |
| 235 | | // Swap the two first row of pixels (kinda tricky with DXT5 unaligned encoding) |
| 236 | | __int32 * const pP = (__int32 * const) (((__int8 * const) pBlock) + 2); |
| 237 | | |
| 238 | | __int32 TmpDWord = (pP[0] & 0xFF000000); |
| 239 | | TmpDWord |= (pP[0] & 0x00000FFF) << 12; |
| 240 | | TmpDWord |= (pP[0] & 0x00FFF000) >> 12; |
| 241 | | pP[0] = TmpDWord; |
| | 235 | // Swap the two first row of pixels (kinda tricky with DXT5 unaligned encoding) |
| | 236 | __int32 * const pP = (__int32 * const) (((__int8 * const) pBlock) + 2); |
| | 237 | |
| | 238 | __int32 TmpDWord = (pP[0] & 0xFF000000); |
| | 239 | TmpDWord |= (pP[0] & 0x00000FFF) << 12; |
| | 240 | TmpDWord |= (pP[0] & 0x00FFF000) >> 12; |
| | 241 | pP[0] = TmpDWord; |
| 250 | | // Swap the the first row of pixels with the last one, then the 2 middle row of pixels (tricky again) |
| 251 | | __int64 * const pB = (__int64 * const) pBlock; |
| 252 | | |
| 253 | | __int64 TmpQWord = (pB[0] & HEX_0x000000000000FFFF); |
| 254 | | TmpQWord |= (pB[0] & HEX_0x000000000FFF0000) << 36; |
| 255 | | TmpQWord |= (pB[0] & HEX_0x000000FFF0000000) << 12; |
| 256 | | TmpQWord |= (pB[0] & HEX_0x000FFF0000000000) >> 12; |
| 257 | | TmpQWord |= (pB[0] & HEX_0xFFF0000000000000) >> 36; |
| 258 | | pB[0] = TmpQWord; |
| | 250 | // Swap the the first row of pixels with the last one, then the 2 middle row of pixels (tricky again) |
| | 251 | __int64 * const pB = (__int64 * const) pBlock; |
| | 252 | |
| | 253 | __int64 TmpQWord = (pB[0] & HEX_0x000000000000FFFF); |
| | 254 | TmpQWord |= (pB[0] & HEX_0x000000000FFF0000) << 36; |
| | 255 | TmpQWord |= (pB[0] & HEX_0x000000FFF0000000) << 12; |
| | 256 | TmpQWord |= (pB[0] & HEX_0x000FFF0000000000) >> 12; |
| | 257 | TmpQWord |= (pB[0] & HEX_0xFFF0000000000000) >> 36; |
| | 258 | pB[0] = TmpQWord; |
| 263 | | // Swap all the pixel values (same trick for DXT5) |
| 264 | | __int64 * const pB1 = (__int64 * const) pBlock1; |
| 265 | | __int64 * const pB2 = (__int64 * const) pBlock2; |
| 266 | | |
| 267 | | __int64 TmpQWord1 = (pB1[0] & HEX_0x000000000000FFFF); |
| 268 | | TmpQWord1 |= (pB1[0] & HEX_0x000000000FFF0000) << 36; |
| 269 | | TmpQWord1 |= (pB1[0] & HEX_0x000000FFF0000000) << 12; |
| 270 | | TmpQWord1 |= (pB1[0] & HEX_0x000FFF0000000000) >> 12; |
| 271 | | TmpQWord1 |= (pB1[0] & HEX_0xFFF0000000000000) >> 36; |
| 272 | | |
| 273 | | __int64 TmpQWord2 = (pB2[0] & HEX_0x000000000000FFFF); |
| 274 | | TmpQWord2 |= (pB2[0] & HEX_0x000000000FFF0000) << 36; |
| 275 | | TmpQWord2 |= (pB2[0] & HEX_0x000000FFF0000000) << 12; |
| 276 | | TmpQWord2 |= (pB2[0] & HEX_0x000FFF0000000000) >> 12; |
| 277 | | TmpQWord2 |= (pB2[0] & HEX_0xFFF0000000000000) >> 36; |
| 278 | | |
| 279 | | pB1[0] = TmpQWord2; |
| 280 | | pB2[0] = TmpQWord1; |
| | 263 | // Swap all the pixel values (same trick for DXT5) |
| | 264 | __int64 * const pB1 = (__int64 * const) pBlock1; |
| | 265 | __int64 * const pB2 = (__int64 * const) pBlock2; |
| | 266 | |
| | 267 | __int64 TmpQWord1 = (pB1[0] & HEX_0x000000000000FFFF); |
| | 268 | TmpQWord1 |= (pB1[0] & HEX_0x000000000FFF0000) << 36; |
| | 269 | TmpQWord1 |= (pB1[0] & HEX_0x000000FFF0000000) << 12; |
| | 270 | TmpQWord1 |= (pB1[0] & HEX_0x000FFF0000000000) >> 12; |
| | 271 | TmpQWord1 |= (pB1[0] & HEX_0xFFF0000000000000) >> 36; |
| | 272 | |
| | 273 | __int64 TmpQWord2 = (pB2[0] & HEX_0x000000000000FFFF); |
| | 274 | TmpQWord2 |= (pB2[0] & HEX_0x000000000FFF0000) << 36; |
| | 275 | TmpQWord2 |= (pB2[0] & HEX_0x000000FFF0000000) << 12; |
| | 276 | TmpQWord2 |= (pB2[0] & HEX_0x000FFF0000000000) >> 12; |
| | 277 | TmpQWord2 |= (pB2[0] & HEX_0xFFF0000000000000) >> 36; |
| | 278 | |
| | 279 | pB1[0] = TmpQWord2; |
| | 280 | pB2[0] = TmpQWord1; |