mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-11 07:12:02 +00:00
- added a 'check only' option to CreateTexBuffer.
This is meant to calculate the content ID without constructing the texture buffer.
This commit is contained in:
parent
200188b3a4
commit
368c788789
4 changed files with 91 additions and 81 deletions
|
@ -358,7 +358,7 @@ int FTexture::CheckExternalFile(bool & hascolorkey)
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
bool FTexture::LoadHiresTexture(FTextureBuffer &texbuffer)
|
bool FTexture::LoadHiresTexture(FTextureBuffer &texbuffer, bool checkonly)
|
||||||
{
|
{
|
||||||
if (HiresLump == -1)
|
if (HiresLump == -1)
|
||||||
{
|
{
|
||||||
|
@ -377,6 +377,8 @@ bool FTexture::LoadHiresTexture(FTextureBuffer &texbuffer)
|
||||||
int w = HiresTexture->GetWidth();
|
int w = HiresTexture->GetWidth();
|
||||||
int h = HiresTexture->GetHeight();
|
int h = HiresTexture->GetHeight();
|
||||||
|
|
||||||
|
if (!checkonly)
|
||||||
|
{
|
||||||
unsigned char * buffer = new unsigned char[w*(h + 1) * 4];
|
unsigned char * buffer = new unsigned char[w*(h + 1) * 4];
|
||||||
memset(buffer, 0, w * (h + 1) * 4);
|
memset(buffer, 0, w * (h + 1) * 4);
|
||||||
|
|
||||||
|
@ -397,6 +399,7 @@ bool FTexture::LoadHiresTexture(FTextureBuffer &texbuffer)
|
||||||
if (dwdata[i] == 0xffffff00 || dwdata[i] == 0xffff00ff) dwdata[i] = 0;
|
if (dwdata[i] == 0xffffff00 || dwdata[i] == 0xffff00ff) dwdata[i] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
FContentIdBuilder contentId;
|
FContentIdBuilder contentId;
|
||||||
contentId.id = 0;
|
contentId.id = 0;
|
||||||
contentId.imageID = HiresTexture->GetImage()->GetId();
|
contentId.imageID = HiresTexture->GetImage()->GetId();
|
||||||
|
|
|
@ -352,7 +352,7 @@ static void xbrzOldScale(size_t factor, const uint32_t* src, uint32_t* trg, int
|
||||||
// the upsampled buffer.
|
// the upsampled buffer.
|
||||||
//
|
//
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
void FTexture::CreateUpsampledTextureBuffer(FTextureBuffer &texbuffer, bool hasAlpha)
|
void FTexture::CreateUpsampledTextureBuffer(FTextureBuffer &texbuffer, bool hasAlpha, bool checkonly)
|
||||||
{
|
{
|
||||||
// [BB] Make sure that inWidth and inHeight denote the size of
|
// [BB] Make sure that inWidth and inHeight denote the size of
|
||||||
// the returned buffer even if we don't upsample the input buffer.
|
// the returned buffer even if we don't upsample the input buffer.
|
||||||
|
@ -398,10 +398,12 @@ void FTexture::CreateUpsampledTextureBuffer(FTextureBuffer &texbuffer, bool hasA
|
||||||
type = 2;
|
type = 2;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (mult < 2)
|
// These checks are to ensure consistency of the content ID.
|
||||||
type = 0;
|
if (mult < 2 || mult > 6 || type < 1 || type > 6) return;
|
||||||
|
if (type < 4 && mult > 4) mult = 4;
|
||||||
|
|
||||||
|
if (!checkonly)
|
||||||
|
{
|
||||||
if (type == 1)
|
if (type == 1)
|
||||||
{
|
{
|
||||||
if (mult == 2)
|
if (mult == 2)
|
||||||
|
@ -442,7 +444,7 @@ void FTexture::CreateUpsampledTextureBuffer(FTextureBuffer &texbuffer, bool hasA
|
||||||
texbuffer.mBuffer = normalNxHelper(&normalNx, mult, texbuffer.mBuffer, inWidth, inHeight, texbuffer.mWidth, texbuffer.mHeight);
|
texbuffer.mBuffer = normalNxHelper(&normalNx, mult, texbuffer.mBuffer, inWidth, inHeight, texbuffer.mWidth, texbuffer.mHeight);
|
||||||
else
|
else
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
// Encode the scaling method in the content ID.
|
// Encode the scaling method in the content ID.
|
||||||
FContentIdBuilder contentId;
|
FContentIdBuilder contentId;
|
||||||
contentId.id = texbuffer.mContentId;
|
contentId.id = texbuffer.mContentId;
|
||||||
|
|
|
@ -668,6 +668,7 @@ FTextureBuffer FTexture::CreateTexBuffer(int translation, int flags)
|
||||||
unsigned char * buffer = nullptr;
|
unsigned char * buffer = nullptr;
|
||||||
int W, H;
|
int W, H;
|
||||||
int isTransparent = -1;
|
int isTransparent = -1;
|
||||||
|
bool checkonly = !!(flags & CTF_CheckOnly);
|
||||||
|
|
||||||
if (flags & CTF_CheckHires)
|
if (flags & CTF_CheckHires)
|
||||||
{
|
{
|
||||||
|
@ -679,6 +680,8 @@ FTextureBuffer FTexture::CreateTexBuffer(int translation, int flags)
|
||||||
W = GetWidth() + 2 * exx;
|
W = GetWidth() + 2 * exx;
|
||||||
H = GetHeight() + 2 * exx;
|
H = GetHeight() + 2 * exx;
|
||||||
|
|
||||||
|
if (!checkonly)
|
||||||
|
{
|
||||||
buffer = new unsigned char[W*(H + 1) * 4];
|
buffer = new unsigned char[W*(H + 1) * 4];
|
||||||
memset(buffer, 0, W * (H + 1) * 4);
|
memset(buffer, 0, W * (H + 1) * 4);
|
||||||
|
|
||||||
|
@ -699,6 +702,7 @@ FTextureBuffer FTexture::CreateTexBuffer(int translation, int flags)
|
||||||
isTransparent = 0;
|
isTransparent = 0;
|
||||||
// A translated image is not conclusive for setting the texture's transparency info.
|
// A translated image is not conclusive for setting the texture's transparency info.
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (GetImage())
|
if (GetImage())
|
||||||
{
|
{
|
||||||
|
@ -718,8 +722,8 @@ FTextureBuffer FTexture::CreateTexBuffer(int translation, int flags)
|
||||||
// Only do postprocessing for image-backed textures. (i.e. not for the burn texture which can also pass through here.)
|
// Only do postprocessing for image-backed textures. (i.e. not for the burn texture which can also pass through here.)
|
||||||
if (GetImage() && flags & CTF_ProcessData)
|
if (GetImage() && flags & CTF_ProcessData)
|
||||||
{
|
{
|
||||||
CreateUpsampledTextureBuffer(result, !!isTransparent);
|
CreateUpsampledTextureBuffer(result, !!isTransparent, checkonly);
|
||||||
ProcessData(result.mBuffer, result.mWidth, result.mHeight, false);
|
if (!checkonly) ProcessData(result.mBuffer, result.mWidth, result.mHeight, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
|
@ -109,6 +109,7 @@ enum ECreateTexBufferFlags
|
||||||
CTF_CheckHires = 1, // use external hires replacement if found
|
CTF_CheckHires = 1, // use external hires replacement if found
|
||||||
CTF_Expand = 2, // create buffer with a one-pixel wide border
|
CTF_Expand = 2, // create buffer with a one-pixel wide border
|
||||||
CTF_ProcessData = 4, // run postprocessing on the generated buffer. This is only needed when using the data for a hardware texture.
|
CTF_ProcessData = 4, // run postprocessing on the generated buffer. This is only needed when using the data for a hardware texture.
|
||||||
|
CTF_CheckOnly = 8, // Only runs the code to get a content ID but does not create a texture. Can be used to access a caching system for the hardware textures.
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -282,7 +283,7 @@ public:
|
||||||
virtual ~FTexture ();
|
virtual ~FTexture ();
|
||||||
virtual FImageSource *GetImage() const { return nullptr; }
|
virtual FImageSource *GetImage() const { return nullptr; }
|
||||||
void AddAutoMaterials();
|
void AddAutoMaterials();
|
||||||
void CreateUpsampledTextureBuffer(FTextureBuffer &texbuffer, bool hasAlpha);
|
void CreateUpsampledTextureBuffer(FTextureBuffer &texbuffer, bool hasAlpha, bool checkonly);
|
||||||
|
|
||||||
// These are mainly meant for 2D code which only needs logical information about the texture to position it properly.
|
// These are mainly meant for 2D code which only needs logical information about the texture to position it properly.
|
||||||
int GetDisplayWidth() { return GetScaledWidth(); }
|
int GetDisplayWidth() { return GetScaledWidth(); }
|
||||||
|
@ -491,7 +492,7 @@ public:
|
||||||
private:
|
private:
|
||||||
int CheckDDPK3();
|
int CheckDDPK3();
|
||||||
int CheckExternalFile(bool & hascolorkey);
|
int CheckExternalFile(bool & hascolorkey);
|
||||||
bool LoadHiresTexture(FTextureBuffer &texbuffer);
|
bool LoadHiresTexture(FTextureBuffer &texbuffer, bool checkonly);
|
||||||
|
|
||||||
bool bSWSkyColorDone = false;
|
bool bSWSkyColorDone = false;
|
||||||
PalEntry FloorSkyColor;
|
PalEntry FloorSkyColor;
|
||||||
|
|
Loading…
Reference in a new issue