29 PRAGMA48(GCC diagnostic ignored
"-Wshadow")
30 #ifndef SDL_BIG_ENDIAN
31 #include <SDL_endian.h>
37 #include <immintrin.h>
45 STD_VECTOR<DyeColor>::const_iterator it_end =
mColors.end();
46 const size_t sz =
mColors.size();
47 if (sz == 0U || pixels ==
nullptr)
52 for (
const uint32_t *
const p_end = pixels +
CAST_SIZE(bufSize);
56 uint8_t *
const p =
reinterpret_cast<uint8_t *
>(pixels);
57 const unsigned int data = *pixels;
59 STD_VECTOR<DyeColor>::const_iterator it =
mColors.begin();
66 #if SDL_BYTEORDER == SDL_BIG_ENDIAN
67 const unsigned int coldata = (col.
value[0] << 24U)
68 | (col.
value[1] << 16U)
69 | (col.
value[2] << 8U)
73 const unsigned int coldata = (col.
value[0])
74 | (col.
value[1] << 8U)
75 | (col.
value[2] << 16U)
76 | (col.
value[3] << 24U);
106 STD_VECTOR<DyeColor>::const_iterator it_end =
mColors.end();
107 const size_t sz =
mColors.size();
108 if (sz == 0U || pixels ==
nullptr)
113 const int mod = bufSize % 4;
114 const int bufEnd = bufSize - mod;
116 for (
int ptr = 0; ptr < bufEnd; ptr += 4)
120 __m128i
base = _mm_loadu_si128(
reinterpret_cast<__m128i*
>(
123 STD_VECTOR<DyeColor>::const_iterator it =
mColors.begin();
130 __m128i newMask = _mm_set1_epi32(col2.
valueAOgl);
131 __m128i cmpMask = _mm_set1_epi32(col.
valueAOgl);
132 __m128i cmpRes = _mm_cmpeq_epi32(
base, cmpMask);
133 __m128i srcAnd = _mm_andnot_si128(cmpRes,
base);
134 __m128i dstAnd = _mm_and_si128(cmpRes, newMask);
135 base = _mm_or_si128(srcAnd, dstAnd);
140 _mm_storeu_si128(
reinterpret_cast<__m128i*
>(&pixels[ptr]),
base);
143 for (
int ptr = bufSize - mod; ptr < bufSize; ptr ++)
145 uint8_t *
const p =
reinterpret_cast<uint8_t *
>(&pixels[ptr]);
146 const unsigned int data = pixels[ptr];
148 STD_VECTOR<DyeColor>::const_iterator it =
mColors.begin();
155 #if SDL_BYTEORDER == SDL_BIG_ENDIAN
156 const unsigned int coldata = (col.
value[0] << 24U)
157 | (col.
value[1] << 16U)
158 | (col.
value[2] << 8U)
162 const unsigned int coldata = (col.
value[0])
163 | (col.
value[1] << 8U)
164 | (col.
value[2] << 16U)
165 | (col.
value[3] << 24U);
170 p[0] = col2.
value[0];
171 p[1] = col2.
value[1];
172 p[2] = col2.
value[2];
173 p[3] = col2.
value[3];
186 STD_VECTOR<DyeColor>::const_iterator it_end =
mColors.end();
187 const size_t sz =
mColors.size();
188 if (sz == 0U || pixels ==
nullptr)
193 const int mod = bufSize % 8;
194 const int bufEnd = bufSize - mod;
196 for (
int ptr = 0; ptr < bufEnd; ptr += 8)
200 __m256i
base = _mm256_loadu_si256(
reinterpret_cast<__m256i*
>(
203 STD_VECTOR<DyeColor>::const_iterator it =
mColors.begin();
210 __m256i newMask = _mm256_set1_epi32(col2.
valueAOgl);
211 __m256i cmpMask = _mm256_set1_epi32(col.
valueAOgl);
212 __m256i cmpRes = _mm256_cmpeq_epi32(
base, cmpMask);
213 __m256i srcAnd = _mm256_andnot_si256(cmpRes,
base);
214 __m256i dstAnd = _mm256_and_si256(cmpRes, newMask);
215 base = _mm256_or_si256(srcAnd, dstAnd);
221 _mm256_storeu_si256(
reinterpret_cast<__m256i*
>(&pixels[ptr]),
225 for (
int ptr = bufSize - mod; ptr < bufSize; ptr ++)
227 uint8_t *
const p =
reinterpret_cast<uint8_t *
>(&pixels[ptr]);
228 const unsigned int data = pixels[ptr];
230 STD_VECTOR<DyeColor>::const_iterator it =
mColors.begin();
237 #if SDL_BYTEORDER == SDL_BIG_ENDIAN
238 const unsigned int coldata = (col.
value[0] << 24U)
239 | (col.
value[1] << 16U)
240 | (col.
value[2] << 8U)
244 const unsigned int coldata = (col.
value[0])
245 | (col.
value[1] << 8U)
246 | (col.
value[2] << 16U)
247 | (col.
value[3] << 24U);
252 p[0] = col2.
value[0];
253 p[1] = col2.
value[1];
254 p[2] = col2.
value[2];
255 p[3] = col2.
value[3];
void replaceAOGLColorDefault(uint32_t *pixels, const int bufSize) const
union EAthena::ItemFlags __attribute__((packed))
std::map< std::string, DyeColor > mColors