- removed the intermediate FGLTexture class.
This wasn't serving any real purpose anymore, and all its remaining functionality could be moved to FHardwareTexture
This commit is contained in:
parent
8d62ebd2f4
commit
c37ff22a05
11 changed files with 166 additions and 294 deletions
|
|
@ -45,6 +45,7 @@
|
|||
#include "c_dispatch.h"
|
||||
#include "v_video.h"
|
||||
#include "m_fixed.h"
|
||||
#include "textures/warpbuffer.h"
|
||||
|
||||
FTexture *CreateBrightmapTexture(FTexture*);
|
||||
|
||||
|
|
@ -1352,7 +1353,7 @@ bool FTexture::ProcessData(unsigned char * buffer, int w, int h, bool ispatch)
|
|||
|
||||
unsigned char * FTexture::CreateTexBuffer(int translation, int & w, int & h, int flags)
|
||||
{
|
||||
unsigned char * buffer;
|
||||
unsigned char * buffer = nullptr;
|
||||
int W, H;
|
||||
int isTransparent = -1;
|
||||
|
||||
|
|
@ -1360,71 +1361,82 @@ unsigned char * FTexture::CreateTexBuffer(int translation, int & w, int & h, int
|
|||
if ((flags & CTF_CheckHires) && translation != STRange_AlphaTexture)
|
||||
{
|
||||
buffer = LoadHiresTexture(&w, &h);
|
||||
if (buffer)
|
||||
{
|
||||
return buffer;
|
||||
}
|
||||
}
|
||||
|
||||
int exx = !!(flags & CTF_Expand);
|
||||
|
||||
W = w = GetWidth() + 2 * exx;
|
||||
H = h = GetHeight() + 2 * exx;
|
||||
|
||||
|
||||
buffer = new unsigned char[W*(H + 1) * 4];
|
||||
memset(buffer, 0, W * (H + 1) * 4);
|
||||
|
||||
FBitmap bmp(buffer, W * 4, W, H);
|
||||
|
||||
if (translation <= 0 || translation >= STRange_Min)
|
||||
if (buffer == nullptr)
|
||||
{
|
||||
// Allow creation of desaturated or special-colormapped textures for the legacy renderer.
|
||||
FCopyInfo inf = { OP_COPY, BLEND_NONE,{ 0 }, 0, 0 };
|
||||
if (translation >= STRange_Desaturate && translation < STRange_Desaturate + 31) // there are 31 ranges of desaturations available
|
||||
{
|
||||
inf.blend = (EBlend)(BLEND_DESATURATE1 + translation - STRange_Desaturate);
|
||||
}
|
||||
else if (translation >= STRange_Specialcolormap && translation < STRange_Specialcolormap + (int)SpecialColormaps.Size())
|
||||
{
|
||||
inf.blend = (EBlend)(BLEND_SPECIALCOLORMAP1 + translation - STRange_Specialcolormap);
|
||||
}
|
||||
|
||||
int trans = CopyTrueColorPixels(&bmp, exx, exx, 0, translation >= STRange_Min ? &inf : nullptr);
|
||||
CheckTrans(buffer, W*H, trans);
|
||||
isTransparent = bTranslucent;
|
||||
// alpha texture for legacy mode
|
||||
if (translation == STRange_AlphaTexture)
|
||||
int exx = !!(flags & CTF_Expand);
|
||||
|
||||
W = w = GetWidth() + 2 * exx;
|
||||
H = h = GetHeight() + 2 * exx;
|
||||
|
||||
|
||||
buffer = new unsigned char[W*(H + 1) * 4];
|
||||
memset(buffer, 0, W * (H + 1) * 4);
|
||||
|
||||
FBitmap bmp(buffer, W * 4, W, H);
|
||||
|
||||
if (translation <= 0 || translation >= STRange_Min)
|
||||
{
|
||||
for (int i = 0; i < W*H; i++)
|
||||
// Allow creation of desaturated or special-colormapped textures for the legacy renderer.
|
||||
FCopyInfo inf = { OP_COPY, BLEND_NONE,{ 0 }, 0, 0 };
|
||||
if (translation >= STRange_Desaturate && translation < STRange_Desaturate + 31) // there are 31 ranges of desaturations available
|
||||
{
|
||||
int b = buffer[4 * i];
|
||||
int g = buffer[4 * i + 1];
|
||||
int r = buffer[4 * i + 2];
|
||||
int gray = Luminance(r, g, b);
|
||||
buffer[4 * i] = 255;
|
||||
buffer[4 * i + 1] = 255;
|
||||
buffer[4 * i + 2] = 255;
|
||||
buffer[4 * i + 3] = (buffer[4 * i + 3] * gray) >> 8;
|
||||
inf.blend = (EBlend)(BLEND_DESATURATE1 + translation - STRange_Desaturate);
|
||||
}
|
||||
else if (translation >= STRange_Specialcolormap && translation < STRange_Specialcolormap + (int)SpecialColormaps.Size())
|
||||
{
|
||||
inf.blend = (EBlend)(BLEND_SPECIALCOLORMAP1 + translation - STRange_Specialcolormap);
|
||||
}
|
||||
|
||||
int trans = CopyTrueColorPixels(&bmp, exx, exx, 0, translation >= STRange_Min ? &inf : nullptr);
|
||||
CheckTrans(buffer, W*H, trans);
|
||||
isTransparent = bTranslucent;
|
||||
// alpha texture for legacy mode
|
||||
if (translation == STRange_AlphaTexture)
|
||||
{
|
||||
for (int i = 0; i < W*H; i++)
|
||||
{
|
||||
int b = buffer[4 * i];
|
||||
int g = buffer[4 * i + 1];
|
||||
int r = buffer[4 * i + 2];
|
||||
int gray = Luminance(r, g, b);
|
||||
buffer[4 * i] = 255;
|
||||
buffer[4 * i + 1] = 255;
|
||||
buffer[4 * i + 2] = 255;
|
||||
buffer[4 * i + 3] = (buffer[4 * i + 3] * gray) >> 8;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// When using translations everything must be mapped to the base palette.
|
||||
// so use CopyTrueColorTranslated
|
||||
CopyTrueColorTranslated(&bmp, exx, exx, 0, FUniquePalette::GetPalette(translation));
|
||||
isTransparent = 0;
|
||||
// This is not conclusive for setting the texture's transparency info.
|
||||
}
|
||||
|
||||
// [BB] The hqnx upsampling (not the scaleN one) destroys partial transparency, don't upsamle textures using it.
|
||||
// [BB] Potentially upsample the buffer.
|
||||
if (flags & CTF_ProcessData)
|
||||
{
|
||||
buffer = CreateUpsampledTextureBuffer(buffer, W, H, w, h, !!isTransparent);
|
||||
ProcessData(buffer, w, h, false);
|
||||
}
|
||||
}
|
||||
else
|
||||
if ((flags & CTF_MaybeWarped) && bWarped && w*h <= 256 * 256) // do not software-warp larger textures, especially on the old systems that still need this fallback.
|
||||
{
|
||||
// When using translations everything must be mapped to the base palette.
|
||||
// so use CopyTrueColorTranslated
|
||||
CopyTrueColorTranslated(&bmp, exx, exx, 0, FUniquePalette::GetPalette(translation));
|
||||
isTransparent = 0;
|
||||
// This is not conclusive for setting the texture's transparency info.
|
||||
// need to do software warping
|
||||
FWarpTexture *wt = static_cast<FWarpTexture*>(this);
|
||||
unsigned char *warpbuffer = new unsigned char[w*h * 4];
|
||||
WarpBuffer((uint32_t*)warpbuffer, (const uint32_t*)buffer, w, h, wt->WidthOffsetMultiplier, wt->HeightOffsetMultiplier, screen->FrameTime, wt->Speed, bWarped);
|
||||
delete[] buffer;
|
||||
buffer = warpbuffer;
|
||||
wt->GenTime[0] = screen->FrameTime;
|
||||
}
|
||||
|
||||
// [BB] The hqnx upsampling (not the scaleN one) destroys partial transparency, don't upsamle textures using it.
|
||||
// [BB] Potentially upsample the buffer.
|
||||
if (flags & CTF_ProcessData)
|
||||
{
|
||||
buffer = CreateUpsampledTextureBuffer(buffer, W, H, w, h, !!isTransparent);
|
||||
ProcessData(buffer, w, h, false);
|
||||
}
|
||||
return buffer;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue