mirror of
https://github.com/ZDoom/qzdoom.git
synced 2025-02-27 06:11:46 +00:00
- allocate FRemapTable's content statically.
first step of organizing this data more renderer-friendly.
This commit is contained in:
parent
b0ecb02d6b
commit
77c4a57c51
2 changed files with 6 additions and 110 deletions
|
@ -135,27 +135,6 @@ bool FUniquePalette::Update()
|
||||||
/****************************************************/
|
/****************************************************/
|
||||||
/****************************************************/
|
/****************************************************/
|
||||||
|
|
||||||
FRemapTable::FRemapTable(int count)
|
|
||||||
{
|
|
||||||
assert(count <= 256);
|
|
||||||
Inactive = false;
|
|
||||||
Alloc(count);
|
|
||||||
|
|
||||||
// Note that the tables are left uninitialized. It is assumed that
|
|
||||||
// the caller will do that next, if only by calling MakeIdentity().
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
FRemapTable::~FRemapTable()
|
|
||||||
{
|
|
||||||
Free();
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
|
@ -179,78 +158,6 @@ int FRemapTable::GetUniqueIndex()
|
||||||
//
|
//
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
|
|
||||||
void FRemapTable::Alloc(int count)
|
|
||||||
{
|
|
||||||
Remap = (uint8_t *)M_Malloc(count*sizeof(*Remap) + count*sizeof(*Palette));
|
|
||||||
assert (Remap != NULL);
|
|
||||||
Palette = (PalEntry *)(Remap + count*(sizeof(*Remap)));
|
|
||||||
Native = NULL;
|
|
||||||
NumEntries = count;
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
void FRemapTable::Free()
|
|
||||||
{
|
|
||||||
KillNative();
|
|
||||||
if (Remap != NULL)
|
|
||||||
{
|
|
||||||
M_Free(Remap);
|
|
||||||
Remap = NULL;
|
|
||||||
Palette = NULL;
|
|
||||||
NumEntries = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
FRemapTable::FRemapTable(const FRemapTable &o)
|
|
||||||
{
|
|
||||||
Remap = NULL;
|
|
||||||
Native = NULL;
|
|
||||||
NumEntries = 0;
|
|
||||||
operator= (o);
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
FRemapTable &FRemapTable::operator=(const FRemapTable &o)
|
|
||||||
{
|
|
||||||
if (&o == this)
|
|
||||||
{
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
if (o.NumEntries != NumEntries)
|
|
||||||
{
|
|
||||||
Free();
|
|
||||||
}
|
|
||||||
if (Remap == NULL)
|
|
||||||
{
|
|
||||||
Alloc(o.NumEntries);
|
|
||||||
}
|
|
||||||
Inactive = o.Inactive;
|
|
||||||
memcpy(Remap, o.Remap, NumEntries*sizeof(*Remap) + NumEntries*sizeof(*Palette));
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
bool FRemapTable::operator==(const FRemapTable &o)
|
bool FRemapTable::operator==(const FRemapTable &o)
|
||||||
{
|
{
|
||||||
// Two translations are identical when they have the same amount of colors
|
// Two translations are identical when they have the same amount of colors
|
||||||
|
@ -271,14 +178,6 @@ void FRemapTable::Serialize(FSerializer &arc)
|
||||||
int n = NumEntries;
|
int n = NumEntries;
|
||||||
|
|
||||||
arc("numentries", NumEntries);
|
arc("numentries", NumEntries);
|
||||||
if (arc.isReading())
|
|
||||||
{
|
|
||||||
if (n != NumEntries)
|
|
||||||
{
|
|
||||||
Free();
|
|
||||||
Alloc(NumEntries);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
arc.Array("remap", Remap, NumEntries);
|
arc.Array("remap", Remap, NumEntries);
|
||||||
arc.Array("palette", Palette, NumEntries);
|
arc.Array("palette", Palette, NumEntries);
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,11 +61,9 @@ public:
|
||||||
|
|
||||||
struct FRemapTable
|
struct FRemapTable
|
||||||
{
|
{
|
||||||
FRemapTable(int count=256);
|
FRemapTable(int count = 256) { NumEntries = count; }
|
||||||
FRemapTable(const FRemapTable &o);
|
FRemapTable(const FRemapTable& o) = default;
|
||||||
~FRemapTable();
|
|
||||||
|
|
||||||
FRemapTable &operator= (const FRemapTable &o);
|
|
||||||
bool operator==(const FRemapTable &o);
|
bool operator==(const FRemapTable &o);
|
||||||
void MakeIdentity();
|
void MakeIdentity();
|
||||||
void KillNative();
|
void KillNative();
|
||||||
|
@ -83,15 +81,14 @@ struct FRemapTable
|
||||||
int StoreTranslation(int slot);
|
int StoreTranslation(int slot);
|
||||||
int GetUniqueIndex();
|
int GetUniqueIndex();
|
||||||
|
|
||||||
uint8_t *Remap; // For the software renderer
|
uint8_t Remap[256]; // For the software renderer
|
||||||
PalEntry *Palette; // The ideal palette this maps to
|
PalEntry Palette[256]; // The ideal palette this maps to
|
||||||
FUniquePalette *Native; // The index into the list of unique palettes (this is to avoid frequent texture recreation with changing ACS translations)
|
FUniquePalette *Native; // The index into the list of unique palettes (this is to avoid frequent texture recreation with changing ACS translations)
|
||||||
|
//int crc32;
|
||||||
int NumEntries; // # of elements in this table (usually 256)
|
int NumEntries; // # of elements in this table (usually 256)
|
||||||
bool Inactive; // This table is inactive and should be treated as if it was passed as NULL
|
bool Inactive = false; // This table is inactive and should be treated as if it was passed as NULL
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void Free();
|
|
||||||
void Alloc(int count);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// A class that initializes unusued pointers to NULL. This is used so that when
|
// A class that initializes unusued pointers to NULL. This is used so that when
|
||||||
|
|
Loading…
Reference in a new issue