Subversion Repositories eduke32

Compare Revisions

Ignore whitespace Rev 8489 → Rev 8491

/source/build/src/colmatch.cpp
80,9 → 80,11
numcolmatchresults = 0;
}
 
#define checkbitfield(field, idx) ((field)[(idx)>>3] & (1u<<((idx)&7)))
 
// Finds a color index in [0 .. lastokcol] closest to (r, g, b).
// <lastokcol> must be in [0 .. 255].
int32_t paletteGetClosestColorUpToIndex(int32_t const r, int32_t const g, int32_t const b, int32_t const lastokcol)
int32_t paletteGetClosestColorWithBlacklist(int32_t const r, int32_t const g, int32_t const b, int32_t const lastokcol, uint8_t const * const blacklist)
{
#ifdef DEBUGGINGAIDS
Bassert(lastokcol >= 0 && lastokcol <= 255);
113,16 → 115,20
for (; i < k; i++)
if (col == (colmatchresults[i] & 0x00ffffff)) { mindist = i; break; }
 
if (mindist != -1 && colmatchresults[mindist]>>24 <= (unsigned)lastokcol)
return colmatchresults[mindist]>>24;
if (mindist != -1)
{
uint32_t const idx = colmatchresults[mindist]>>24;
if (idx <= (unsigned)lastokcol && (blacklist == nullptr || !checkbitfield(blacklist, idx)))
return idx;
}
 
skip:
i = paletteGetClosestColorUpToIndexNoCache(r, g, b, lastokcol);
i = paletteGetClosestColorWithBlacklistNoCache(r, g, b, lastokcol, blacklist);
colmatchresults[numcolmatchresults++ & (COLRESULTSIZ-1)] = col | (i << 24);
return i;
}
 
int32_t paletteGetClosestColorUpToIndexNoCache(int32_t r, int32_t g, int32_t b, int32_t const lastokcol)
int32_t paletteGetClosestColorWithBlacklistNoCache(int32_t r, int32_t g, int32_t b, int32_t const lastokcol, uint8_t const * const blacklist)
{
#ifdef DEBUGGINGAIDS
Bassert(lastokcol >= 0 && lastokcol <= 255);
158,7 → 164,7
char const * const pal1 = (char const *)&colmatch_palette[i*3];
int dist = gdist[pal1[1]+g];
 
if (dist >= mindist || i > lastokcol) continue;
if (dist >= mindist || i > lastokcol || (blacklist != nullptr && checkbitfield(blacklist, i))) continue;
if ((dist += rdist[pal1[0]+r]) >= mindist) continue;
if ((dist += bdist[pal1[2]+b]) >= mindist) continue;
 
175,6 → 181,9
 
for (bssize_t i = 0; i <= lastokcol; ++i)
{
if (blacklist != nullptr && checkbitfield(blacklist, i))
continue;
 
char const * const pal1 = (char const *)&colmatch_palette[i*3];
int dist = gdist[pal1[1]+g];