mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-26 05:51:20 +00:00
- Convert the entire image backend infrastructure to be animation-friendly
This commit is contained in:
parent
53d8a5bb2c
commit
7c90ea6b84
31 changed files with 145 additions and 128 deletions
|
@ -109,8 +109,8 @@ class FHexFontChar : public FImageSource
|
|||
public:
|
||||
FHexFontChar(uint8_t *sourcedata, int swidth, int width, int height);
|
||||
|
||||
PalettedPixels CreatePalettedPixels(int conversion) override;
|
||||
int CopyPixels(FBitmap* bmp, int conversion);
|
||||
PalettedPixels CreatePalettedPixels(int conversion, int frame = 0) override;
|
||||
int CopyPixels(FBitmap* bmp, int conversion, int frame = 0);
|
||||
|
||||
protected:
|
||||
int SourceWidth;
|
||||
|
@ -144,7 +144,7 @@ FHexFontChar::FHexFontChar (uint8_t *sourcedata, int swidth, int width, int heig
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
PalettedPixels FHexFontChar::CreatePalettedPixels(int)
|
||||
PalettedPixels FHexFontChar::CreatePalettedPixels(int, int)
|
||||
{
|
||||
int destSize = Width * Height;
|
||||
PalettedPixels Pixels(destSize);
|
||||
|
@ -175,7 +175,7 @@ PalettedPixels FHexFontChar::CreatePalettedPixels(int)
|
|||
return Pixels;
|
||||
}
|
||||
|
||||
int FHexFontChar::CopyPixels(FBitmap* bmp, int conversion)
|
||||
int FHexFontChar::CopyPixels(FBitmap* bmp, int conversion, int frame)
|
||||
{
|
||||
if (conversion == luminance) conversion = normal; // luminance images have no use as an RGB source.
|
||||
PalEntry* palette = hexdata.ConsolePal;
|
||||
|
@ -190,8 +190,8 @@ class FHexFontChar2 : public FHexFontChar
|
|||
public:
|
||||
FHexFontChar2(uint8_t *sourcedata, int swidth, int width, int height);
|
||||
|
||||
PalettedPixels CreatePalettedPixels(int conversion) override;
|
||||
int CopyPixels(FBitmap* bmp, int conversion);
|
||||
PalettedPixels CreatePalettedPixels(int conversion, int frame = 0) override;
|
||||
int CopyPixels(FBitmap* bmp, int conversion, int frame = 0);
|
||||
};
|
||||
|
||||
|
||||
|
@ -216,7 +216,7 @@ FHexFontChar2::FHexFontChar2(uint8_t *sourcedata, int swidth, int width, int hei
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
PalettedPixels FHexFontChar2::CreatePalettedPixels(int)
|
||||
PalettedPixels FHexFontChar2::CreatePalettedPixels(int, int)
|
||||
{
|
||||
int destSize = Width * Height;
|
||||
PalettedPixels Pixels(destSize);
|
||||
|
@ -255,7 +255,7 @@ PalettedPixels FHexFontChar2::CreatePalettedPixels(int)
|
|||
return Pixels;
|
||||
}
|
||||
|
||||
int FHexFontChar2::CopyPixels(FBitmap* bmp, int conversion)
|
||||
int FHexFontChar2::CopyPixels(FBitmap* bmp, int conversion, int frame)
|
||||
{
|
||||
if (conversion == luminance) conversion = normal; // luminance images have no use as an RGB source.
|
||||
PalEntry* palette = hexdata.SmallPal;
|
||||
|
|
|
@ -57,8 +57,8 @@ class FVoxelTexture : public FImageSource
|
|||
public:
|
||||
FVoxelTexture(FVoxel *voxel);
|
||||
|
||||
int CopyPixels(FBitmap *bmp, int conversion) override;
|
||||
PalettedPixels CreatePalettedPixels(int conversion) override;
|
||||
int CopyPixels(FBitmap *bmp, int conversion, int frame = 0) override;
|
||||
PalettedPixels CreatePalettedPixels(int conversion, int frame = 0) override;
|
||||
|
||||
protected:
|
||||
FVoxel *SourceVox;
|
||||
|
@ -84,7 +84,7 @@ FVoxelTexture::FVoxelTexture(FVoxel *vox)
|
|||
//
|
||||
//===========================================================================
|
||||
|
||||
PalettedPixels FVoxelTexture::CreatePalettedPixels(int conversion)
|
||||
PalettedPixels FVoxelTexture::CreatePalettedPixels(int conversion, int frame)
|
||||
{
|
||||
// GetPixels gets called when a translated palette is used so we still need to implement it here.
|
||||
PalettedPixels Pixels(256);
|
||||
|
@ -123,7 +123,7 @@ PalettedPixels FVoxelTexture::CreatePalettedPixels(int conversion)
|
|||
//
|
||||
//===========================================================================
|
||||
|
||||
int FVoxelTexture::CopyPixels(FBitmap *bmp, int conversion)
|
||||
int FVoxelTexture::CopyPixels(FBitmap *bmp, int conversion, int frame)
|
||||
{
|
||||
PalEntry pe[256];
|
||||
uint8_t bitmap[256];
|
||||
|
|
|
@ -51,8 +51,8 @@ class FAnmTexture : public FImageSource
|
|||
public:
|
||||
FAnmTexture (int lumpnum, int w, int h);
|
||||
void ReadFrame(uint8_t *buffer, uint8_t *palette);
|
||||
PalettedPixels CreatePalettedPixels(int conversion) override;
|
||||
int CopyPixels(FBitmap *bmp, int conversion) override;
|
||||
PalettedPixels CreatePalettedPixels(int conversion, int frame = 0) override;
|
||||
int CopyPixels(FBitmap *bmp, int conversion, int frame = 0) override;
|
||||
};
|
||||
|
||||
|
||||
|
@ -103,7 +103,7 @@ FAnmTexture::FAnmTexture (int lumpnum, int w, int h)
|
|||
|
||||
void FAnmTexture::ReadFrame(uint8_t *pixels, uint8_t *palette)
|
||||
{
|
||||
auto lump = fileSystem.ReadFile (SourceLump);
|
||||
auto lump = fileSystem.ReadFile (SourceLump);
|
||||
auto source = lump.GetBytes();
|
||||
|
||||
anim_t anim;
|
||||
|
@ -127,7 +127,7 @@ void FAnmTexture::ReadFrame(uint8_t *pixels, uint8_t *palette)
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
PalettedPixels FAnmTexture::CreatePalettedPixels(int conversion)
|
||||
PalettedPixels FAnmTexture::CreatePalettedPixels(int conversion, int frame)
|
||||
{
|
||||
PalettedPixels pixels(Width*Height);
|
||||
uint8_t buffer[64000];
|
||||
|
@ -149,7 +149,7 @@ PalettedPixels FAnmTexture::CreatePalettedPixels(int conversion)
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
int FAnmTexture::CopyPixels(FBitmap *bmp, int conversion)
|
||||
int FAnmTexture::CopyPixels(FBitmap *bmp, int conversion, int frame)
|
||||
{
|
||||
uint8_t buffer[64000];
|
||||
uint8_t palette[768];
|
||||
|
|
|
@ -50,7 +50,7 @@ class FAutomapTexture : public FImageSource
|
|||
{
|
||||
public:
|
||||
FAutomapTexture(int lumpnum);
|
||||
PalettedPixels CreatePalettedPixels(int conversion) override;
|
||||
PalettedPixels CreatePalettedPixels(int conversion, int frame = 0) override;
|
||||
};
|
||||
|
||||
|
||||
|
@ -89,7 +89,7 @@ FAutomapTexture::FAutomapTexture (int lumpnum)
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
PalettedPixels FAutomapTexture::CreatePalettedPixels(int conversion)
|
||||
PalettedPixels FAutomapTexture::CreatePalettedPixels(int conversion, int frame)
|
||||
{
|
||||
int x, y;
|
||||
auto data = fileSystem.ReadFile (SourceLump);
|
||||
|
|
|
@ -43,7 +43,7 @@ class FBrightmapTexture : public FImageSource
|
|||
public:
|
||||
FBrightmapTexture (FImageSource *source);
|
||||
|
||||
int CopyPixels(FBitmap *bmp, int conversion) override;
|
||||
int CopyPixels(FBitmap *bmp, int conversion, int frame = 0) override;
|
||||
|
||||
protected:
|
||||
FImageSource *SourcePic;
|
||||
|
@ -65,7 +65,7 @@ FBrightmapTexture::FBrightmapTexture (FImageSource *source)
|
|||
bMasked = false;
|
||||
}
|
||||
|
||||
int FBrightmapTexture::CopyPixels(FBitmap *bmp, int conversion)
|
||||
int FBrightmapTexture::CopyPixels(FBitmap *bmp, int conversion, int frame)
|
||||
{
|
||||
SourcePic->CopyTranslatedPixels(bmp, GPalette.GlobalBrightmap.Palette);
|
||||
return 0;
|
||||
|
|
|
@ -55,7 +55,7 @@ FBuildTexture::FBuildTexture(const FString &pathprefix, int tilenum, const uint8
|
|||
TopOffset = top;
|
||||
}
|
||||
|
||||
PalettedPixels FBuildTexture::CreatePalettedPixels(int conversion)
|
||||
PalettedPixels FBuildTexture::CreatePalettedPixels(int conversion, int frame)
|
||||
{
|
||||
PalettedPixels Pixels(Width * Height);
|
||||
FRemapTable *Remap = Translation;
|
||||
|
@ -67,7 +67,7 @@ PalettedPixels FBuildTexture::CreatePalettedPixels(int conversion)
|
|||
return Pixels;
|
||||
}
|
||||
|
||||
int FBuildTexture::CopyPixels(FBitmap *bmp, int conversion)
|
||||
int FBuildTexture::CopyPixels(FBitmap *bmp, int conversion, int frame)
|
||||
{
|
||||
PalEntry *Remap = Translation->Palette;
|
||||
bmp->CopyPixelData(0, 0, RawPixels, Width, Height, Height, 1, 0, Remap);
|
||||
|
|
|
@ -164,7 +164,7 @@ class FDDSTexture : public FImageSource
|
|||
public:
|
||||
FDDSTexture (FileReader &lump, int lumpnum, void *surfdesc);
|
||||
|
||||
PalettedPixels CreatePalettedPixels(int conversion) override;
|
||||
PalettedPixels CreatePalettedPixels(int conversion, int frame = 0) override;
|
||||
|
||||
protected:
|
||||
uint32_t Format;
|
||||
|
@ -183,7 +183,7 @@ protected:
|
|||
void DecompressDXT3 (FileReader &lump, bool premultiplied, uint8_t *buffer, int pixelmode);
|
||||
void DecompressDXT5 (FileReader &lump, bool premultiplied, uint8_t *buffer, int pixelmode);
|
||||
|
||||
int CopyPixels(FBitmap *bmp, int conversion) override;
|
||||
int CopyPixels(FBitmap *bmp, int conversion, int frame = 0) override;
|
||||
|
||||
friend class FTexture;
|
||||
};
|
||||
|
@ -372,7 +372,7 @@ void FDDSTexture::CalcBitShift (uint32_t mask, uint8_t *lshiftp, uint8_t *rshift
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
PalettedPixels FDDSTexture::CreatePalettedPixels(int conversion)
|
||||
PalettedPixels FDDSTexture::CreatePalettedPixels(int conversion, int frame)
|
||||
{
|
||||
auto lump = fileSystem.OpenFileReader (SourceLump);
|
||||
|
||||
|
@ -781,7 +781,7 @@ void FDDSTexture::DecompressDXT5 (FileReader &lump, bool premultiplied, uint8_t
|
|||
//
|
||||
//===========================================================================
|
||||
|
||||
int FDDSTexture::CopyPixels(FBitmap *bmp, int conversion)
|
||||
int FDDSTexture::CopyPixels(FBitmap *bmp, int conversion, int frame)
|
||||
{
|
||||
auto lump = fileSystem.OpenFileReader (SourceLump);
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ class FEmptyTexture : public FImageSource
|
|||
{
|
||||
public:
|
||||
FEmptyTexture (int lumpnum);
|
||||
PalettedPixels CreatePalettedPixels(int conversion) override;
|
||||
PalettedPixels CreatePalettedPixels(int conversion, int frame = 0) override;
|
||||
};
|
||||
|
||||
//==========================================================================
|
||||
|
@ -94,7 +94,7 @@ FEmptyTexture::FEmptyTexture (int lumpnum)
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
PalettedPixels FEmptyTexture::CreatePalettedPixels(int conversion)
|
||||
PalettedPixels FEmptyTexture::CreatePalettedPixels(int conversion, int frame)
|
||||
{
|
||||
static uint8_t p;
|
||||
PalettedPixels Pixel(&p, 1);
|
||||
|
|
|
@ -48,7 +48,7 @@ class FFlatTexture : public FImageSource
|
|||
{
|
||||
public:
|
||||
FFlatTexture (int lumpnum);
|
||||
PalettedPixels CreatePalettedPixels(int conversion) override;
|
||||
PalettedPixels CreatePalettedPixels(int conversion, int frame = 0) override;
|
||||
};
|
||||
|
||||
|
||||
|
@ -102,7 +102,7 @@ FFlatTexture::FFlatTexture (int lumpnum)
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
PalettedPixels FFlatTexture::CreatePalettedPixels(int conversion)
|
||||
PalettedPixels FFlatTexture::CreatePalettedPixels(int conversion, int frame)
|
||||
{
|
||||
auto lump = fileSystem.OpenFileReader (SourceLump);
|
||||
PalettedPixels Pixels(Width*Height);
|
||||
|
|
|
@ -66,7 +66,7 @@ FFontChar2::FFontChar2(int sourcelump, int sourcepos, int width, int height, int
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
PalettedPixels FFontChar2::CreatePalettedPixels(int)
|
||||
PalettedPixels FFontChar2::CreatePalettedPixels(int, int)
|
||||
{
|
||||
auto lump = fileSystem.OpenFileReader(SourceLump);
|
||||
int destSize = Width * Height;
|
||||
|
@ -170,7 +170,7 @@ PalettedPixels FFontChar2::CreatePalettedPixels(int)
|
|||
return Pixels;
|
||||
}
|
||||
|
||||
int FFontChar2::CopyPixels(FBitmap* bmp, int conversion)
|
||||
int FFontChar2::CopyPixels(FBitmap* bmp, int conversion, int frame)
|
||||
{
|
||||
if (conversion == luminance) conversion = normal; // luminance images have no use as an RGB source.
|
||||
auto ppix = CreatePalettedPixels(conversion);
|
||||
|
|
|
@ -6,8 +6,8 @@ class FFontChar2 : public FImageSource
|
|||
public:
|
||||
FFontChar2 (int sourcelump, int sourcepos, int width, int height, int leftofs=0, int topofs=0);
|
||||
|
||||
PalettedPixels CreatePalettedPixels(int conversion) override;
|
||||
int CopyPixels(FBitmap* bmp, int conversion);
|
||||
PalettedPixels CreatePalettedPixels(int conversion, int frame = 0) override;
|
||||
int CopyPixels(FBitmap* bmp, int conversion, int frame = 0);
|
||||
|
||||
void SetSourceRemap(const PalEntry* sourceremap)
|
||||
{
|
||||
|
|
|
@ -66,8 +66,8 @@ class FIMGZTexture : public FImageSource
|
|||
|
||||
public:
|
||||
FIMGZTexture (int lumpnum, uint16_t w, uint16_t h, int16_t l, int16_t t, bool isalpha);
|
||||
PalettedPixels CreatePalettedPixels(int conversion) override;
|
||||
int CopyPixels(FBitmap *bmp, int conversion) override;
|
||||
PalettedPixels CreatePalettedPixels(int conversion, int frame = 0) override;
|
||||
int CopyPixels(FBitmap *bmp, int conversion, int frame = 0) override;
|
||||
};
|
||||
|
||||
|
||||
|
@ -118,7 +118,7 @@ FIMGZTexture::FIMGZTexture (int lumpnum, uint16_t w, uint16_t h, int16_t l, int1
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
PalettedPixels FIMGZTexture::CreatePalettedPixels(int conversion)
|
||||
PalettedPixels FIMGZTexture::CreatePalettedPixels(int conversion, int frame)
|
||||
{
|
||||
auto lump = fileSystem.ReadFile (SourceLump);
|
||||
auto imgz = (const ImageHeader *)lump.GetMem();
|
||||
|
@ -198,7 +198,7 @@ PalettedPixels FIMGZTexture::CreatePalettedPixels(int conversion)
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
int FIMGZTexture::CopyPixels(FBitmap *bmp, int conversion)
|
||||
int FIMGZTexture::CopyPixels(FBitmap *bmp, int conversion, int frame)
|
||||
{
|
||||
if (!isalpha) return FImageSource::CopyPixels(bmp, conversion);
|
||||
else return CopyTranslatedPixels(bmp, GPalette.GrayscaleMap.Palette);
|
||||
|
|
|
@ -185,8 +185,8 @@ class FJPEGTexture : public FImageSource
|
|||
public:
|
||||
FJPEGTexture (int lumpnum, int width, int height);
|
||||
|
||||
int CopyPixels(FBitmap *bmp, int conversion) override;
|
||||
PalettedPixels CreatePalettedPixels(int conversion) override;
|
||||
int CopyPixels(FBitmap *bmp, int conversion, int frame = 0) override;
|
||||
PalettedPixels CreatePalettedPixels(int conversion, int frame = 0) override;
|
||||
};
|
||||
|
||||
//==========================================================================
|
||||
|
@ -260,7 +260,7 @@ FJPEGTexture::FJPEGTexture (int lumpnum, int width, int height)
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
PalettedPixels FJPEGTexture::CreatePalettedPixels(int conversion)
|
||||
PalettedPixels FJPEGTexture::CreatePalettedPixels(int conversion, int frame)
|
||||
{
|
||||
auto lump = fileSystem.OpenFileReader (SourceLump);
|
||||
JSAMPLE *buff = NULL;
|
||||
|
@ -401,7 +401,7 @@ PalettedPixels FJPEGTexture::CreatePalettedPixels(int conversion)
|
|||
//
|
||||
//===========================================================================
|
||||
|
||||
int FJPEGTexture::CopyPixels(FBitmap *bmp, int conversion)
|
||||
int FJPEGTexture::CopyPixels(FBitmap *bmp, int conversion, int frame)
|
||||
{
|
||||
PalEntry pe[256];
|
||||
|
||||
|
|
|
@ -201,7 +201,7 @@ void FMultiPatchTexture::CopyToBlock(uint8_t *dest, int dwidth, int dheight, FIm
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
PalettedPixels FMultiPatchTexture::CreatePalettedPixels(int conversion)
|
||||
PalettedPixels FMultiPatchTexture::CreatePalettedPixels(int conversion, int frame)
|
||||
{
|
||||
int numpix = Width * Height;
|
||||
uint8_t blendwork[256];
|
||||
|
@ -278,7 +278,7 @@ PalettedPixels FMultiPatchTexture::CreatePalettedPixels(int conversion)
|
|||
//
|
||||
//===========================================================================
|
||||
|
||||
int FMultiPatchTexture::CopyPixels(FBitmap *bmp, int conversion)
|
||||
int FMultiPatchTexture::CopyPixels(FBitmap *bmp, int conversion, int frame)
|
||||
{
|
||||
int retv = -1;
|
||||
|
||||
|
|
|
@ -74,8 +74,8 @@ protected:
|
|||
TexPart *Parts;
|
||||
|
||||
// The getters must optionally redirect if it's a simple one-patch texture.
|
||||
int CopyPixels(FBitmap *bmp, int conversion) override;
|
||||
PalettedPixels CreatePalettedPixels(int conversion) override;
|
||||
int CopyPixels(FBitmap *bmp, int conversion, int frame = 0) override;
|
||||
PalettedPixels CreatePalettedPixels(int conversion, int frame = 0) override;
|
||||
void CopyToBlock(uint8_t *dest, int dwidth, int dheight, FImageSource *source, int xpos, int ypos, int rotate, const uint8_t *translation, int style);
|
||||
void CollectForPrecache(PrecacheInfo &info, bool requiretruecolor) override;
|
||||
|
||||
|
|
|
@ -62,8 +62,8 @@ class FPatchTexture : public FImageSource
|
|||
bool isalpha = false;
|
||||
public:
|
||||
FPatchTexture (int lumpnum, int w, int h, int lo, int to, bool isalphatex);
|
||||
PalettedPixels CreatePalettedPixels(int conversion) override;
|
||||
int CopyPixels(FBitmap *bmp, int conversion) override;
|
||||
PalettedPixels CreatePalettedPixels(int conversion, int frame = 0) override;
|
||||
int CopyPixels(FBitmap *bmp, int conversion, int frame = 0) override;
|
||||
bool SupportRemap0() override { return !badflag; }
|
||||
void DetectBadPatches();
|
||||
};
|
||||
|
@ -167,7 +167,7 @@ FPatchTexture::FPatchTexture (int lumpnum, int w, int h, int lo, int to, bool is
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
PalettedPixels FPatchTexture::CreatePalettedPixels(int conversion)
|
||||
PalettedPixels FPatchTexture::CreatePalettedPixels(int conversion, int frame)
|
||||
{
|
||||
uint8_t *remap, remaptable[256];
|
||||
int numspans;
|
||||
|
@ -264,7 +264,7 @@ PalettedPixels FPatchTexture::CreatePalettedPixels(int conversion)
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
int FPatchTexture::CopyPixels(FBitmap *bmp, int conversion)
|
||||
int FPatchTexture::CopyPixels(FBitmap *bmp, int conversion, int frame)
|
||||
{
|
||||
if (!isalpha) return FImageSource::CopyPixels(bmp, conversion);
|
||||
else return CopyTranslatedPixels(bmp, GPalette.GrayscaleMap.Palette);
|
||||
|
|
|
@ -84,7 +84,7 @@ class FPCXTexture : public FImageSource
|
|||
public:
|
||||
FPCXTexture (int lumpnum, PCXHeader &);
|
||||
|
||||
int CopyPixels(FBitmap *bmp, int conversion) override;
|
||||
int CopyPixels(FBitmap *bmp, int conversion, int frame = 0) override;
|
||||
|
||||
protected:
|
||||
void ReadPCX1bit (uint8_t *dst, FileReader & lump, PCXHeader *hdr);
|
||||
|
@ -92,7 +92,7 @@ protected:
|
|||
void ReadPCX8bits (uint8_t *dst, FileReader & lump, PCXHeader *hdr);
|
||||
void ReadPCX24bits (uint8_t *dst, FileReader & lump, PCXHeader *hdr, int planes);
|
||||
|
||||
PalettedPixels CreatePalettedPixels(int conversion) override;
|
||||
PalettedPixels CreatePalettedPixels(int conversion, int frame = 0) override;
|
||||
};
|
||||
|
||||
|
||||
|
@ -345,7 +345,7 @@ void FPCXTexture::ReadPCX24bits (uint8_t *dst, FileReader & lump, PCXHeader *hdr
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
PalettedPixels FPCXTexture::CreatePalettedPixels(int conversion)
|
||||
PalettedPixels FPCXTexture::CreatePalettedPixels(int conversion, int frame)
|
||||
{
|
||||
uint8_t PaletteMap[256];
|
||||
PCXHeader header;
|
||||
|
@ -433,7 +433,7 @@ PalettedPixels FPCXTexture::CreatePalettedPixels(int conversion)
|
|||
//
|
||||
//===========================================================================
|
||||
|
||||
int FPCXTexture::CopyPixels(FBitmap *bmp, int conversion)
|
||||
int FPCXTexture::CopyPixels(FBitmap *bmp, int conversion, int frame)
|
||||
{
|
||||
PalEntry pe[256];
|
||||
PCXHeader header;
|
||||
|
|
|
@ -56,8 +56,8 @@ class FPNGTexture : public FImageSource
|
|||
public:
|
||||
FPNGTexture (FileReader &lump, int lumpnum, int width, int height, uint8_t bitdepth, uint8_t colortype, uint8_t interlace);
|
||||
|
||||
int CopyPixels(FBitmap *bmp, int conversion) override;
|
||||
PalettedPixels CreatePalettedPixels(int conversion) override;
|
||||
int CopyPixels(FBitmap *bmp, int conversion, int frame = 0) override;
|
||||
PalettedPixels CreatePalettedPixels(int conversion, int frame = 0) override;
|
||||
|
||||
protected:
|
||||
void ReadAlphaRemap(FileReader *lump, uint8_t *alpharemap);
|
||||
|
@ -412,7 +412,7 @@ void FPNGTexture::ReadAlphaRemap(FileReader *lump, uint8_t *alpharemap)
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
PalettedPixels FPNGTexture::CreatePalettedPixels(int conversion)
|
||||
PalettedPixels FPNGTexture::CreatePalettedPixels(int conversion, int frame)
|
||||
{
|
||||
FileReader *lump;
|
||||
FileReader lfr;
|
||||
|
@ -553,7 +553,7 @@ PalettedPixels FPNGTexture::CreatePalettedPixels(int conversion)
|
|||
//
|
||||
//===========================================================================
|
||||
|
||||
int FPNGTexture::CopyPixels(FBitmap *bmp, int conversion)
|
||||
int FPNGTexture::CopyPixels(FBitmap *bmp, int conversion, int frame)
|
||||
{
|
||||
// Parse pre-IDAT chunks. I skip the CRCs. Is that bad?
|
||||
PalEntry pe[256];
|
||||
|
|
|
@ -51,8 +51,8 @@ class FQOITexture : public FImageSource
|
|||
{
|
||||
public:
|
||||
FQOITexture(int lumpnum, QOIHeader& header);
|
||||
PalettedPixels CreatePalettedPixels(int conversion) override;
|
||||
int CopyPixels(FBitmap *bmp, int conversion) override;
|
||||
PalettedPixels CreatePalettedPixels(int conversion, int frame = 0) override;
|
||||
int CopyPixels(FBitmap *bmp, int conversion, int frame = 0) override;
|
||||
};
|
||||
|
||||
FImageSource *QOIImage_TryCreate(FileReader &file, int lumpnum)
|
||||
|
@ -89,7 +89,7 @@ FQOITexture::FQOITexture(int lumpnum, QOIHeader& header)
|
|||
if (header.channels == 3) bMasked = bTranslucent = false;
|
||||
}
|
||||
|
||||
PalettedPixels FQOITexture::CreatePalettedPixels(int conversion)
|
||||
PalettedPixels FQOITexture::CreatePalettedPixels(int conversion, int frame)
|
||||
{
|
||||
FBitmap bitmap;
|
||||
bitmap.Create(Width, Height);
|
||||
|
@ -124,7 +124,7 @@ PalettedPixels FQOITexture::CreatePalettedPixels(int conversion)
|
|||
return Pixels;
|
||||
}
|
||||
|
||||
int FQOITexture::CopyPixels(FBitmap *bmp, int conversion)
|
||||
int FQOITexture::CopyPixels(FBitmap *bmp, int conversion, int frame)
|
||||
{
|
||||
enum
|
||||
{
|
||||
|
|
|
@ -52,8 +52,8 @@ class FRawPageTexture : public FImageSource
|
|||
int mPaletteLump = -1;
|
||||
public:
|
||||
FRawPageTexture (int lumpnum);
|
||||
PalettedPixels CreatePalettedPixels(int conversion) override;
|
||||
int CopyPixels(FBitmap *bmp, int conversion) override;
|
||||
PalettedPixels CreatePalettedPixels(int conversion, int frame = 0) override;
|
||||
int CopyPixels(FBitmap *bmp, int conversion, int frame = 0) override;
|
||||
};
|
||||
|
||||
//==========================================================================
|
||||
|
@ -170,7 +170,7 @@ FRawPageTexture::FRawPageTexture (int lumpnum)
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
PalettedPixels FRawPageTexture::CreatePalettedPixels(int conversion)
|
||||
PalettedPixels FRawPageTexture::CreatePalettedPixels(int conversion, int frame)
|
||||
{
|
||||
auto lump = fileSystem.ReadFile (SourceLump);
|
||||
auto source = lump.GetBytes();
|
||||
|
@ -199,7 +199,7 @@ PalettedPixels FRawPageTexture::CreatePalettedPixels(int conversion)
|
|||
return Pixels;
|
||||
}
|
||||
|
||||
int FRawPageTexture::CopyPixels(FBitmap *bmp, int conversion)
|
||||
int FRawPageTexture::CopyPixels(FBitmap *bmp, int conversion, int frame)
|
||||
{
|
||||
if (mPaletteLump < 0) return FImageSource::CopyPixels(bmp, conversion);
|
||||
else
|
||||
|
|
|
@ -98,7 +98,7 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
PalettedPixels CreatePalettedPixels(int conversion) override
|
||||
PalettedPixels CreatePalettedPixels(int conversion, int frame = 0) override
|
||||
{
|
||||
PalettedPixels Pix(512);
|
||||
if (conversion == luminance)
|
||||
|
@ -118,7 +118,7 @@ public:
|
|||
return Pix;
|
||||
}
|
||||
|
||||
int CopyPixels(FBitmap *bmp, int conversion) override
|
||||
int CopyPixels(FBitmap *bmp, int conversion, int frame = 0) override
|
||||
{
|
||||
bmp->CopyPixelData(0, 0, Pixels, Width, Height, Height, 1, 0, GPalette.GrayRamp.Palette);
|
||||
return 0;
|
||||
|
|
|
@ -60,7 +60,7 @@ public:
|
|||
Height = srcdata.GetHeight();
|
||||
bUseGamePalette = false;
|
||||
}
|
||||
int CopyPixels(FBitmap* bmp, int conversion)
|
||||
int CopyPixels(FBitmap* bmp, int conversion, int frame = 0)
|
||||
{
|
||||
bmp->Blit(0, 0, info);
|
||||
return 0;
|
||||
|
|
|
@ -77,30 +77,30 @@ class FStartupTexture : public FImageSource
|
|||
{
|
||||
public:
|
||||
FStartupTexture (int lumpnum);
|
||||
PalettedPixels CreatePalettedPixels(int conversion) override;
|
||||
int CopyPixels(FBitmap *bmp, int conversion) override;
|
||||
PalettedPixels CreatePalettedPixels(int conversion, int frame = 0) override;
|
||||
int CopyPixels(FBitmap *bmp, int conversion, int frame) override;
|
||||
};
|
||||
|
||||
class FNotchTexture : public FImageSource
|
||||
{
|
||||
public:
|
||||
FNotchTexture (int lumpnum, int width, int height);
|
||||
PalettedPixels CreatePalettedPixels(int conversion) override;
|
||||
int CopyPixels(FBitmap *bmp, int conversion) override;
|
||||
PalettedPixels CreatePalettedPixels(int conversion, int frame = 0) override;
|
||||
int CopyPixels(FBitmap *bmp, int conversion, int frame) override;
|
||||
};
|
||||
|
||||
class FStrifeStartupTexture : public FImageSource
|
||||
{
|
||||
public:
|
||||
FStrifeStartupTexture (int lumpnum, int w, int h);
|
||||
PalettedPixels CreatePalettedPixels(int conversion) override;
|
||||
PalettedPixels CreatePalettedPixels(int conversion, int frame = 0) override;
|
||||
};
|
||||
|
||||
class FStrifeStartupBackground : public FImageSource
|
||||
{
|
||||
public:
|
||||
FStrifeStartupBackground (int lumpnum);
|
||||
PalettedPixels CreatePalettedPixels(int conversion) override;
|
||||
PalettedPixels CreatePalettedPixels(int conversion, int frame = 0) override;
|
||||
};
|
||||
|
||||
//==========================================================================
|
||||
|
@ -231,7 +231,7 @@ void PlanarToChunky(T* dest, const uint8_t* src, const T* remap, int width, int
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
PalettedPixels FStartupTexture::CreatePalettedPixels(int conversion)
|
||||
PalettedPixels FStartupTexture::CreatePalettedPixels(int conversion, int frame)
|
||||
{
|
||||
auto lump = fileSystem.ReadFile (SourceLump);
|
||||
auto source = lump.GetBytes();
|
||||
|
@ -251,7 +251,7 @@ PalettedPixels FStartupTexture::CreatePalettedPixels(int conversion)
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
int FStartupTexture::CopyPixels(FBitmap *bmp, int conversion)
|
||||
int FStartupTexture::CopyPixels(FBitmap *bmp, int conversion, int frame)
|
||||
{
|
||||
auto lump = fileSystem.ReadFile (SourceLump);
|
||||
auto source = lump.GetBytes();
|
||||
|
@ -279,7 +279,7 @@ FNotchTexture::FNotchTexture (int lumpnum, int width, int height)
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
PalettedPixels FNotchTexture::CreatePalettedPixels(int conversion)
|
||||
PalettedPixels FNotchTexture::CreatePalettedPixels(int conversion, int frame)
|
||||
{
|
||||
auto lump = fileSystem.ReadFile (SourceLump);
|
||||
auto source = lump.GetBytes();
|
||||
|
@ -302,7 +302,7 @@ PalettedPixels FNotchTexture::CreatePalettedPixels(int conversion)
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
int FNotchTexture::CopyPixels(FBitmap *bmp, int conversion)
|
||||
int FNotchTexture::CopyPixels(FBitmap *bmp, int conversion, int frame)
|
||||
{
|
||||
auto lump = fileSystem.ReadFile (SourceLump);
|
||||
auto source = lump.GetBytes();
|
||||
|
@ -336,7 +336,7 @@ FStrifeStartupTexture::FStrifeStartupTexture (int lumpnum, int w, int h)
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
PalettedPixels FStrifeStartupTexture::CreatePalettedPixels(int conversion)
|
||||
PalettedPixels FStrifeStartupTexture::CreatePalettedPixels(int conversion, int frame)
|
||||
{
|
||||
auto lump = fileSystem.ReadFile (SourceLump);
|
||||
auto source = lump.GetBytes();
|
||||
|
@ -366,7 +366,7 @@ FStrifeStartupBackground::FStrifeStartupBackground (int lumpnum)
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
PalettedPixels FStrifeStartupBackground::CreatePalettedPixels(int conversion)
|
||||
PalettedPixels FStrifeStartupBackground::CreatePalettedPixels(int conversion, int frame)
|
||||
{
|
||||
TArray<uint8_t> source(64000, true);
|
||||
memset(source.Data(), 0xF0, 64000);
|
||||
|
|
|
@ -67,8 +67,8 @@ class FStbTexture : public FImageSource
|
|||
|
||||
public:
|
||||
FStbTexture (int lumpnum, int w, int h);
|
||||
PalettedPixels CreatePalettedPixels(int conversion) override;
|
||||
int CopyPixels(FBitmap *bmp, int conversion) override;
|
||||
PalettedPixels CreatePalettedPixels(int conversion, int frame = 0) override;
|
||||
int CopyPixels(FBitmap *bmp, int conversion, int frame = 0) override;
|
||||
};
|
||||
|
||||
|
||||
|
@ -117,7 +117,7 @@ FStbTexture::FStbTexture (int lumpnum, int w, int h)
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
PalettedPixels FStbTexture::CreatePalettedPixels(int conversion)
|
||||
PalettedPixels FStbTexture::CreatePalettedPixels(int conversion, int frame)
|
||||
{
|
||||
FBitmap bitmap;
|
||||
bitmap.Create(Width, Height);
|
||||
|
@ -156,7 +156,7 @@ PalettedPixels FStbTexture::CreatePalettedPixels(int conversion)
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
int FStbTexture::CopyPixels(FBitmap *bmp, int conversion)
|
||||
int FStbTexture::CopyPixels(FBitmap *bmp, int conversion, int frame)
|
||||
{
|
||||
auto lump = fileSystem.OpenFileReader (SourceLump);
|
||||
int x, y, chan;
|
||||
|
|
|
@ -80,11 +80,11 @@ class FTGATexture : public FImageSource
|
|||
public:
|
||||
FTGATexture (int lumpnum, TGAHeader *);
|
||||
|
||||
int CopyPixels(FBitmap *bmp, int conversion) override;
|
||||
int CopyPixels(FBitmap *bmp, int conversion, int frame = 0) override;
|
||||
|
||||
protected:
|
||||
void ReadCompressed(FileReader &lump, uint8_t * buffer, int bytesperpixel);
|
||||
PalettedPixels CreatePalettedPixels(int conversion) override;
|
||||
PalettedPixels CreatePalettedPixels(int conversion, int frame = 0) override;
|
||||
};
|
||||
|
||||
//==========================================================================
|
||||
|
@ -178,7 +178,7 @@ void FTGATexture::ReadCompressed(FileReader &lump, uint8_t * buffer, int bytespe
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
PalettedPixels FTGATexture::CreatePalettedPixels(int conversion)
|
||||
PalettedPixels FTGATexture::CreatePalettedPixels(int conversion, int frame)
|
||||
{
|
||||
uint8_t PaletteMap[256];
|
||||
auto lump = fileSystem.OpenFileReader (SourceLump);
|
||||
|
@ -385,7 +385,7 @@ PalettedPixels FTGATexture::CreatePalettedPixels(int conversion)
|
|||
//
|
||||
//===========================================================================
|
||||
|
||||
int FTGATexture::CopyPixels(FBitmap *bmp, int conversion)
|
||||
int FTGATexture::CopyPixels(FBitmap *bmp, int conversion, int frame)
|
||||
{
|
||||
PalEntry pe[256];
|
||||
auto lump = fileSystem.OpenFileReader (SourceLump);
|
||||
|
|
|
@ -47,8 +47,8 @@ class FWebPTexture : public FImageSource
|
|||
|
||||
public:
|
||||
FWebPTexture(int lumpnum, int w, int h, int xoff, int yoff);
|
||||
PalettedPixels CreatePalettedPixels(int conversion) override;
|
||||
int CopyPixels(FBitmap *bmp, int conversion) override;
|
||||
PalettedPixels CreatePalettedPixels(int conversion, int frame = 0) override;
|
||||
int CopyPixels(FBitmap *bmp, int conversion, int frame = 0) override;
|
||||
};
|
||||
|
||||
|
||||
|
@ -94,10 +94,10 @@ FWebPTexture::FWebPTexture(int lumpnum, int w, int h, int xoff, int yoff)
|
|||
TopOffset = yoff;
|
||||
}
|
||||
|
||||
PalettedPixels FWebPTexture::CreatePalettedPixels(int conversion)
|
||||
PalettedPixels FWebPTexture::CreatePalettedPixels(int conversion, int frame)
|
||||
{
|
||||
FBitmap bitmap;
|
||||
bitmap.Create(Width, Height);
|
||||
bitmap.Create(Width, Height, frame);
|
||||
CopyPixels(&bitmap, conversion);
|
||||
const uint8_t *data = bitmap.GetPixels();
|
||||
|
||||
|
@ -127,7 +127,7 @@ PalettedPixels FWebPTexture::CreatePalettedPixels(int conversion)
|
|||
return Pixels;
|
||||
}
|
||||
|
||||
int FWebPTexture::CopyPixels(FBitmap *bmp, int conversion)
|
||||
int FWebPTexture::CopyPixels(FBitmap *bmp, int conversion, int frame)
|
||||
{
|
||||
WebPDecoderConfig config;
|
||||
auto bytes = fileSystem.ReadFile(SourceLump);
|
||||
|
|
|
@ -51,6 +51,7 @@ struct PrecacheDataPaletted
|
|||
PalettedPixels Pixels;
|
||||
int RefCount;
|
||||
int ImageID;
|
||||
int Frame;
|
||||
};
|
||||
|
||||
struct PrecacheDataRgba
|
||||
|
@ -59,6 +60,7 @@ struct PrecacheDataRgba
|
|||
int TransInfo;
|
||||
int RefCount;
|
||||
int ImageID;
|
||||
int Frame;
|
||||
};
|
||||
|
||||
// TMap doesn't handle this kind of data well. std::map neither. The linear search is still faster, even for a few 100 entries because it doesn't have to access the heap as often..
|
||||
|
@ -71,21 +73,21 @@ TArray<PrecacheDataRgba> precacheDataRgba;
|
|||
//
|
||||
//===========================================================================
|
||||
|
||||
PalettedPixels FImageSource::CreatePalettedPixels(int conversion)
|
||||
PalettedPixels FImageSource::CreatePalettedPixels(int conversion, int frame)
|
||||
{
|
||||
PalettedPixels Pixels(Width * Height);
|
||||
memset(Pixels.Data(), 0, Width * Height);
|
||||
return Pixels;
|
||||
}
|
||||
|
||||
PalettedPixels FImageSource::GetCachedPalettedPixels(int conversion)
|
||||
PalettedPixels FImageSource::GetCachedPalettedPixels(int conversion, int frame)
|
||||
{
|
||||
PalettedPixels ret;
|
||||
|
||||
auto imageID = ImageID;
|
||||
|
||||
// Do we have this image in the cache?
|
||||
unsigned index = conversion != normal? UINT_MAX : precacheDataPaletted.FindEx([=](PrecacheDataPaletted &entry) { return entry.ImageID == imageID; });
|
||||
unsigned index = conversion != normal? UINT_MAX : precacheDataPaletted.FindEx([=](PrecacheDataPaletted &entry) { return entry.ImageID == imageID && entry.Frame == frame; });
|
||||
if (index < precacheDataPaletted.Size())
|
||||
{
|
||||
auto cache = &precacheDataPaletted[index];
|
||||
|
@ -115,7 +117,7 @@ PalettedPixels FImageSource::GetCachedPalettedPixels(int conversion)
|
|||
{
|
||||
// This is either the only copy needed or some access outside the caching block. In these cases create a new one and directly return it.
|
||||
//Printf("returning fresh copy of %s\n", name.GetChars());
|
||||
return CreatePalettedPixels(conversion);
|
||||
return CreatePalettedPixels(conversion, frame);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -126,16 +128,16 @@ PalettedPixels FImageSource::GetCachedPalettedPixels(int conversion)
|
|||
pdp->ImageID = imageID;
|
||||
pdp->RefCount = info->second - 1;
|
||||
info->second = 0;
|
||||
pdp->Pixels = CreatePalettedPixels(normal);
|
||||
pdp->Pixels = CreatePalettedPixels(normal, frame);
|
||||
ret.Pixels.Set(pdp->Pixels.Data(), pdp->Pixels.Size());
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
TArray<uint8_t> FImageSource::GetPalettedPixels(int conversion)
|
||||
TArray<uint8_t> FImageSource::GetPalettedPixels(int conversion, int frame)
|
||||
{
|
||||
auto pix = GetCachedPalettedPixels(conversion);
|
||||
auto pix = GetCachedPalettedPixels(conversion, frame);
|
||||
if (pix.ownsPixels())
|
||||
{
|
||||
// return the pixel store of the returned data directly if this was the last reference.
|
||||
|
@ -165,19 +167,19 @@ TArray<uint8_t> FImageSource::GetPalettedPixels(int conversion)
|
|||
//
|
||||
//===========================================================================
|
||||
|
||||
int FImageSource::CopyPixels(FBitmap *bmp, int conversion)
|
||||
int FImageSource::CopyPixels(FBitmap *bmp, int conversion, int frame)
|
||||
{
|
||||
if (conversion == luminance) conversion = normal; // luminance images have no use as an RGB source.
|
||||
PalEntry *palette = GPalette.BaseColors;
|
||||
|
||||
auto ppix = CreatePalettedPixels(conversion);
|
||||
auto ppix = CreatePalettedPixels(conversion, frame);
|
||||
bmp->CopyPixelData(0, 0, ppix.Data(), Width, Height, Height, 1, 0, palette, nullptr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int FImageSource::CopyTranslatedPixels(FBitmap *bmp, const PalEntry *remap)
|
||||
int FImageSource::CopyTranslatedPixels(FBitmap *bmp, const PalEntry *remap, int frame)
|
||||
{
|
||||
auto ppix = CreatePalettedPixels(normal);
|
||||
auto ppix = CreatePalettedPixels(normal, frame);
|
||||
bmp->CopyPixelData(0, 0, ppix.Data(), Width, Height, Height, 1, 0, remap, nullptr);
|
||||
return 0;
|
||||
}
|
||||
|
@ -188,26 +190,31 @@ int FImageSource::CopyTranslatedPixels(FBitmap *bmp, const PalEntry *remap)
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
FBitmap FImageSource::GetCachedBitmap(const PalEntry *remap, int conversion, int *ptrans)
|
||||
FBitmap FImageSource::GetCachedBitmap(const PalEntry *remap, int conversion, int *ptrans, int frame)
|
||||
{
|
||||
FBitmap ret;
|
||||
|
||||
int trans = -1;
|
||||
auto imageID = ImageID;
|
||||
|
||||
if (NumOfFrames == 1 && frame == 1)
|
||||
{
|
||||
frame = 0;
|
||||
}
|
||||
|
||||
if (remap != nullptr)
|
||||
{
|
||||
// Remapped images are never run through the cache because they would complicate matters too much for very little gain.
|
||||
// Translated images are normally sprites which normally just consist of a single image and use no composition.
|
||||
// Additionally, since translation requires the base palette, the really time consuming stuff will never be subjected to it.
|
||||
ret.Create(Width, Height);
|
||||
trans = CopyTranslatedPixels(&ret, remap);
|
||||
trans = CopyTranslatedPixels(&ret, remap, frame);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (conversion == luminance) conversion = normal; // luminance has no meaning for true color.
|
||||
// Do we have this image in the cache?
|
||||
unsigned index = conversion != normal? UINT_MAX : precacheDataRgba.FindEx([=](PrecacheDataRgba &entry) { return entry.ImageID == imageID; });
|
||||
unsigned index = conversion != normal? UINT_MAX : precacheDataRgba.FindEx([=](PrecacheDataRgba &entry) { return entry.ImageID == imageID && entry.Frame == frame; });
|
||||
if (index < precacheDataRgba.Size())
|
||||
{
|
||||
auto cache = &precacheDataRgba[index];
|
||||
|
@ -230,7 +237,7 @@ FBitmap FImageSource::GetCachedBitmap(const PalEntry *remap, int conversion, int
|
|||
// This should never happen if the function is implemented correctly
|
||||
//Printf("something bad happened for %s, refcount = %d\n", name.GetChars(), cache->RefCount);
|
||||
ret.Create(Width, Height);
|
||||
trans = CopyPixels(&ret, normal);
|
||||
trans = CopyPixels(&ret, normal, frame);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -242,7 +249,7 @@ FBitmap FImageSource::GetCachedBitmap(const PalEntry *remap, int conversion, int
|
|||
// This is either the only copy needed or some access outside the caching block. In these cases create a new one and directly return it.
|
||||
//Printf("returning fresh copy of %s\n", name.GetChars());
|
||||
ret.Create(Width, Height);
|
||||
trans = CopyPixels(&ret, conversion);
|
||||
trans = CopyPixels(&ret, conversion, frame);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -251,10 +258,11 @@ FBitmap FImageSource::GetCachedBitmap(const PalEntry *remap, int conversion, int
|
|||
PrecacheDataRgba *pdr = &precacheDataRgba[precacheDataRgba.Reserve(1)];
|
||||
|
||||
pdr->ImageID = imageID;
|
||||
pdr->Frame = frame;
|
||||
pdr->RefCount = info->first - 1;
|
||||
info->first = 0;
|
||||
pdr->Pixels.Create(Width, Height);
|
||||
trans = pdr->TransInfo = CopyPixels(&pdr->Pixels, normal);
|
||||
trans = pdr->TransInfo = CopyPixels(&pdr->Pixels, normal, frame);
|
||||
ret.Copy(pdr->Pixels, false);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -67,12 +67,13 @@ protected:
|
|||
int LeftOffset = 0, TopOffset = 0; // Offsets stored in the image.
|
||||
bool bUseGamePalette = false; // true if this is an image without its own color set.
|
||||
int ImageID = -1;
|
||||
int NumOfFrames = 1;
|
||||
|
||||
// Internal image creation functions. All external access should go through the cache interface,
|
||||
// so that all code can benefit from future improvements to that.
|
||||
|
||||
virtual PalettedPixels CreatePalettedPixels(int conversion);
|
||||
int CopyTranslatedPixels(FBitmap *bmp, const PalEntry *remap);
|
||||
virtual PalettedPixels CreatePalettedPixels(int conversion, int frame = 0);
|
||||
int CopyTranslatedPixels(FBitmap *bmp, const PalEntry *remap, int frame = 0);
|
||||
|
||||
|
||||
public:
|
||||
|
@ -101,19 +102,25 @@ public:
|
|||
// 'noremap0' will only be looked at by FPatchTexture and forwarded by FMultipatchTexture.
|
||||
|
||||
// Either returns a reference to the cache, or a newly created item. The return of this has to be considered transient. If you need to store the result, use GetPalettedPixels
|
||||
PalettedPixels GetCachedPalettedPixels(int conversion);
|
||||
PalettedPixels GetCachedPalettedPixels(int conversion, int frame = 0);
|
||||
|
||||
// tries to get a buffer from the cache. If not available, create a new one. If further references are pending, create a copy.
|
||||
TArray<uint8_t> GetPalettedPixels(int conversion);
|
||||
TArray<uint8_t> GetPalettedPixels(int conversion, int frame = 0);
|
||||
|
||||
virtual int CopyPixels(FBitmap* bmp, int conversion);
|
||||
virtual int CopyPixels(FBitmap* bmp, int conversion, int frame = 0);
|
||||
|
||||
FBitmap GetCachedBitmap(const PalEntry *remap, int conversion, int *trans = nullptr);
|
||||
FBitmap GetCachedBitmap(const PalEntry *remap, int conversion, int *trans = nullptr, int frame = 0);
|
||||
|
||||
static void ClearImages() { ImageArena.FreeAll(); ImageForLump.Clear(); NextID = 0; }
|
||||
static FImageSource * GetImage(int lumpnum, bool checkflat);
|
||||
|
||||
// Frame functions
|
||||
|
||||
// Gets number of frames.
|
||||
int GetNumOfFrames() { return NumOfFrames; }
|
||||
|
||||
// Gets duration of frame in miliseconds.
|
||||
virtual int GetDurationOfFrame(int frame) { return 1000; }
|
||||
|
||||
// Conversion option
|
||||
enum EType
|
||||
|
@ -180,8 +187,8 @@ class FBuildTexture : public FImageSource
|
|||
{
|
||||
public:
|
||||
FBuildTexture(const FString& pathprefix, int tilenum, const uint8_t* pixels, FRemapTable* translation, int width, int height, int left, int top);
|
||||
PalettedPixels CreatePalettedPixels(int conversion) override;
|
||||
int CopyPixels(FBitmap* bmp, int conversion) override;
|
||||
PalettedPixels CreatePalettedPixels(int conversion, int frame = 0) override;
|
||||
int CopyPixels(FBitmap* bmp, int conversion, int frame = 0) override;
|
||||
|
||||
protected:
|
||||
const uint8_t* RawPixels;
|
||||
|
@ -191,4 +198,4 @@ protected:
|
|||
|
||||
class FTexture;
|
||||
|
||||
FTexture* CreateImageTexture(FImageSource* img) noexcept;
|
||||
FTexture* CreateImageTexture(FImageSource* img, int frame = 0) noexcept;
|
||||
|
|
|
@ -47,10 +47,11 @@
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
FImageTexture::FImageTexture(FImageSource *img) noexcept
|
||||
FImageTexture::FImageTexture(FImageSource *img, int frame) noexcept
|
||||
: FTexture(img? img->LumpNum() : 0)
|
||||
{
|
||||
mImage = img;
|
||||
TexFrame = frame;
|
||||
if (img != nullptr)
|
||||
{
|
||||
SetFromImage();
|
||||
|
@ -79,7 +80,7 @@ void FImageTexture::SetFromImage()
|
|||
|
||||
FBitmap FImageTexture::GetBgraBitmap(const PalEntry *p, int *trans)
|
||||
{
|
||||
return mImage->GetCachedBitmap(p, bNoRemap0? FImageSource::noremap0 : FImageSource::normal, trans);
|
||||
return mImage->GetCachedBitmap(p, bNoRemap0? FImageSource::noremap0 : FImageSource::normal, trans, TexFrame);
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
|
@ -90,7 +91,7 @@ FBitmap FImageTexture::GetBgraBitmap(const PalEntry *p, int *trans)
|
|||
|
||||
TArray<uint8_t> FImageTexture::Get8BitPixels(bool alpha)
|
||||
{
|
||||
return mImage->GetPalettedPixels(alpha? FImageSource::luminance : bNoRemap0 ? FImageSource::noremap0 : FImageSource::normal);
|
||||
return mImage->GetPalettedPixels(alpha? FImageSource::luminance : bNoRemap0 ? FImageSource::noremap0 : FImageSource::normal, TexFrame);
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
|
@ -113,8 +114,8 @@ bool FImageTexture::DetermineTranslucency()
|
|||
}
|
||||
|
||||
|
||||
FTexture* CreateImageTexture(FImageSource* img) noexcept
|
||||
FTexture* CreateImageTexture(FImageSource* img, int frame) noexcept
|
||||
{
|
||||
return new FImageTexture(img);
|
||||
return new FImageTexture(img, frame);
|
||||
}
|
||||
|
||||
|
|
|
@ -379,10 +379,11 @@ class FImageTexture : public FTexture
|
|||
{
|
||||
FImageSource* mImage;
|
||||
bool bNoRemap0 = false;
|
||||
int TexFrame = 0;
|
||||
protected:
|
||||
void SetFromImage();
|
||||
public:
|
||||
FImageTexture(FImageSource* image) noexcept;
|
||||
FImageTexture(FImageSource* image, int frame = 0) noexcept;
|
||||
~FImageTexture();
|
||||
TArray<uint8_t> Get8BitPixels(bool alphatex) override;
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ public:
|
|||
Height = 1;
|
||||
}
|
||||
|
||||
int CopyPixels(FBitmap *bmp, int conversion) override
|
||||
int CopyPixels(FBitmap *bmp, int conversion, int frame = 0) override
|
||||
{
|
||||
PalEntry *pe = (PalEntry*)bmp->GetPixels();
|
||||
for (int i = 0; i < 256; i++)
|
||||
|
|
Loading…
Reference in a new issue