mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-11 15:22:15 +00:00
- replaced FTexture::FillBuffer
This commit is contained in:
parent
82bd742ea3
commit
1e070d27bd
4 changed files with 45 additions and 63 deletions
|
@ -90,6 +90,36 @@ public:
|
|||
ClipRect.height = height;
|
||||
}
|
||||
|
||||
FBitmap(const FBitmap &other) = delete; // disallow because in nearly all cases this creates an unwanted copy.
|
||||
|
||||
FBitmap(FBitmap &&other)
|
||||
{
|
||||
data = other.data;
|
||||
Pitch = other.Pitch;
|
||||
Width = other.Width;
|
||||
Height = other.Height;
|
||||
FreeBuffer = other.FreeBuffer;
|
||||
ClipRect = other.ClipRect;
|
||||
other.data = nullptr;
|
||||
other.FreeBuffer = false;
|
||||
}
|
||||
|
||||
FBitmap &operator=(const FBitmap &other) = delete; // disallow because in nearly all cases this creates an unwanted copy.
|
||||
|
||||
FBitmap &operator=(FBitmap &&other)
|
||||
{
|
||||
if (data != nullptr && FreeBuffer) delete[] data;
|
||||
data = other.data;
|
||||
Pitch = other.Pitch;
|
||||
Width = other.Width;
|
||||
Height = other.Height;
|
||||
FreeBuffer = other.FreeBuffer;
|
||||
ClipRect = other.ClipRect;
|
||||
other.data = nullptr;
|
||||
other.FreeBuffer = false;
|
||||
return *this;
|
||||
}
|
||||
|
||||
virtual ~FBitmap()
|
||||
{
|
||||
Destroy();
|
||||
|
|
|
@ -441,12 +441,10 @@ TArray<uint8_t> FMultiPatchTexture::MakeTexture (bool alphatex)
|
|||
{
|
||||
// In case there are translucent patches let's do the composition in
|
||||
// True color to keep as much precision as possible before downconverting to the palette.
|
||||
uint8_t *buffer = new uint8_t[Width * Height * 4];
|
||||
memset(buffer, 0, Width * Height * 4);
|
||||
FillBuffer(buffer, Width * 4, Height, TEX_RGB);
|
||||
auto buffer = GetBgraBitmap(nullptr);
|
||||
for(int y = 0; y < Height; y++)
|
||||
{
|
||||
uint8_t *in = buffer + Width * y * 4;
|
||||
uint8_t *in = buffer.GetPixels() + Width * y * 4;
|
||||
uint8_t *out = Pixels.Data() + y;
|
||||
for (int x = 0; x < Width; x++)
|
||||
{
|
||||
|
@ -458,7 +456,6 @@ TArray<uint8_t> FMultiPatchTexture::MakeTexture (bool alphatex)
|
|||
in += 4;
|
||||
}
|
||||
}
|
||||
delete [] buffer;
|
||||
}
|
||||
return Pixels;
|
||||
}
|
||||
|
|
|
@ -47,6 +47,7 @@
|
|||
#include "m_fixed.h"
|
||||
#include "hwrenderer/textures/hw_material.h"
|
||||
#include "hwrenderer/textures/hw_ihwtexture.h"
|
||||
#include "swrenderer/textures/r_swtexture.h"
|
||||
|
||||
FTexture *CreateBrightmapTexture(FTexture*);
|
||||
|
||||
|
@ -418,54 +419,6 @@ void FTexture::FlipNonSquareBlockRemap (uint8_t *dst, const uint8_t *src, int x,
|
|||
}
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
void FTexture::FillBuffer(uint8_t *buff, int pitch, int height, FTextureFormat fmt)
|
||||
{
|
||||
int x, y, w, h, stride;
|
||||
|
||||
w = GetWidth();
|
||||
h = GetHeight();
|
||||
|
||||
switch (fmt)
|
||||
{
|
||||
case TEX_Pal:
|
||||
case TEX_Gray:
|
||||
{
|
||||
auto ppix = Get8BitPixels(fmt == TEX_Gray); // should use composition cache
|
||||
auto pix = ppix.Data();
|
||||
stride = pitch - w;
|
||||
for (y = 0; y < h; ++y)
|
||||
{
|
||||
const uint8_t *pix2 = pix;
|
||||
for (x = 0; x < w; ++x)
|
||||
{
|
||||
*buff++ = *pix2;
|
||||
pix2 += h;
|
||||
}
|
||||
pix++;
|
||||
buff += stride;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case TEX_RGB:
|
||||
{
|
||||
FCopyInfo inf = {OP_OVERWRITE, BLEND_NONE, {0}, 0, 0};
|
||||
FBitmap bmp(buff, pitch, pitch/4, height);
|
||||
CopyTrueColorPixels(&bmp, 0, 0, 0, &inf);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
I_Error("FTexture::FillBuffer: Unsupported format %d", fmt);
|
||||
}
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
// FTexture::CopyTrueColorPixels
|
||||
|
@ -495,6 +448,15 @@ int FTexture::CopyTrueColorTranslated(FBitmap *bmp, int x, int y, int rotate, Pa
|
|||
return 0;
|
||||
}
|
||||
|
||||
FBitmap FTexture::GetBgraBitmap(PalEntry *remap)
|
||||
{
|
||||
FBitmap bmp;
|
||||
bmp.Create(GetWidth(), GetHeight());
|
||||
if (!remap) CopyTrueColorPixels(&bmp, 0, 0, 0, nullptr);
|
||||
else CopyTrueColorTranslated(&bmp, 0, 0, 0, remap, nullptr);
|
||||
return bmp;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//
|
||||
|
@ -729,14 +691,8 @@ void FTexture::GetGlowColor(float *data)
|
|||
{
|
||||
if (bGlowing && GlowColor == 0)
|
||||
{
|
||||
int w = Width, h = Height;
|
||||
auto buffer = new uint8_t[w * h * 4];
|
||||
if (buffer)
|
||||
{
|
||||
FillBuffer(buffer, w * 4, h, TEX_RGB);
|
||||
GlowColor = averageColor((uint32_t *)buffer, w*h, 153);
|
||||
delete[] buffer;
|
||||
}
|
||||
auto buffer = GetBgraBitmap(nullptr);
|
||||
GlowColor = averageColor((uint32_t*)buffer.GetPixels(), buffer.GetWidth() * buffer.GetHeight(), 153);
|
||||
|
||||
// Black glow equals nothing so switch glowing off
|
||||
if (GlowColor == 0) bGlowing = false;
|
||||
|
|
|
@ -301,6 +301,7 @@ public:
|
|||
|
||||
// Returns the whole texture, stored in column-major order
|
||||
virtual TArray<uint8_t> Get8BitPixels(bool alphatex);
|
||||
/*virtual*/ FBitmap GetBgraBitmap(PalEntry *remap);
|
||||
|
||||
public:
|
||||
static void FlipSquareBlock (uint8_t *block, int x, int y);
|
||||
|
@ -395,8 +396,6 @@ protected:
|
|||
// Returns the native pixel format for this image
|
||||
virtual FTextureFormat GetFormat();
|
||||
|
||||
// Fill the native texture buffer with pixel data for this image
|
||||
virtual void FillBuffer(uint8_t *buff, int pitch, int height, FTextureFormat fmt);
|
||||
void SetSpeed(float fac) { shaderspeed = fac; }
|
||||
|
||||
int GetWidth () { return Width; }
|
||||
|
|
Loading…
Reference in a new issue