27 PRAGMA48(GCC diagnostic ignored
"-Wshadow")
28 #ifndef SDL_BIG_ENDIAN
29 #include <SDL_endian.h>
35 #include <immintrin.h>
43 STD_VECTOR<DyeColor>::const_iterator it_end =
mColors.end();
44 const size_t sz =
mColors.size();
45 if ((sz == 0U) || (pixels ==
nullptr))
50 for (
const uint32_t *
const p_end = pixels +
CAST_SIZE(bufSize);
54 uint8_t *
const p =
reinterpret_cast<uint8_t *
>(pixels);
55 const unsigned int data = *pixels;
57 STD_VECTOR<DyeColor>::const_iterator it =
mColors.begin();
64 #if SDL_BYTEORDER == SDL_BIG_ENDIAN
65 const unsigned int coldata = (col.
value[3] << 24U)
66 | (col.
value[2] << 16U)
67 | (col.
value[1] << 8U)
70 const unsigned int coldata = (col.
value[3])
71 | (col.
value[2] << 8U)
72 | (col.
value[1] << 16U) |
73 (col.
value[0] << 24U);
103 STD_VECTOR<DyeColor>::const_iterator it_end =
mColors.end();
104 const size_t sz =
mColors.size();
105 if ((sz == 0U) || (pixels ==
nullptr))
109 const int mod = bufSize % 4;
110 const int bufEnd = bufSize - mod;
112 for (
int ptr = 0; ptr < bufEnd; ptr += 4)
115 __m128i
base = _mm_loadu_si128(
reinterpret_cast<__m128i*
>(
118 STD_VECTOR<DyeColor>::const_iterator it =
mColors.begin();
125 __m128i newMask = _mm_set1_epi32(col2.
valueA);
126 __m128i cmpMask = _mm_set1_epi32(col.
valueA);
127 __m128i cmpRes = _mm_cmpeq_epi32(
base, cmpMask);
128 __m128i srcAnd = _mm_andnot_si128(cmpRes,
base);
129 __m128i dstAnd = _mm_and_si128(cmpRes, newMask);
130 base = _mm_or_si128(srcAnd, dstAnd);
135 _mm_storeu_si128(
reinterpret_cast<__m128i*
>(&pixels[ptr]),
base);
139 for (
int ptr = bufSize - mod; ptr < bufSize; ptr ++)
141 uint8_t *
const p =
reinterpret_cast<uint8_t *
>(&pixels[ptr]);
142 const unsigned int data = pixels[ptr];
144 STD_VECTOR<DyeColor>::const_iterator it =
mColors.begin();
151 const unsigned int coldata = (col.
value[3]) |
152 (col.
value[2] << 8U) |
153 (col.
value[1] << 16U) |
154 (col.
value[0] << 24U);
158 p[3] = col2.
value[0];
159 p[2] = col2.
value[1];
160 p[1] = col2.
value[2];
161 p[0] = col2.
value[3];
174 STD_VECTOR<DyeColor>::const_iterator it_end =
mColors.end();
175 const size_t sz =
mColors.size();
176 if ((sz == 0U) || (pixels ==
nullptr))
180 const int mod = bufSize % 8;
181 const int bufEnd = bufSize - mod;
183 for (
int ptr = 0; ptr < bufEnd; ptr += 8)
186 __m256i
base = _mm256_loadu_si256(
reinterpret_cast<__m256i*
>(
189 STD_VECTOR<DyeColor>::const_iterator it =
mColors.begin();
196 __m256i newMask = _mm256_set1_epi32(col2.
valueA);
197 __m256i cmpMask = _mm256_set1_epi32(col.
valueA);
198 __m256i cmpRes = _mm256_cmpeq_epi32(
base, cmpMask);
199 __m256i srcAnd = _mm256_andnot_si256(cmpRes,
base);
200 __m256i dstAnd = _mm256_and_si256(cmpRes, newMask);
201 base = _mm256_or_si256(srcAnd, dstAnd);
206 _mm256_storeu_si256(
reinterpret_cast<__m256i*
>(&pixels[ptr]),
base);
210 for (
int ptr = bufSize - mod; ptr < bufSize; ptr ++)
212 uint8_t *
const p =
reinterpret_cast<uint8_t *
>(&pixels[ptr]);
213 const unsigned int data = pixels[ptr];
215 STD_VECTOR<DyeColor>::const_iterator it =
mColors.begin();
222 const unsigned int coldata = (col.
value[3]) |
223 (col.
value[2] << 8U) |
224 (col.
value[1] << 16U) |
225 (col.
value[0] << 24U);
229 p[3] = col2.
value[0];
230 p[2] = col2.
value[1];
231 p[1] = col2.
value[2];
232 p[0] = col2.
value[3];
void replaceAColorDefault(uint32_t *pixels, const int bufSize) const
union EAthena::ItemFlags __attribute__((packed))
std::map< std::string, DyeColor > mColors