mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-11 15:22:16 +00:00
- make the colormap comparison against NormalLight inline because this is by far the most frequent case and any cycle being saved here counts.
This commit is contained in:
parent
9a24771a7d
commit
cd015f9340
3 changed files with 11 additions and 48 deletions
|
@ -212,7 +212,6 @@ FDynamicColormap *GetSpecialLights (PalEntry color, PalEntry fade, int desaturat
|
||||||
colormap->BuildLights ();
|
colormap->BuildLights ();
|
||||||
}
|
}
|
||||||
else colormap->Maps = NULL;
|
else colormap->Maps = NULL;
|
||||||
|
|
||||||
return colormap;
|
return colormap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
#ifndef __RES_CMAP_H
|
#ifndef __RES_CMAP_H
|
||||||
#define __RES_CMAP_H
|
#define __RES_CMAP_H
|
||||||
|
|
||||||
|
#include "m_fixed.h"
|
||||||
|
|
||||||
struct FSWColormap;
|
struct FSWColormap;
|
||||||
struct lightlist_t;
|
struct lightlist_t;
|
||||||
|
|
||||||
|
@ -149,8 +151,16 @@ extern bool NormalLightHasFixedLights;
|
||||||
|
|
||||||
FDynamicColormap *GetSpecialLights (PalEntry lightcolor, PalEntry fadecolor, int desaturate);
|
FDynamicColormap *GetSpecialLights (PalEntry lightcolor, PalEntry fadecolor, int desaturate);
|
||||||
|
|
||||||
inline FDynamicColormap *GetColorTable(const FColormap &cm)
|
__forceinline FDynamicColormap *GetColorTable(const FColormap &cm)
|
||||||
{
|
{
|
||||||
|
auto p = &NormalLight;
|
||||||
|
if (cm.LightColor == p->Color &&
|
||||||
|
cm.FadeColor == p->Fade &&
|
||||||
|
cm.Desaturation == p->Desaturate)
|
||||||
|
{
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
return GetSpecialLights(cm.LightColor, cm.FadeColor, cm.Desaturation);
|
return GetSpecialLights(cm.LightColor, cm.FadeColor, cm.Desaturation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1715,52 +1715,6 @@ FSerializer &Serialize(FSerializer &arc, const char *key, FName &value, FName *d
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
template<> FSerializer &Serialize(FSerializer &arc, const char *key, FDynamicColormap *&cm, FDynamicColormap **def)
|
|
||||||
{
|
|
||||||
if (arc.isWriting())
|
|
||||||
{
|
|
||||||
if (arc.w->inObject() && def != nullptr && cm->Color == (*def)->Color && cm->Fade == (*def)->Fade && cm->Desaturate == (*def)->Desaturate)
|
|
||||||
{
|
|
||||||
return arc;
|
|
||||||
}
|
|
||||||
|
|
||||||
arc.WriteKey(key);
|
|
||||||
arc.w->StartArray();
|
|
||||||
arc.w->Uint(cm->Color);
|
|
||||||
arc.w->Uint(cm->Fade);
|
|
||||||
arc.w->Uint(cm->Desaturate);
|
|
||||||
arc.w->EndArray();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
auto val = arc.r->FindKey(key);
|
|
||||||
if (val != nullptr)
|
|
||||||
{
|
|
||||||
if (val->IsArray())
|
|
||||||
{
|
|
||||||
const rapidjson::Value &colorval = (*val)[0];
|
|
||||||
const rapidjson::Value &fadeval = (*val)[1];
|
|
||||||
const rapidjson::Value &desatval = (*val)[2];
|
|
||||||
if (colorval.IsUint() && fadeval.IsUint() && desatval.IsUint())
|
|
||||||
{
|
|
||||||
cm = GetSpecialLights(colorval.GetUint(), fadeval.GetUint(), desatval.GetUint());
|
|
||||||
return arc;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
assert(false && "not a colormap");
|
|
||||||
Printf(TEXTCOLOR_RED "object does not represent a colormap for '%s'\n", key);
|
|
||||||
cm = &NormalLight;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return arc;
|
|
||||||
}
|
|
||||||
|
|
||||||
//==========================================================================
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//==========================================================================
|
|
||||||
|
|
||||||
FSerializer &Serialize(FSerializer &arc, const char *key, FSoundID &sid, FSoundID *def)
|
FSerializer &Serialize(FSerializer &arc, const char *key, FSoundID &sid, FSoundID *def)
|
||||||
{
|
{
|
||||||
if (arc.isWriting())
|
if (arc.isWriting())
|
||||||
|
|
Loading…
Reference in a new issue