Precache, Unload and FillSimplePoly bug fix

This commit is contained in:
Magnus Norddahl 2016-06-13 21:39:55 +02:00
parent 3ce2d8365d
commit 8ba6a4f175
22 changed files with 33 additions and 52 deletions

View File

@ -35,7 +35,6 @@ public:
const BYTE *GetColumn (unsigned int column, const Span **spans_out);
const BYTE *GetPixels ();
bool CheckModified ();
void Unload ();
void SetVial (int level);
@ -90,10 +89,6 @@ bool FHealthBar::CheckModified ()
return NeedRefresh;
}
void FHealthBar::Unload ()
{
}
const BYTE *FHealthBar::GetColumn (unsigned int column, const Span **spans_out)
{
if (NeedRefresh)

View File

@ -78,7 +78,6 @@ public:
const BYTE *GetColumn(unsigned int column, const Span **spans_out);
const BYTE *GetPixels();
void Unload();
bool CheckModified();
protected:
@ -212,10 +211,6 @@ bool FBackdropTexture::CheckModified()
return LastRenderTic != gametic;
}
void FBackdropTexture::Unload()
{
}
//=============================================================================
//
//

View File

@ -87,9 +87,9 @@ void FSoftwareRenderer::PrecacheTexture(FTexture *tex, int cache)
if (cache & FTextureManager::HIT_Columnmode)
{
const FTexture::Span *spanp;
/*if (r_swtruecolor)
if (r_swtruecolor)
tex->GetColumnBgra(0, &spanp);
else*/
else
tex->GetColumn(0, &spanp);
}
else if (cache != 0)

View File

@ -122,6 +122,7 @@ void FAutomapTexture::Unload ()
delete[] Pixels;
Pixels = NULL;
}
FTexture::Unload();
}
//==========================================================================

View File

@ -56,7 +56,6 @@ public:
const BYTE *GetColumn (unsigned int column, const Span **spans_out);
const BYTE *GetPixels ();
void Unload ();
protected:
const BYTE *Pixels;
@ -103,17 +102,6 @@ FBuildTexture::~FBuildTexture ()
//
//==========================================================================
void FBuildTexture::Unload ()
{
// Nothing to do, since the pixels are accessed from memory-mapped files directly
}
//==========================================================================
//
//
//
//==========================================================================
const BYTE *FBuildTexture::GetPixels ()
{
return Pixels;

View File

@ -183,6 +183,8 @@ void FCanvasTexture::Unload ()
CanvasBgra->Destroy();
CanvasBgra = NULL;
}
FTexture::Unload();
}
bool FCanvasTexture::CheckModified ()

View File

@ -401,6 +401,7 @@ void FDDSTexture::Unload ()
delete[] Pixels;
Pixels = NULL;
}
FTexture::Unload();
}
//==========================================================================

View File

@ -138,6 +138,7 @@ void FFlatTexture::Unload ()
delete[] Pixels;
Pixels = NULL;
}
FTexture::Unload();
}
//==========================================================================

View File

@ -142,6 +142,7 @@ void FIMGZTexture::Unload ()
delete[] Pixels;
Pixels = NULL;
}
FTexture::Unload();
}
//==========================================================================

View File

@ -196,7 +196,6 @@ public:
protected:
BYTE *Pixels;
std::vector<uint32_t> PixelsBgra;
Span DummySpans[2];
void MakeTexture ();
@ -300,7 +299,7 @@ void FJPEGTexture::Unload ()
{
delete[] Pixels;
Pixels = NULL;
PixelsBgra.clear();
FTexture::Unload();
}
//==========================================================================

View File

@ -362,6 +362,7 @@ void FMultiPatchTexture::Unload ()
delete[] Pixels;
Pixels = NULL;
}
FTexture::Unload();
}
//==========================================================================

View File

@ -184,6 +184,7 @@ void FPatchTexture::Unload ()
delete[] Pixels;
Pixels = NULL;
}
FTexture::Unload();
}
//==========================================================================

View File

@ -191,6 +191,7 @@ void FPCXTexture::Unload ()
delete[] Pixels;
Pixels = NULL;
}
FTexture::Unload();
}
//==========================================================================

View File

@ -67,7 +67,6 @@ protected:
FString SourceFile;
BYTE *Pixels;
std::vector<uint32_t> PixelsBgra;
Span **Spans;
BYTE BitDepth;
@ -382,7 +381,7 @@ void FPNGTexture::Unload ()
{
delete[] Pixels;
Pixels = NULL;
PixelsBgra.clear();
FTexture::Unload();
}
//==========================================================================

View File

@ -206,6 +206,7 @@ void FRawPageTexture::Unload ()
delete[] Pixels;
Pixels = NULL;
}
FTexture::Unload();
}
//==========================================================================

View File

@ -176,6 +176,11 @@ FTexture::~FTexture ()
KillNative();
}
void FTexture::Unload()
{
PixelsBgra = std::vector<uint32_t>();
}
const uint32_t *FTexture::GetColumnBgra(unsigned int column, const Span **spans_out)
{
const uint32_t *pixels = GetPixelsBgra();
@ -189,16 +194,19 @@ const uint32_t *FTexture::GetColumnBgra(unsigned int column, const Span **spans_
const uint32_t *FTexture::GetPixelsBgra()
{
if (BgraPixels.empty())
if (PixelsBgra.empty())
{
GetColumn(0, nullptr);
const BYTE *indices = GetPixels();
BgraPixels.resize(Width * Height);
if (indices == nullptr)
return nullptr;
PixelsBgra.resize(Width * Height);
for (int i = 0; i < Width * Height; i++)
{
BgraPixels[i] = GPalette.BaseColors[indices[i]].d;
PixelsBgra[i] = GPalette.BaseColors[indices[i]].d;
}
}
return BgraPixels.data();
return PixelsBgra.data();
}
bool FTexture::CheckModified ()
@ -642,10 +650,6 @@ FDummyTexture::FDummyTexture ()
UseType = TEX_Null;
}
void FDummyTexture::Unload ()
{
}
void FDummyTexture::SetSize (int width, int height)
{
Width = width;

View File

@ -192,7 +192,7 @@ public:
virtual FTexture *GetRedirect(bool wantwarped);
virtual FTexture *GetRawTexture(); // for FMultiPatchTexture to override
virtual void Unload () = 0;
virtual void Unload ();
// Returns the native pixel format for this image
virtual FTextureFormat GetFormat();
@ -269,8 +269,7 @@ protected:
Rotations = other->Rotations;
}
private:
std::vector<uint32_t> BgraPixels;
std::vector<uint32_t> PixelsBgra;
public:
static void FlipSquareBlock (BYTE *block, int x, int y);
@ -472,7 +471,6 @@ public:
FDummyTexture ();
const BYTE *GetColumn (unsigned int column, const Span **spans_out);
const BYTE *GetPixels ();
void Unload ();
void SetSize (int width, int height);
};

View File

@ -181,6 +181,7 @@ void FTGATexture::Unload ()
delete[] Pixels;
Pixels = NULL;
}
FTexture::Unload();
}
//==========================================================================

View File

@ -74,6 +74,7 @@ void FWarpTexture::Unload ()
Spans = NULL;
}
SourcePic->Unload ();
FTexture::Unload();
}
bool FWarpTexture::CheckModified ()

View File

@ -1403,7 +1403,7 @@ void DCanvas::FillSimplePoly(FTexture *tex, FVector2 *points, int npoints,
R_SetSpanColormap(colormap, clamp(shade >> FRACBITS, 0, NUMCOLORMAPS - 1));
else
R_SetSpanColormap(&identitycolormap, 0);
R_SetSpanSource(tex->GetPixels());
R_SetSpanSource(r_swtruecolor ? (const BYTE*)tex->GetPixelsBgra() : tex->GetPixels());
scalex = double(1u << (32 - ds_xbits)) / scalex;
scaley = double(1u << (32 - ds_ybits)) / scaley;
ds_xstep = xs_RoundToInt(cosrot * scalex);

View File

@ -1662,6 +1662,7 @@ void FFontChar1::Unload ()
delete[] Pixels;
Pixels = NULL;
}
FTexture::Unload();
}
//==========================================================================
@ -1723,6 +1724,7 @@ void FFontChar2::Unload ()
delete[] Pixels;
Pixels = NULL;
}
FTexture::Unload();
}
//==========================================================================

View File

@ -117,7 +117,6 @@ public:
const BYTE *GetColumn(unsigned int column, const Span **spans_out);
const BYTE *GetPixels();
void Unload();
bool CheckModified();
void SetTranslation(int num);
@ -1076,16 +1075,6 @@ void FPaletteTester::SetTranslation(int num)
}
}
//==========================================================================
//
// FPaletteTester :: Unload
//
//==========================================================================
void FPaletteTester::Unload()
{
}
//==========================================================================
//
// FPaletteTester :: GetColumn