mirror of
https://github.com/ZDoom/raze-gles.git
synced 2025-01-11 18:50:46 +00:00
Rename colmatch functions
git-svn-id: https://svn.eduke32.com/eduke32@8488 1a8010ca-5511-0410-912e-c29ae57300e0 # Conflicts: # source/build/include/colmatch.h # source/build/src/build.cpp # source/build/src/defs.cpp # source/build/src/palette.cpp # source/duke3d/src/lunatic/dynsymlist_editor.lds # source/duke3d/src/lunatic/dynsymlist_game.lds # source/duke3d/src/lunatic/engine.lua # source/tools/src/transpal.cpp
This commit is contained in:
parent
7db49ea20a
commit
0a7f5f558a
5 changed files with 38 additions and 38 deletions
|
@ -1,15 +1,15 @@
|
|||
|
||||
#include "compat.h"
|
||||
|
||||
extern void initfastcolorlookup_scale(int32_t rscale, int32_t gscale, int32_t bscale);
|
||||
extern void initfastcolorlookup_palette(uint8_t const * pal) ATTRIBUTE((nonnull(1)));
|
||||
extern void initfastcolorlookup_gridvectors(void);
|
||||
extern void paletteInitClosestColorScale(int32_t rscale, int32_t gscale, int32_t bscale);
|
||||
extern void paletteInitClosestColorMap(uint8_t const * pal) ATTRIBUTE((nonnull(1)));
|
||||
extern void paletteInitClosestColorGrid(void);
|
||||
|
||||
extern int32_t getclosestcol_lim(int32_t r, int32_t g, int32_t b, int32_t lastokcol);
|
||||
extern int32_t getclosestcol_nocache_lim(int32_t r, int32_t g, int32_t b, int32_t lastokcol);
|
||||
extern void getclosestcol_flush(void);
|
||||
extern int32_t paletteGetClosestColorUpToIndex(int32_t r, int32_t g, int32_t b, int32_t lastokcol);
|
||||
extern int32_t paletteGetClosestColorUpToIndexNoCache(int32_t r, int32_t g, int32_t b, int32_t lastokcol);
|
||||
extern void paletteFlushClosestColor(void);
|
||||
|
||||
static FORCE_INLINE int32_t paletteGetClosestColor(int32_t r, int32_t g, int32_t b)
|
||||
{
|
||||
return getclosestcol_lim(r, g, b, 255);
|
||||
return paletteGetClosestColorUpToIndex(r, g, b, 255);
|
||||
}
|
||||
|
|
|
@ -19,9 +19,9 @@ static uint8_t const * colmatch_palette;
|
|||
#define pow2char(x) (1u << (x))
|
||||
|
||||
//
|
||||
// initfastcolorlookup
|
||||
// paletteInitClosestColor
|
||||
//
|
||||
void initfastcolorlookup_scale(int32_t rscale, int32_t gscale, int32_t bscale)
|
||||
void paletteInitClosestColorScale(int32_t rscale, int32_t gscale, int32_t bscale)
|
||||
{
|
||||
int32_t j = 0;
|
||||
for (bssize_t i=256; i>=0; i--)
|
||||
|
@ -33,7 +33,7 @@ void initfastcolorlookup_scale(int32_t rscale, int32_t gscale, int32_t bscale)
|
|||
j += FASTPALRGBDIST-(i<<1);
|
||||
}
|
||||
}
|
||||
void initfastcolorlookup_palette(uint8_t const * const pal)
|
||||
void paletteInitClosestColorMap(uint8_t const * const pal)
|
||||
{
|
||||
Bmemset(colhere,0,sizeof(colhere));
|
||||
Bmemset(colhead,0,sizeof(colhead));
|
||||
|
@ -51,9 +51,9 @@ void initfastcolorlookup_palette(uint8_t const * const pal)
|
|||
colhere[j>>3] |= pow2char(j&7);
|
||||
}
|
||||
|
||||
getclosestcol_flush();
|
||||
paletteFlushClosestColor();
|
||||
}
|
||||
void initfastcolorlookup_gridvectors(void)
|
||||
void paletteInitClosestColorGrid(void)
|
||||
{
|
||||
int i = 0;
|
||||
int32_t x, y, z;
|
||||
|
@ -71,18 +71,18 @@ void initfastcolorlookup_gridvectors(void)
|
|||
|
||||
#define COLRESULTSIZ 4096
|
||||
|
||||
static uint32_t getclosestcol_results[COLRESULTSIZ];
|
||||
static int32_t numclosestcolresults;
|
||||
static uint32_t colmatchresults[COLRESULTSIZ];
|
||||
static int32_t numcolmatchresults;
|
||||
|
||||
void getclosestcol_flush(void)
|
||||
void paletteFlushClosestColor(void)
|
||||
{
|
||||
Bmemset(getclosestcol_results, 0, COLRESULTSIZ * sizeof(uint32_t));
|
||||
numclosestcolresults = 0;
|
||||
Bmemset(colmatchresults, 0, COLRESULTSIZ * sizeof(uint32_t));
|
||||
numcolmatchresults = 0;
|
||||
}
|
||||
|
||||
// Finds a color index in [0 .. lastokcol] closest to (r, g, b).
|
||||
// <lastokcol> must be in [0 .. 255].
|
||||
int32_t getclosestcol_lim(int32_t const r, int32_t const g, int32_t const b, int32_t const lastokcol)
|
||||
int32_t paletteGetClosestColorUpToIndex(int32_t const r, int32_t const g, int32_t const b, int32_t const lastokcol)
|
||||
{
|
||||
#ifdef DEBUGGINGAIDS
|
||||
Bassert(lastokcol >= 0 && lastokcol <= 255);
|
||||
|
@ -92,37 +92,37 @@ int32_t getclosestcol_lim(int32_t const r, int32_t const g, int32_t const b, int
|
|||
|
||||
int mindist = -1;
|
||||
|
||||
int const k = (numclosestcolresults > COLRESULTSIZ) ? COLRESULTSIZ : numclosestcolresults;
|
||||
int const k = (numcolmatchresults > COLRESULTSIZ) ? COLRESULTSIZ : numcolmatchresults;
|
||||
|
||||
if (!numclosestcolresults) goto skip;
|
||||
if (!numcolmatchresults) goto skip;
|
||||
|
||||
if (col == (getclosestcol_results[(numclosestcolresults-1) & (COLRESULTSIZ-1)] & 0x00ffffff))
|
||||
return getclosestcol_results[(numclosestcolresults-1) & (COLRESULTSIZ-1)]>>24;
|
||||
if (col == (colmatchresults[(numcolmatchresults-1) & (COLRESULTSIZ-1)] & 0x00ffffff))
|
||||
return colmatchresults[(numcolmatchresults-1) & (COLRESULTSIZ-1)]>>24;
|
||||
|
||||
int i;
|
||||
|
||||
for (i = 0; i <= k-4; i+=4)
|
||||
{
|
||||
if (col == (getclosestcol_results[i] & 0x00ffffff)) { mindist = i; break; }
|
||||
if (col == (getclosestcol_results[i+1] & 0x00ffffff)) { mindist = i+1; break; }
|
||||
if (col == (getclosestcol_results[i+2] & 0x00ffffff)) { mindist = i+2; break; }
|
||||
if (col == (getclosestcol_results[i+3] & 0x00ffffff)) { mindist = i+3; break; }
|
||||
if (col == (colmatchresults[i] & 0x00ffffff)) { mindist = i; break; }
|
||||
if (col == (colmatchresults[i+1] & 0x00ffffff)) { mindist = i+1; break; }
|
||||
if (col == (colmatchresults[i+2] & 0x00ffffff)) { mindist = i+2; break; }
|
||||
if (col == (colmatchresults[i+3] & 0x00ffffff)) { mindist = i+3; break; }
|
||||
}
|
||||
|
||||
if (mindist == -1)
|
||||
for (; i < k; i++)
|
||||
if (col == (getclosestcol_results[i] & 0x00ffffff)) { mindist = i; break; }
|
||||
if (col == (colmatchresults[i] & 0x00ffffff)) { mindist = i; break; }
|
||||
|
||||
if (mindist != -1 && getclosestcol_results[mindist]>>24 < (unsigned)lastokcol)
|
||||
return getclosestcol_results[mindist]>>24;
|
||||
if (mindist != -1 && colmatchresults[mindist]>>24 < (unsigned)lastokcol)
|
||||
return colmatchresults[mindist]>>24;
|
||||
|
||||
skip:
|
||||
i = getclosestcol_nocache_lim(r, g, b, lastokcol);
|
||||
getclosestcol_results[numclosestcolresults++ & (COLRESULTSIZ-1)] = col | (i << 24);
|
||||
i = paletteGetClosestColorUpToIndexNoCache(r, g, b, lastokcol);
|
||||
colmatchresults[numcolmatchresults++ & (COLRESULTSIZ-1)] = col | (i << 24);
|
||||
return i;
|
||||
}
|
||||
|
||||
int32_t getclosestcol_nocache_lim(int32_t r, int32_t g, int32_t b, int32_t const lastokcol)
|
||||
int32_t paletteGetClosestColorUpToIndexNoCache(int32_t r, int32_t g, int32_t b, int32_t const lastokcol)
|
||||
{
|
||||
#ifdef DEBUGGINGAIDS
|
||||
Bassert(lastokcol >= 0 && lastokcol <= 255);
|
||||
|
|
|
@ -2713,7 +2713,7 @@ static int32_t defsparser(scriptfile *script)
|
|||
|
||||
if (didLoadPal && id == 0)
|
||||
{
|
||||
initfastcolorlookup_palette(palette);
|
||||
paletteInitClosestColorMap(palette);
|
||||
|
||||
paletteloaded |= PALETTE_MAIN;
|
||||
}
|
||||
|
|
|
@ -164,8 +164,8 @@ inline bool read_and_test(FileReader& handle, void* buffer, int32_t leng)
|
|||
//
|
||||
void paletteLoadFromDisk(void)
|
||||
{
|
||||
initfastcolorlookup_scale(30, 59, 11);
|
||||
initfastcolorlookup_gridvectors();
|
||||
paletteInitClosestColorScale(30, 59, 11);
|
||||
paletteInitClosestColorGrid();
|
||||
|
||||
#ifdef USE_OPENGL
|
||||
for (auto & x : glblend)
|
||||
|
@ -191,7 +191,7 @@ void paletteLoadFromDisk(void)
|
|||
for (unsigned char & k : palette)
|
||||
k <<= 2;
|
||||
|
||||
initfastcolorlookup_palette(palette);
|
||||
paletteInitClosestColorMap(palette);
|
||||
|
||||
paletteloaded |= PALETTE_MAIN;
|
||||
|
||||
|
@ -361,7 +361,7 @@ void palettePostLoadTables(void)
|
|||
for (size_t i = 0; i<16; i++)
|
||||
{
|
||||
palette_t *edcol = (palette_t *) &vgapal16[4*i];
|
||||
editorcolors[i] = getclosestcol_lim(edcol->b, edcol->g, edcol->r, playing_blood ? 254 : 239);
|
||||
editorcolors[i] = paletteGetClosestColorUpToIndex(edcol->b, edcol->g, edcol->r, playing_blood ? 254 : 239);
|
||||
}
|
||||
|
||||
// Bmemset(PaletteIndexFullbrights, 0, sizeof(PaletteIndexFullbrights));
|
||||
|
|
|
@ -5829,7 +5829,7 @@ badindex:
|
|||
{
|
||||
tw = *insptr++;
|
||||
int32_t const rgb = Gv_GetVar(*insptr++);
|
||||
Gv_SetVar(tw, getclosestcol_lim(rgb & 0xFF, (rgb >> 8) & 0xFF, (rgb >> 16) & 0xFF, Gv_GetVar(*insptr++)));
|
||||
Gv_SetVar(tw, paletteGetClosestColorUpToIndex(rgb & 0xFF, (rgb >> 8) & 0xFF, (rgb >> 16) & 0xFF, Gv_GetVar(*insptr++)));
|
||||
}
|
||||
dispatch();
|
||||
|
||||
|
|
Loading…
Reference in a new issue