mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-11 15:22:15 +00:00
- moved the bit size variables to FSoftwareTexture
They are only needed by the software rasterizer.
This commit is contained in:
parent
18c1a3abe5
commit
bde3558dc2
22 changed files with 61 additions and 129 deletions
|
@ -160,7 +160,7 @@ FMaterial::FMaterial(FTexture * tx, bool expanded)
|
||||||
mShaderIndex = SHADER_Default;
|
mShaderIndex = SHADER_Default;
|
||||||
sourcetex = tex = tx;
|
sourcetex = tex = tx;
|
||||||
|
|
||||||
if (tx->UseType == ETextureType::SWCanvas && tx->WidthBits == 0)
|
if (tx->UseType == ETextureType::SWCanvas && static_cast<FWrapperTexture*>(tx)->GetColorFormat() == 0)
|
||||||
{
|
{
|
||||||
mShaderIndex = SHADER_Paletted;
|
mShaderIndex = SHADER_Paletted;
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,9 +70,6 @@ FVoxelTexture::FVoxelTexture(FVoxel *vox)
|
||||||
SourceVox = vox;
|
SourceVox = vox;
|
||||||
Width = 16;
|
Width = 16;
|
||||||
Height = 16;
|
Height = 16;
|
||||||
WidthBits = 4;
|
|
||||||
HeightBits = 4;
|
|
||||||
WidthMask = 15;
|
|
||||||
bNoCompress = true;
|
bNoCompress = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,6 +41,40 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//==========================================================================
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//==========================================================================
|
||||||
|
|
||||||
|
void FSoftwareTexture::CalcBitSize ()
|
||||||
|
{
|
||||||
|
// WidthBits is rounded down, and HeightBits is rounded up
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; (1 << i) < GetWidth(); ++i)
|
||||||
|
{ }
|
||||||
|
|
||||||
|
WidthBits = i;
|
||||||
|
|
||||||
|
// Having WidthBits that would allow for columns past the end of the
|
||||||
|
// texture is not allowed, even if it means the entire texture is
|
||||||
|
// not drawn.
|
||||||
|
if (GetWidth() < (1 << WidthBits))
|
||||||
|
{
|
||||||
|
WidthBits--;
|
||||||
|
}
|
||||||
|
WidthMask = (1 << WidthBits) - 1;
|
||||||
|
|
||||||
|
// <hr>The minimum height is 2, because we cannot shift right 32 bits.</hr>
|
||||||
|
// Scratch that. Somebody actually made a 1x1 texture, so now we have to handle it.
|
||||||
|
for (i = 0; (1 << i) < GetHeight(); ++i)
|
||||||
|
{ }
|
||||||
|
|
||||||
|
HeightBits = i;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
|
@ -61,7 +95,7 @@ const uint32_t *FSoftwareTexture::GetColumnBgra(unsigned int column, const FSoft
|
||||||
|
|
||||||
const uint32_t *FSoftwareTexture::GetPixelsBgra()
|
const uint32_t *FSoftwareTexture::GetPixelsBgra()
|
||||||
{
|
{
|
||||||
if (PixelsBgra.empty() || CheckModified(DefaultRenderStyle()))
|
if (PixelsBgra.Size() == 0 || CheckModified(DefaultRenderStyle()))
|
||||||
{
|
{
|
||||||
if (!GetColumn(DefaultRenderStyle(), 0, nullptr))
|
if (!GetColumn(DefaultRenderStyle(), 0, nullptr))
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -71,7 +105,7 @@ const uint32_t *FSoftwareTexture::GetPixelsBgra()
|
||||||
mTexture->CopyTrueColorPixels(&bitmap, 0, 0);
|
mTexture->CopyTrueColorPixels(&bitmap, 0, 0);
|
||||||
GenerateBgraFromBitmap(bitmap);
|
GenerateBgraFromBitmap(bitmap);
|
||||||
}
|
}
|
||||||
return PixelsBgra.data();
|
return PixelsBgra.Data();
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
@ -191,7 +225,7 @@ void FSoftwareTexture::GenerateBgraFromBitmap(const FBitmap &bitmap)
|
||||||
|
|
||||||
// Transpose
|
// Transpose
|
||||||
const uint32_t *src = (const uint32_t *)bitmap.GetPixels();
|
const uint32_t *src = (const uint32_t *)bitmap.GetPixels();
|
||||||
uint32_t *dest = PixelsBgra.data();
|
uint32_t *dest = PixelsBgra.Data();
|
||||||
for (int x = 0; x < GetWidth(); x++)
|
for (int x = 0; x < GetWidth(); x++)
|
||||||
{
|
{
|
||||||
for (int y = 0; y < GetHeight(); y++)
|
for (int y = 0; y < GetHeight(); y++)
|
||||||
|
@ -213,7 +247,7 @@ void FSoftwareTexture::CreatePixelsBgraWithMipmaps()
|
||||||
int h = MAX(GetHeight() >> i, 1);
|
int h = MAX(GetHeight() >> i, 1);
|
||||||
buffersize += w * h;
|
buffersize += w * h;
|
||||||
}
|
}
|
||||||
PixelsBgra.resize(buffersize, 0xffff0000);
|
PixelsBgra.Resize(buffersize);
|
||||||
}
|
}
|
||||||
|
|
||||||
int FSoftwareTexture::MipmapLevels()
|
int FSoftwareTexture::MipmapLevels()
|
||||||
|
@ -249,7 +283,7 @@ void FSoftwareTexture::GenerateBgraMipmaps()
|
||||||
};
|
};
|
||||||
|
|
||||||
int levels = MipmapLevels();
|
int levels = MipmapLevels();
|
||||||
std::vector<Color4f> image(PixelsBgra.size());
|
std::vector<Color4f> image(PixelsBgra.Size());
|
||||||
|
|
||||||
// Convert to normalized linear colorspace
|
// Convert to normalized linear colorspace
|
||||||
{
|
{
|
||||||
|
@ -335,7 +369,7 @@ void FSoftwareTexture::GenerateBgraMipmaps()
|
||||||
// Convert to bgra8 sRGB colorspace
|
// Convert to bgra8 sRGB colorspace
|
||||||
{
|
{
|
||||||
Color4f *src = image.data() + GetWidth() * GetHeight();
|
Color4f *src = image.data() + GetWidth() * GetHeight();
|
||||||
uint32_t *dest = PixelsBgra.data() + GetWidth() * GetHeight();
|
uint32_t *dest = PixelsBgra.Data() + GetWidth() * GetHeight();
|
||||||
for (int i = 1; i < levels; i++)
|
for (int i = 1; i < levels; i++)
|
||||||
{
|
{
|
||||||
int w = MAX(GetWidth() >> i, 1);
|
int w = MAX(GetWidth() >> i, 1);
|
||||||
|
@ -362,7 +396,7 @@ void FSoftwareTexture::GenerateBgraMipmaps()
|
||||||
|
|
||||||
void FSoftwareTexture::GenerateBgraMipmapsFast()
|
void FSoftwareTexture::GenerateBgraMipmapsFast()
|
||||||
{
|
{
|
||||||
uint32_t *src = PixelsBgra.data();
|
uint32_t *src = PixelsBgra.Data();
|
||||||
uint32_t *dest = src + GetWidth() * GetHeight();
|
uint32_t *dest = src + GetWidth() * GetHeight();
|
||||||
int levels = MipmapLevels();
|
int levels = MipmapLevels();
|
||||||
for (int i = 1; i < levels; i++)
|
for (int i = 1; i < levels; i++)
|
||||||
|
@ -413,9 +447,9 @@ const uint8_t *FSoftwareTexture::GetColumn(FRenderStyle style, unsigned int colu
|
||||||
auto Pixeldata = GetPixels(style);
|
auto Pixeldata = GetPixels(style);
|
||||||
if ((unsigned)column >= (unsigned)GetWidth())
|
if ((unsigned)column >= (unsigned)GetWidth())
|
||||||
{
|
{
|
||||||
if (mTexture->WidthMask + 1 == GetWidth())
|
if (WidthMask + 1 == GetWidth())
|
||||||
{
|
{
|
||||||
column &= mTexture->WidthMask;
|
column &= WidthMask;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -15,9 +15,11 @@ class FSoftwareTexture
|
||||||
protected:
|
protected:
|
||||||
FTexture *mTexture;
|
FTexture *mTexture;
|
||||||
FTexture *mSource;
|
FTexture *mSource;
|
||||||
uint8_t *Pixels[2];
|
TArray<uint32_t> PixelsBgra;
|
||||||
std::vector<uint32_t> PixelsBgra;
|
|
||||||
FSoftwareTextureSpan **Spandata[2] = { nullptr, nullptr };
|
FSoftwareTextureSpan **Spandata[2] = { nullptr, nullptr };
|
||||||
|
uint8_t WidthBits = 0, HeightBits = 0;
|
||||||
|
uint16_t WidthMask = 0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -25,6 +27,7 @@ public:
|
||||||
{
|
{
|
||||||
mTexture = tex;
|
mTexture = tex;
|
||||||
mSource = tex;
|
mSource = tex;
|
||||||
|
CalcBitSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~FSoftwareTexture()
|
virtual ~FSoftwareTexture()
|
||||||
|
@ -48,14 +51,15 @@ public:
|
||||||
return mTexture->bMasked;
|
return mTexture->bMasked;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CalcBitSize();
|
||||||
bool UseBasePalette() const { return mTexture->UseBasePalette(); }
|
bool UseBasePalette() const { return mTexture->UseBasePalette(); }
|
||||||
int GetSkyOffset() const { return mTexture->GetSkyOffset(); }
|
int GetSkyOffset() const { return mTexture->GetSkyOffset(); }
|
||||||
PalEntry GetSkyCapColor(bool bottom) const { return mTexture->GetSkyCapColor(bottom); }
|
PalEntry GetSkyCapColor(bool bottom) const { return mTexture->GetSkyCapColor(bottom); }
|
||||||
|
|
||||||
int GetWidth () { return mTexture->GetWidth(); }
|
int GetWidth () { return mTexture->GetWidth(); }
|
||||||
int GetHeight () { return mTexture->GetHeight(); }
|
int GetHeight () { return mTexture->GetHeight(); }
|
||||||
int GetWidthBits() { return mTexture->WidthBits; }
|
int GetWidthBits() { return WidthBits; }
|
||||||
int GetHeightBits() { return mTexture->HeightBits; }
|
int GetHeightBits() { return HeightBits; }
|
||||||
bool Mipmapped() { return mTexture->Mipmapped(); }
|
bool Mipmapped() { return mTexture->Mipmapped(); }
|
||||||
|
|
||||||
int GetScaledWidth () { return mTexture->GetScaledWidth(); }
|
int GetScaledWidth () { return mTexture->GetScaledWidth(); }
|
||||||
|
@ -98,7 +102,7 @@ public:
|
||||||
void Unload()
|
void Unload()
|
||||||
{
|
{
|
||||||
mTexture->Unload();
|
mTexture->Unload();
|
||||||
PixelsBgra = std::vector<uint32_t>();
|
PixelsBgra.Reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns true if the next call to GetPixels() will return an image different from the
|
// Returns true if the next call to GetPixels() will return an image different from the
|
||||||
|
|
|
@ -80,7 +80,6 @@ FAutomapTexture::FAutomapTexture (int lumpnum)
|
||||||
{
|
{
|
||||||
Width = 320;
|
Width = 320;
|
||||||
Height = uint16_t(Wads.LumpLength(lumpnum) / 320);
|
Height = uint16_t(Wads.LumpLength(lumpnum) / 320);
|
||||||
CalcBitSize ();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
|
@ -81,7 +81,6 @@ FBuildTexture::FBuildTexture(const FString &pathprefix, int tilenum, const uint8
|
||||||
Height = height;
|
Height = height;
|
||||||
_LeftOffset[1] = _LeftOffset[0] = left;
|
_LeftOffset[1] = _LeftOffset[0] = left;
|
||||||
_TopOffset[1] = _TopOffset[0] = top;
|
_TopOffset[1] = _TopOffset[0] = top;
|
||||||
CalcBitSize ();
|
|
||||||
Name.Format("%sBTIL%04d", pathprefix.GetChars(), tilenum);
|
Name.Format("%sBTIL%04d", pathprefix.GetChars(), tilenum);
|
||||||
UseType = ETextureType::Override;
|
UseType = ETextureType::Override;
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,15 +41,8 @@ FCanvasTexture::FCanvasTexture (const char *name, int width, int height)
|
||||||
Name = name;
|
Name = name;
|
||||||
Width = width;
|
Width = width;
|
||||||
Height = height;
|
Height = height;
|
||||||
CalcBitSize ();
|
|
||||||
|
|
||||||
bMasked = false;
|
bMasked = false;
|
||||||
/*
|
|
||||||
DummySpans[0].TopOffset = 0;
|
|
||||||
DummySpans[0].Length = height;
|
|
||||||
DummySpans[1].TopOffset = 0;
|
|
||||||
DummySpans[1].Length = 0;
|
|
||||||
*/
|
|
||||||
UseType = ETextureType::Wall;
|
UseType = ETextureType::Wall;
|
||||||
bNeedsUpdate = true;
|
bNeedsUpdate = true;
|
||||||
bDidUpdate = false;
|
bDidUpdate = false;
|
||||||
|
@ -63,33 +56,6 @@ FCanvasTexture::~FCanvasTexture ()
|
||||||
Unload ();
|
Unload ();
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
const uint8_t *FCanvasTexture::GetColumn(FRenderStyle style, unsigned int column, const FSoftwareTextureSpan **spans_out)
|
|
||||||
{
|
|
||||||
bNeedsUpdate = true;
|
|
||||||
if (Canvas == NULL)
|
|
||||||
{
|
|
||||||
MakeTexture (style);
|
|
||||||
}
|
|
||||||
if ((unsigned)column >= (unsigned)Width)
|
|
||||||
{
|
|
||||||
if (WidthMask + 1 == Width)
|
|
||||||
{
|
|
||||||
column &= WidthMask;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
column %= Width;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (spans_out != NULL)
|
|
||||||
{
|
|
||||||
*spans_out = DummySpans;
|
|
||||||
}
|
|
||||||
return Pixels + column*Height;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
const uint8_t *FCanvasTexture::GetPixels (FRenderStyle style)
|
const uint8_t *FCanvasTexture::GetPixels (FRenderStyle style)
|
||||||
{
|
{
|
||||||
bNeedsUpdate = true;
|
bNeedsUpdate = true;
|
||||||
|
|
|
@ -292,7 +292,6 @@ FDDSTexture::FDDSTexture (FileReader &lump, int lumpnum, void *vsurfdesc)
|
||||||
|
|
||||||
Width = uint16_t(surf->Width);
|
Width = uint16_t(surf->Width);
|
||||||
Height = uint16_t(surf->Height);
|
Height = uint16_t(surf->Height);
|
||||||
CalcBitSize ();
|
|
||||||
|
|
||||||
if (surf->PixelFormat.Flags & DDPF_FOURCC)
|
if (surf->PixelFormat.Flags & DDPF_FOURCC)
|
||||||
{
|
{
|
||||||
|
|
|
@ -81,9 +81,7 @@ FEmptyTexture::FEmptyTexture (int lumpnum)
|
||||||
: FWorldTexture(NULL, lumpnum)
|
: FWorldTexture(NULL, lumpnum)
|
||||||
{
|
{
|
||||||
bMasked = true;
|
bMasked = true;
|
||||||
WidthBits = HeightBits = 1;
|
|
||||||
Width = Height = 1;
|
Width = Height = 1;
|
||||||
WidthMask = 0;
|
|
||||||
PixelsAreStatic = 3;
|
PixelsAreStatic = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -92,9 +92,7 @@ FFlatTexture::FFlatTexture (int lumpnum)
|
||||||
|
|
||||||
bMasked = false;
|
bMasked = false;
|
||||||
bTranslucent = false;
|
bTranslucent = false;
|
||||||
WidthBits = HeightBits = bits;
|
|
||||||
Width = Height = 1 << bits;
|
Width = Height = 1 << bits;
|
||||||
WidthMask = (1 << bits) - 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
|
@ -113,7 +113,6 @@ FIMGZTexture::FIMGZTexture (int lumpnum, uint16_t w, uint16_t h, int16_t l, int1
|
||||||
_LeftOffset[1] = _LeftOffset[0] = l;
|
_LeftOffset[1] = _LeftOffset[0] = l;
|
||||||
_TopOffset[1] = _TopOffset[0] = t;
|
_TopOffset[1] = _TopOffset[0] = t;
|
||||||
isalpha = _isalpha;
|
isalpha = _isalpha;
|
||||||
CalcBitSize ();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
@ -132,7 +131,6 @@ uint8_t *FIMGZTexture::MakeTexture (FRenderStyle style)
|
||||||
int dest_adv = Height;
|
int dest_adv = Height;
|
||||||
int dest_rew = Width * Height - 1;
|
int dest_rew = Width * Height - 1;
|
||||||
|
|
||||||
CalcBitSize ();
|
|
||||||
auto Pixels = new uint8_t[Width*Height];
|
auto Pixels = new uint8_t[Width*Height];
|
||||||
dest_p = Pixels;
|
dest_p = Pixels;
|
||||||
|
|
||||||
|
|
|
@ -253,7 +253,6 @@ FJPEGTexture::FJPEGTexture (int lumpnum, int width, int height)
|
||||||
|
|
||||||
Width = width;
|
Width = width;
|
||||||
Height = height;
|
Height = height;
|
||||||
CalcBitSize ();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
|
@ -254,7 +254,6 @@ FMultiPatchTexture::FMultiPatchTexture (const void *texdef, FPatchLookup *patchl
|
||||||
Width = SAFESHORT(mtexture.d->width);
|
Width = SAFESHORT(mtexture.d->width);
|
||||||
Height = SAFESHORT(mtexture.d->height);
|
Height = SAFESHORT(mtexture.d->height);
|
||||||
Name = (char *)mtexture.d->name;
|
Name = (char *)mtexture.d->name;
|
||||||
CalcBitSize ();
|
|
||||||
|
|
||||||
Scale.X = mtexture.d->ScaleX ? mtexture.d->ScaleX / 8. : 1.;
|
Scale.X = mtexture.d->ScaleX ? mtexture.d->ScaleX / 8. : 1.;
|
||||||
Scale.Y = mtexture.d->ScaleY ? mtexture.d->ScaleY / 8. : 1.;
|
Scale.Y = mtexture.d->ScaleY ? mtexture.d->ScaleY / 8. : 1.;
|
||||||
|
@ -400,9 +399,7 @@ uint8_t *GetBlendMap(PalEntry blend, uint8_t *blendwork)
|
||||||
|
|
||||||
uint8_t *FMultiPatchTexture::MakeTexture (FRenderStyle style)
|
uint8_t *FMultiPatchTexture::MakeTexture (FRenderStyle style)
|
||||||
{
|
{
|
||||||
// Add a little extra space at the end if the texture's height is not
|
int numpix = Width * Height;
|
||||||
// a power of 2, in case somebody accidentally makes it repeat vertically.
|
|
||||||
int numpix = Width * Height + (1 << HeightBits) - Height;
|
|
||||||
uint8_t blendwork[256];
|
uint8_t blendwork[256];
|
||||||
bool buildrgb = bComplex;
|
bool buildrgb = bComplex;
|
||||||
|
|
||||||
|
@ -620,7 +617,6 @@ void FMultiPatchTexture::CheckForHacks ()
|
||||||
Height == 128)
|
Height == 128)
|
||||||
{
|
{
|
||||||
Height = 200;
|
Height = 200;
|
||||||
HeightBits = 8;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1220,8 +1216,6 @@ FMultiPatchTexture::FMultiPatchTexture (FScanner &sc, ETextureType usetype)
|
||||||
Printf("Texture %s has invalid dimensions (%d, %d)\n", Name.GetChars(), Width, Height);
|
Printf("Texture %s has invalid dimensions (%d, %d)\n", Name.GetChars(), Width, Height);
|
||||||
Width = Height = 1;
|
Width = Height = 1;
|
||||||
}
|
}
|
||||||
CalcBitSize ();
|
|
||||||
|
|
||||||
|
|
||||||
sc.SetCMode(false);
|
sc.SetCMode(false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -159,7 +159,6 @@ FPatchTexture::FPatchTexture (int lumpnum, patch_t * header, bool isalphatex)
|
||||||
_LeftOffset[1] = _LeftOffset[0] = header->leftoffset;
|
_LeftOffset[1] = _LeftOffset[0] = header->leftoffset;
|
||||||
_TopOffset[1] = _TopOffset[0] = header->topoffset;
|
_TopOffset[1] = _TopOffset[0] = header->topoffset;
|
||||||
DetectBadPatches();
|
DetectBadPatches();
|
||||||
CalcBitSize ();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
@ -208,9 +207,7 @@ uint8_t *FPatchTexture::MakeTexture (FRenderStyle style)
|
||||||
return Pixels;
|
return Pixels;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add a little extra space at the end if the texture's height is not
|
int numpix = Width * Height;
|
||||||
// a power of 2, in case somebody accidentally makes it repeat vertically.
|
|
||||||
int numpix = Width * Height + (1 << HeightBits) - Height;
|
|
||||||
|
|
||||||
numspans = Width;
|
numspans = Width;
|
||||||
|
|
||||||
|
|
|
@ -148,7 +148,6 @@ FPCXTexture::FPCXTexture(int lumpnum, PCXHeader & hdr)
|
||||||
bMasked = false;
|
bMasked = false;
|
||||||
Width = LittleShort(hdr.xmax) - LittleShort(hdr.xmin) + 1;
|
Width = LittleShort(hdr.xmax) - LittleShort(hdr.xmin) + 1;
|
||||||
Height = LittleShort(hdr.ymax) - LittleShort(hdr.ymin) + 1;
|
Height = LittleShort(hdr.ymax) - LittleShort(hdr.ymin) + 1;
|
||||||
CalcBitSize();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
|
@ -209,7 +209,6 @@ FPNGTexture::FPNGTexture (FileReader &lump, int lumpnum, const FString &filename
|
||||||
|
|
||||||
Width = width;
|
Width = width;
|
||||||
Height = height;
|
Height = height;
|
||||||
CalcBitSize ();
|
|
||||||
|
|
||||||
memset(trans, 255, 256);
|
memset(trans, 255, 256);
|
||||||
|
|
||||||
|
|
|
@ -159,9 +159,6 @@ FRawPageTexture::FRawPageTexture (int lumpnum)
|
||||||
{
|
{
|
||||||
Width = 320;
|
Width = 320;
|
||||||
Height = 200;
|
Height = 200;
|
||||||
WidthBits = 8;
|
|
||||||
HeightBits = 8;
|
|
||||||
WidthMask = 255;
|
|
||||||
|
|
||||||
// Special case hack for Heretic's E2 end pic. This is not going to be exposed as an editing feature because the implications would be horrible.
|
// Special case hack for Heretic's E2 end pic. This is not going to be exposed as an editing feature because the implications would be horrible.
|
||||||
if (Name.CompareNoCase("E2END") == 0 && gameinfo.gametype == GAME_Heretic)
|
if (Name.CompareNoCase("E2END") == 0 && gameinfo.gametype == GAME_Heretic)
|
||||||
|
|
|
@ -51,7 +51,6 @@ public:
|
||||||
Name.Format("BarShader%c%c", vertical ? 'v' : 'h', reverse ? 'r' : 'f');
|
Name.Format("BarShader%c%c", vertical ? 'v' : 'h', reverse ? 'r' : 'f');
|
||||||
Width = vertical ? 2 : 256;
|
Width = vertical ? 2 : 256;
|
||||||
Height = vertical ? 256 : 2;
|
Height = vertical ? 256 : 2;
|
||||||
CalcBitSize();
|
|
||||||
bMasked = false;
|
bMasked = false;
|
||||||
bTranslucent = false;
|
bTranslucent = false;
|
||||||
PixelsAreStatic = 2; // The alpha buffer is static, but if this gets used as a regular texture, a separate buffer needs to be made.
|
PixelsAreStatic = 2; // The alpha buffer is static, but if this gets used as a regular texture, a separate buffer needs to be made.
|
||||||
|
|
|
@ -136,7 +136,6 @@ FTGATexture::FTGATexture (int lumpnum, TGAHeader * hdr)
|
||||||
Height = hdr->height;
|
Height = hdr->height;
|
||||||
// Alpha channel is used only for 32 bit RGBA and paletted images with RGBA palettes.
|
// Alpha channel is used only for 32 bit RGBA and paletted images with RGBA palettes.
|
||||||
bMasked = (hdr->img_desc&15)==8 && (hdr->bpp==32 || (hdr->img_type==1 && hdr->cm_size==32));
|
bMasked = (hdr->img_desc&15)==8 && (hdr->bpp==32 || (hdr->img_type==1 && hdr->cm_size==32));
|
||||||
CalcBitSize();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
|
@ -177,10 +177,10 @@ FTexture * FTexture::CreateTexture (const char *name, int lumpnum, ETextureType
|
||||||
|
|
||||||
FTexture::FTexture (const char *name, int lumpnum)
|
FTexture::FTexture (const char *name, int lumpnum)
|
||||||
:
|
:
|
||||||
WidthBits(0), HeightBits(0), Scale(1,1), SourceLump(lumpnum),
|
Scale(1,1), SourceLump(lumpnum),
|
||||||
UseType(ETextureType::Any), bNoDecals(false), bNoRemap0(false), bWorldPanning(false),
|
UseType(ETextureType::Any), bNoDecals(false), bNoRemap0(false), bWorldPanning(false),
|
||||||
bMasked(true), bAlphaTexture(false), bHasCanvas(false), bWarped(0), bComplex(false), bMultiPatch(false), bKeepAround(false), bFullNameTexture(false),
|
bMasked(true), bAlphaTexture(false), bHasCanvas(false), bWarped(0), bComplex(false), bMultiPatch(false), bKeepAround(false), bFullNameTexture(false),
|
||||||
Rotations(0xFFFF), SkyOffset(0), Width(0), Height(0), WidthMask(0)
|
Rotations(0xFFFF), SkyOffset(0), Width(0), Height(0)
|
||||||
{
|
{
|
||||||
bBrightmapChecked = false;
|
bBrightmapChecked = false;
|
||||||
bGlowing = false;
|
bGlowing = false;
|
||||||
|
@ -254,39 +254,6 @@ void FTexture::SetFrontSkyLayer ()
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
void FTexture::CalcBitSize ()
|
|
||||||
{
|
|
||||||
// WidthBits is rounded down, and HeightBits is rounded up
|
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = 0; (1 << i) < Width; ++i)
|
|
||||||
{ }
|
|
||||||
|
|
||||||
WidthBits = i;
|
|
||||||
|
|
||||||
// Having WidthBits that would allow for columns past the end of the
|
|
||||||
// texture is not allowed, even if it means the entire texture is
|
|
||||||
// not drawn.
|
|
||||||
if (Width < (1 << WidthBits))
|
|
||||||
{
|
|
||||||
WidthBits--;
|
|
||||||
}
|
|
||||||
WidthMask = (1 << WidthBits) - 1;
|
|
||||||
|
|
||||||
// <hr>The minimum height is 2, because we cannot shift right 32 bits.</hr>
|
|
||||||
// Scratch that. Somebody actually made a 1x1 texture, so now we have to handle it.
|
|
||||||
for (i = 0; (1 << i) < Height; ++i)
|
|
||||||
{ }
|
|
||||||
|
|
||||||
HeightBits = i;
|
|
||||||
}
|
|
||||||
|
|
||||||
//==========================================================================
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//==========================================================================
|
|
||||||
|
|
||||||
void FTexture::CopyToBlock (uint8_t *dest, int dwidth, int dheight, int xpos, int ypos, int rotate, const uint8_t *translation, FRenderStyle style)
|
void FTexture::CopyToBlock (uint8_t *dest, int dwidth, int dheight, int xpos, int ypos, int rotate, const uint8_t *translation, FRenderStyle style)
|
||||||
{
|
{
|
||||||
const uint8_t *pixels = GetPixels(style);
|
const uint8_t *pixels = GetPixels(style);
|
||||||
|
@ -1102,9 +1069,6 @@ FDummyTexture::FDummyTexture ()
|
||||||
{
|
{
|
||||||
Width = 64;
|
Width = 64;
|
||||||
Height = 64;
|
Height = 64;
|
||||||
HeightBits = 6;
|
|
||||||
WidthBits = 6;
|
|
||||||
WidthMask = 63;
|
|
||||||
UseType = ETextureType::Null;
|
UseType = ETextureType::Null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1112,7 +1076,6 @@ void FDummyTexture::SetSize (int width, int height)
|
||||||
{
|
{
|
||||||
Width = width;
|
Width = width;
|
||||||
Height = height;
|
Height = height;
|
||||||
CalcBitSize ();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1126,7 +1089,7 @@ FWrapperTexture::FWrapperTexture(int w, int h, int bits)
|
||||||
{
|
{
|
||||||
Width = w;
|
Width = w;
|
||||||
Height = h;
|
Height = h;
|
||||||
WidthBits = bits;
|
Format = bits;
|
||||||
UseType = ETextureType::SWCanvas;
|
UseType = ETextureType::SWCanvas;
|
||||||
bNoCompress = true;
|
bNoCompress = true;
|
||||||
SystemTexture[0] = screen->CreateHardwareTexture(this);
|
SystemTexture[0] = screen->CreateHardwareTexture(this);
|
||||||
|
|
|
@ -315,8 +315,6 @@ public:
|
||||||
protected:
|
protected:
|
||||||
//int16_t LeftOffset, TopOffset;
|
//int16_t LeftOffset, TopOffset;
|
||||||
|
|
||||||
uint8_t WidthBits, HeightBits;
|
|
||||||
|
|
||||||
DVector2 Scale;
|
DVector2 Scale;
|
||||||
|
|
||||||
int SourceLump;
|
int SourceLump;
|
||||||
|
@ -455,16 +453,13 @@ protected:
|
||||||
_TopOffset[1] = BaseTexture->_TopOffset[1];
|
_TopOffset[1] = BaseTexture->_TopOffset[1];
|
||||||
_LeftOffset[0] = BaseTexture->_LeftOffset[0];
|
_LeftOffset[0] = BaseTexture->_LeftOffset[0];
|
||||||
_LeftOffset[1] = BaseTexture->_LeftOffset[1];
|
_LeftOffset[1] = BaseTexture->_LeftOffset[1];
|
||||||
WidthBits = BaseTexture->WidthBits;
|
|
||||||
HeightBits = BaseTexture->HeightBits;
|
|
||||||
Scale = BaseTexture->Scale;
|
Scale = BaseTexture->Scale;
|
||||||
WidthMask = (1 << WidthBits) - 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetScaledSize(int fitwidth, int fitheight);
|
void SetScaledSize(int fitwidth, int fitheight);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
uint16_t Width, Height, WidthMask;
|
uint16_t Width, Height;
|
||||||
int16_t _LeftOffset[2], _TopOffset[2];
|
int16_t _LeftOffset[2], _TopOffset[2];
|
||||||
static uint8_t GrayMap[256];
|
static uint8_t GrayMap[256];
|
||||||
uint8_t *GetRemap(FRenderStyle style, bool srcisgrayscale = false)
|
uint8_t *GetRemap(FRenderStyle style, bool srcisgrayscale = false)
|
||||||
|
@ -516,7 +511,6 @@ protected:
|
||||||
|
|
||||||
FTexture (const char *name = NULL, int lumpnum = -1);
|
FTexture (const char *name = NULL, int lumpnum = -1);
|
||||||
|
|
||||||
void CalcBitSize ();
|
|
||||||
void CopyInfo(FTexture *other)
|
void CopyInfo(FTexture *other)
|
||||||
{
|
{
|
||||||
CopySize(other);
|
CopySize(other);
|
||||||
|
@ -813,6 +807,7 @@ public:
|
||||||
// A wrapper around a hardware texture, to allow using it in the 2D drawing interface.
|
// A wrapper around a hardware texture, to allow using it in the 2D drawing interface.
|
||||||
class FWrapperTexture : public FTexture
|
class FWrapperTexture : public FTexture
|
||||||
{
|
{
|
||||||
|
int Format;
|
||||||
public:
|
public:
|
||||||
FWrapperTexture(int w, int h, int bits = 1);
|
FWrapperTexture(int w, int h, int bits = 1);
|
||||||
IHardwareTexture *GetSystemTexture(int slot)
|
IHardwareTexture *GetSystemTexture(int slot)
|
||||||
|
@ -822,7 +817,7 @@ public:
|
||||||
|
|
||||||
int GetColorFormat() const
|
int GetColorFormat() const
|
||||||
{
|
{
|
||||||
return WidthBits;
|
return Format;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1659,7 +1659,6 @@ FFontChar2::FFontChar2 (int sourcelump, int sourcepos, int width, int height, in
|
||||||
Height = height;
|
Height = height;
|
||||||
_LeftOffset[1] = _LeftOffset[0] = leftofs;
|
_LeftOffset[1] = _LeftOffset[0] = leftofs;
|
||||||
_TopOffset[1] = _TopOffset[0] = topofs;
|
_TopOffset[1] = _TopOffset[0] = topofs;
|
||||||
CalcBitSize ();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
Loading…
Reference in a new issue