summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-12-21 01:24:25 +0300
committerAndrei Karas <akaras@inbox.ru>2016-12-21 01:24:25 +0300
commit412c329e164c4b3bef9de3fa6179f244b83b0f6d (patch)
tree598c2d2dae8cbec6e1b6cdb7ba31990b3976bdcc
parent1dcb529da1483ef67426236480abe79e5e952ef0 (diff)
downloadmanaplus-412c329e164c4b3bef9de3fa6179f244b83b0f6d.tar.gz
manaplus-412c329e164c4b3bef9de3fa6179f244b83b0f6d.tar.bz2
manaplus-412c329e164c4b3bef9de3fa6179f244b83b0f6d.tar.xz
manaplus-412c329e164c4b3bef9de3fa6179f244b83b0f6d.zip
Improve a bit dye speed.
-rw-r--r--src/resources/dye/dyepalette.cpp44
-rw-r--r--src/resources/dye/dyepalette_replacescolor.cpp57
2 files changed, 33 insertions, 68 deletions
diff --git a/src/resources/dye/dyepalette.cpp b/src/resources/dye/dyepalette.cpp
index 8ca07ecc7..62beb0b69 100644
--- a/src/resources/dye/dyepalette.cpp
+++ b/src/resources/dye/dyepalette.cpp
@@ -331,42 +331,37 @@ void DyePalette::replaceSOGLColor(uint32_t *restrict pixels,
{
uint8_t *const p = reinterpret_cast<uint8_t *>(&pixels[ptr]);
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- const int alpha = *p & 0xff;
const unsigned int data = (pixels[ptr]) & 0xffffff00;
#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
- const int alpha = pixels[ptr] & 0xff000000;
const unsigned int data = (pixels[ptr]) & 0x00ffffff;
#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
- if (alpha)
+ std::vector<DyeColor>::const_iterator it = mColors.begin();
+ while (it != it_end)
{
- std::vector<DyeColor>::const_iterator it = mColors.begin();
- while (it != it_end)
- {
- const DyeColor &col = *it;
- ++ it;
- const DyeColor &col2 = *it;
+ const DyeColor &col = *it;
+ ++ it;
+ const DyeColor &col2 = *it;
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- const unsigned int coldata = (col.value[0] << 24)
- | (col.value[1] << 16) | (col.value[2] << 8);
+ const unsigned int coldata = (col.value[0] << 24)
+ | (col.value[1] << 16) | (col.value[2] << 8);
#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
- const unsigned int coldata = (col.value[0])
- | (col.value[1] << 8) | (col.value[2] << 16);
+ const unsigned int coldata = (col.value[0])
+ | (col.value[1] << 8) | (col.value[2] << 16);
#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
- if (data == coldata)
- {
- p[0] = col2.value[0];
- p[1] = col2.value[1];
- p[2] = col2.value[2];
- break;
- }
-
- ++ it;
+ if (data == coldata)
+ {
+ p[0] = col2.value[0];
+ p[1] = col2.value[1];
+ p[2] = col2.value[2];
+ break;
}
+
+ ++ it;
}
}
@@ -378,17 +373,12 @@ void DyePalette::replaceSOGLColor(uint32_t *restrict pixels,
{
uint8_t *const p = reinterpret_cast<uint8_t *>(pixels);
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- const int alpha = *p & 0xff;
const unsigned int data = (*pixels) & 0xffffff00;
#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
- const int alpha = *pixels & 0xff000000;
const unsigned int data = (*pixels) & 0x00ffffff;
#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
- if (!alpha)
- continue;
-
std::vector<DyeColor>::const_iterator it = mColors.begin();
while (it != it_end)
{
diff --git a/src/resources/dye/dyepalette_replacescolor.cpp b/src/resources/dye/dyepalette_replacescolor.cpp
index 98525108e..7546ebe72 100644
--- a/src/resources/dye/dyepalette_replacescolor.cpp
+++ b/src/resources/dye/dyepalette_replacescolor.cpp
@@ -69,48 +69,35 @@ void DyePalette::replaceSColorDefault(uint32_t *restrict pixels,
{
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)
{
- std::vector<DyeColor>::const_iterator it = mColors.begin();
- while (it != it_end)
- {
- const DyeColor &col = *it;
- ++ it;
- const DyeColor &col2 = *it;
+ 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]);
+ 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);
+ 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;
+ if (data == coldata)
+ {
+ p[3] = col2.value[0];
+ p[2] = col2.value[1];
+ p[1] = col2.value[2];
+ break;
}
+ ++ it;
}
}
#else // ENABLE_CILKPLUS
@@ -121,22 +108,12 @@ void DyePalette::replaceSColorDefault(uint32_t *restrict 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)
{
@@ -153,10 +130,8 @@ void DyePalette::replaceSColorDefault(uint32_t *restrict pixels,
| (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];