From d28891fb628b08fb3786ea315ec0a14af43c4544 Mon Sep 17 00:00:00 2001 From: HALX99 Date: Wed, 21 Oct 2020 00:35:39 +0800 Subject: [PATCH] Remove unused converter functions --- cocos/renderer/backend/TextureUtils.cpp | 180 +----------------------- 1 file changed, 2 insertions(+), 178 deletions(-) diff --git a/cocos/renderer/backend/TextureUtils.cpp b/cocos/renderer/backend/TextureUtils.cpp index 2036603073..bcbd7146cb 100644 --- a/cocos/renderer/backend/TextureUtils.cpp +++ b/cocos/renderer/backend/TextureUtils.cpp @@ -1,5 +1,6 @@ /**************************************************************************** Copyright (c) 2018-2019 Xiamen Yaji Software Co., Ltd. + Copyright (c) 2020 c4games.com http://www.cocos2d-x.org @@ -204,46 +205,6 @@ namespace backend { namespace PixelFormatUtils { } } -#if 0 // unused - // IIIIIIIIAAAAAAAA -> BBBBBGGG GGGRRRR - static void convertLA8ToBGR565(const unsigned char* data, size_t dataLen, unsigned char* outData) - { - uint16_t* out16 = (uint16_t*)outData; - for (ssize_t i = 0, l = dataLen - 1; i < l; i += 2) - { - *out16++ = (data[i] & 0x00F8) << 8 //R - | (data[i] & 0x00FC) << 3 //G - | (data[i] & 0x00F8) >> 3; //B - } - } - - // IIIIIIIIAAAAAAAA -> BBBBBGGG GGRRRRRA - static void convertLA8ToBGR5A1(const unsigned char* data, size_t dataLen, unsigned char* outData) - { - uint16_t* out16 = (uint16_t*)outData; - for (ssize_t i = 0, l = dataLen - 1; i < l; i += 2) - { - *out16++ = (data[i] & 0x00F8) << 7 //R - | (data[i] & 0x00F8) << 2 //G - | (data[i] & 0x00F8) >> 3 //B - | (data[i + 1] & 0x0080) << 8; //A - } - } - - // IIIIIIIIAAAAAAAA -> AAAABBBB GGGGRRRR - static void convertLA8ToABGR4(const unsigned char* data, size_t dataLen, unsigned char* outData) - { - uint16_t* out16 = (uint16_t*)outData; - for (ssize_t i = 0, l = dataLen - 1; i < l; i += 2) - { - *out16++ = (data[i] & 0x00F0) << 8 //R - | (data[i] & 0x00F0) << 4 //G - | (data[i] & 0x00F0) //B - | (data[i + 1] & 0x00F0) >> 4; //A - } - } -#endif - // IIIIIIII -> RRRRRGGGGGBBBBBA void convertL8ToRGB5A1(const unsigned char* data, size_t dataLen, unsigned char* outData) { @@ -255,48 +216,7 @@ namespace backend { namespace PixelFormatUtils { | (data[i] & 0x00F8) >> 2 //B | 0x0001; //A } - } - -#if 0 // unused - /// IIIIIIII -> BBBBBGGG GGRRRRRA - static void convertL8ToBGR5A1(const unsigned char* data, size_t dataLen, unsigned char* outData) - { - uint16_t *out16 = (uint16_t*)outData; - for (size_t i = 0; i < dataLen; ++i) - { - *out16++ = (data[i] & 0xF8) << 7 //R - | (data[i] & 0xF8) << 2 //G - | (data[i] & 0xF8) >> 3 //B - | 0x8000; //A - } - } - - // IIIIIIIII -> BBBBBGGG GGGRRRRR - static void convertL8ToBGR565(const unsigned char* data, size_t dataLen, unsigned char* outData) - { - uint16_t *out16 = (uint16_t*)outData; - for (size_t i = 0; i < dataLen; ++i) - { - *out16++ = (data[i] & 0xF8) << 8 //R - | (data[i] & 0xFC) << 3 //G - | (data[i] & 0xF8) >> 3 //B - ; - } - } - - // IIIIIIIII -> AAAABBBBB GGGGRRRR - static void convertL8ToABGR4(const unsigned char* data, size_t dataLen, unsigned char* outData) - { - uint16_t *out16 = (uint16_t*)outData; - for (size_t i = 0; i < dataLen; ++i) - { - *out16++ = (data[i] & 0xF0) << 8 //R - | (data[i] & 0xF0) << 4 //G - | (data[i] & 0xF0) //B - | 0x000F; - } - } -#endif + } // IIIIIIIIAAAAAAAA -> RRRRRGGGGGBBBBBA void convertLA8ToRGB5A1(const unsigned char* data, size_t dataLen, unsigned char* outData) @@ -482,44 +402,6 @@ namespace backend { namespace PixelFormatUtils { | 0x01; //A } } -#if 0 // unused - // RRRRRRRRGGGGGGGGBBBBBBBB -> BBBBBGGG GGGRRRRR - static void convertRGB8ToBGR565(const unsigned char *data, size_t dataLen, unsigned char *out) - { - uint16_t *outData = (uint16_t*) out; - for(size_t i = 0;i < dataLen ; i += 3) - { - *outData++ = ((data[i] & 0xF8) << 8)| - ((data[i + 1] &0xFC) << 3) | - ((data[i + 2] & 0xF8)>> 3); - } - } - - // RRRRRRRRGGGGGGGGBBBBBBBB -> BBBBBGGG GGRRRRRA - static void convertRGB8ToBGR5A1(const unsigned char *data, size_t dataLen, unsigned char *out) - { - uint16_t *outData = (uint16_t*) out; - for(size_t i = 0;i < dataLen ; i += 3) - { - *outData++ = ((data[i] & 0xF8) << 7) | - ((data[i + 1] & 0xF8) << 2) | - ((data[i + 2] &0xF8) >> 3) | 0x8000; - } - } - - // RRRRRRRRGGGGGGGGBBBBBBBB -> AAAABBBB GGGGRRRR - static void convertRGB8ToABGR4(const unsigned char *data, size_t dataLen, unsigned char *out) - { - uint16_t *outData = (uint16_t*) out; - for(size_t i = 0;i < dataLen ; i += 3) - { - *outData++ = ((data[i] & 0xF0) << 8) | //r - ((data[i + 1] & 0xF0) << 4) | //g - ((data[i + 2] & 0xF0)) | //b - 0x000F; //a - } - } -#endif // RRRRRRRRGGGGGGGGBBBBBBBBAAAAAAAA -> RRRRRGGG GGBBBBBA void convertRGBA8ToRGB5A1(const unsigned char* data, size_t dataLen, unsigned char* outData) @@ -534,47 +416,6 @@ namespace backend { namespace PixelFormatUtils { } } -#if 0 // unused - // RRRRRRRRGGGGGGGGBBBBBBBBAAAAAAAA -> BBBBBGGG GGGRRRR - static void convertRGBA8ToBGR565(const unsigned char *data, size_t dataLen, unsigned char *out) - { - uint16_t *outData = (uint16_t*)out; - const size_t pixelCnt = dataLen / 4; - for(size_t i=0;i < pixelCnt; i++ ) - { - outData[i] = ((data[i*4 + 2] & 0xF8) >> 3) | //b - ((data[i * 4 + 1] & 0xFC ) << 3) | //g - (((data[i * 4 + 0] & 0xF8) << 8)); //r - } - } - - // RRRRRRRRGGGGGGGGBBBBBBBBAAAAAAAA -> AAAABBBB GGGGRRRR - static void convertRGBA8ToABGR4(const unsigned char *data, size_t dataLen, unsigned char *out) - { - uint16_t *outData = (uint16_t*)out; - for(size_t i=0;i < dataLen; i+=4 ) - { - *outData++ = (data[i] & 0x00F0) >> 4 //R - | (data[i + 1] & 0x00F0) //G - | (data[i + 2] & 0x00F0) << 4 //B - | (data[i + 3] & 0x00F0) << 8; //A - } - } - - // RRRRRRRRGGGGGGGGBBBBBBBBAAAAAAAA -> BBBBBGGG GGRRRRRA - static void convertRGBA8ToBGR5A1(const unsigned char *data, size_t dataLen, unsigned char *out) - { - uint16_t *outData = (uint16_t*)out; - for(size_t i = 0; i < dataLen; i += 4) - { - *outData++ = ((data[i + 2] & 0xF8) >> 3)| //b - ((data[i + 1] & 0xF8 ) << 2) | //g - ((data[i + 0] & 0xF8 ) << 7) | //r - ((data[i + 3] & 0x80) << 8); //a - } - } -#endif - void convertRGB5A1ToRGBA8(const unsigned char* data, size_t dataLen, unsigned char* outData) { uint16_t *inData = (uint16_t*)data; @@ -590,22 +431,6 @@ namespace backend { namespace PixelFormatUtils { } } -#if 0 // unused - // ABBBBBGG GGGRRRRR -> BBBBBGGG GGRRRRRA - static void convertRGB5A1ToBGR5A1(const unsigned char *data, size_t dataLen, unsigned char *out) - { - const size_t pixelLen = dataLen / 2; - const uint16_t *inData = (uint16_t*) data; - uint16_t *outData = (uint16_t*) out; - uint16_t pixel; - for (size_t i = 0; i < pixelLen; i++ ) - { - pixel = inData[i]; - outData[i] = (pixel >> 1) | ((pixel & 0x0001) << 15); - } - } -#endif - void convertRGB565ToRGBA8(const unsigned char* data, size_t dataLen, unsigned char* outData) { uint16_t *inData = (uint16_t*)data; @@ -664,7 +489,6 @@ namespace backend { namespace PixelFormatUtils { ////////////////////////////////////////////////////////////////////////// - cocos2d::backend::PixelFormat convertL8ToFormat(const unsigned char* data, size_t dataLen, PixelFormat format, unsigned char** outData, size_t* outDataLen) { switch (format)