diff options
author | Andrei Karas <akaras@inbox.ru> | 2016-12-20 23:51:08 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2016-12-20 23:51:08 +0300 |
commit | 1dcb529da1483ef67426236480abe79e5e952ef0 (patch) | |
tree | 72b1454f812025381a12cd9ec15dd7346d87551e /src/resources/dye/dyepalette.cpp | |
parent | 83c4dc85adf03d22b8e7c0ac56abfdaced84edf8 (diff) | |
download | manaplus-1dcb529da1483ef67426236480abe79e5e952ef0.tar.gz manaplus-1dcb529da1483ef67426236480abe79e5e952ef0.tar.bz2 manaplus-1dcb529da1483ef67426236480abe79e5e952ef0.tar.xz manaplus-1dcb529da1483ef67426236480abe79e5e952ef0.zip |
Add simd function for dye replace color (software).
Diffstat (limited to 'src/resources/dye/dyepalette.cpp')
-rw-r--r-- | src/resources/dye/dyepalette.cpp | 115 |
1 files changed, 0 insertions, 115 deletions
diff --git a/src/resources/dye/dyepalette.cpp b/src/resources/dye/dyepalette.cpp index dbb8e4973..8ca07ecc7 100644 --- a/src/resources/dye/dyepalette.cpp +++ b/src/resources/dye/dyepalette.cpp @@ -224,121 +224,6 @@ void DyePalette::getColor(double intensity, intensity * colorJ.value[2]); } -void DyePalette::replaceSColor(uint32_t *restrict pixels, - const int bufSize) const restrict2 -{ - std::vector<DyeColor>::const_iterator it_end = mColors.end(); - const size_t sz = mColors.size(); - if (!sz || !pixels) - return; - if (sz % 2) - -- it_end; - -#ifdef ENABLE_CILKPLUS - cilk_for (int ptr = 0; ptr < bufSize; ptr ++) - { - uint8_t *const p = reinterpret_cast<uint8_t *>(&pixels[ptr]); -#if SDL_BYTEORDER == SDL_BIG_ENDIAN - const int alpha = pixels[ptr] & 0xff000000; - const unsigned int data = pixels[ptr] & 0x00ffffff; -#else // SDL_BYTEORDER == SDL_BIG_ENDIAN - - const int alpha = *p & 0xff; - const unsigned int data = pixels[ptr] & 0xffffff00; -#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN - -// logger->log("c:%04d %08x", c, *pixels); -// logger->log("data: %08x", data); - if (!alpha) - { -// logger->log("skip: %08x", *pixels); - } - else - { - std::vector<DyeColor>::const_iterator it = mColors.begin(); - while (it != it_end) - { - const DyeColor &col = *it; - ++ it; - const DyeColor &col2 = *it; - -#if SDL_BYTEORDER == SDL_BIG_ENDIAN - const unsigned int coldata = (col.value[2] << 16U) - | (col.value[1] << 8U) | (col.value[0]); -#else // SDL_BYTEORDER == SDL_BIG_ENDIAN - const unsigned int coldata = (col.value[2] << 8U) - | (col.value[1] << 16U) | (col.value[0] << 24U); -#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN - -// logger->log("coldata: %08x", coldata); - if (data == coldata) - { -// logger->log("correct"); - p[3] = col2.value[0]; - p[2] = col2.value[1]; - p[1] = col2.value[2]; - break; - } - ++ it; - } - } - } -#else // ENABLE_CILKPLUS - - for (const uint32_t *const p_end = pixels + CAST_SIZE(bufSize); - pixels != p_end; - ++ pixels) - { - uint8_t *const p = reinterpret_cast<uint8_t *>(pixels); -#if SDL_BYTEORDER == SDL_BIG_ENDIAN - const int alpha = *pixels & 0xff000000; - const unsigned int data = (*pixels) & 0x00ffffff; -#else // SDL_BYTEORDER == SDL_BIG_ENDIAN - - const int alpha = *p & 0xff; - const unsigned int data = (*pixels) & 0xffffff00; -#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN - -// logger->log("c:%04d %08x", c, *pixels); -// logger->log("data: %08x", data); - if (!alpha) - { -// logger->log("skip: %08x", *pixels); - continue; - } - - std::vector<DyeColor>::const_iterator it = mColors.begin(); - while (it != it_end) - { - const DyeColor &col = *it; - ++ it; - const DyeColor &col2 = *it; - -#if SDL_BYTEORDER == SDL_BIG_ENDIAN - const unsigned int coldata = (col.value[2] << 16U) - | (col.value[1] << 8U) | (col.value[0]); -#else // SDL_BYTEORDER == SDL_BIG_ENDIAN - - const unsigned int coldata = (col.value[2] << 8U) - | (col.value[1] << 16U) | (col.value[0] << 24U); -#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN - -// logger->log("coldata: %08x", coldata); - if (data == coldata) - { -// logger->log("correct"); - p[3] = col2.value[0]; - p[2] = col2.value[1]; - p[1] = col2.value[2]; - break; - } - - ++ it; - } - } -#endif // ENABLE_CILKPLUS -} - void DyePalette::replaceAColor(uint32_t *restrict pixels, const int bufSize) const restrict2 { |