- whitespace cleanup, updated from Raze.
This commit is contained in:
parent
3b879c5656
commit
e60e6967c0
182 changed files with 835 additions and 824 deletions
|
|
@ -44,42 +44,42 @@
|
|||
|
||||
void AnimTexture::SetFrameSize(int format, int width, int height)
|
||||
{
|
||||
pixelformat = format;
|
||||
FTexture::SetSize(width, height);
|
||||
Image.Resize(width * height * (format == Paletted ? 1 : 3));
|
||||
memset(Image.Data(), 0, Image.Size());
|
||||
pixelformat = format;
|
||||
FTexture::SetSize(width, height);
|
||||
Image.Resize(width * height * (format == Paletted ? 1 : 3));
|
||||
memset(Image.Data(), 0, Image.Size());
|
||||
}
|
||||
|
||||
void AnimTexture::SetFrame(const uint8_t* palette, const void* data_)
|
||||
{
|
||||
if (palette) memcpy(Palette, palette, 768);
|
||||
if (data_)
|
||||
{
|
||||
if (pixelformat == YUV)
|
||||
{
|
||||
auto spix = (const uint8_t*)data_;
|
||||
auto dpix = Image.Data();
|
||||
for (int i = 0; i < Width * Height; i++)
|
||||
{
|
||||
int p = i * 4;
|
||||
int q = i * 3;
|
||||
float y = spix[p] * (1 / 255.f);
|
||||
float u = spix[p + 1] * (1 / 255.f) - 0.5f;
|
||||
float v = spix[p + 2] * (1 / 255.f) - 0.5f;
|
||||
if (palette) memcpy(Palette, palette, 768);
|
||||
if (data_)
|
||||
{
|
||||
if (pixelformat == YUV)
|
||||
{
|
||||
auto spix = (const uint8_t*)data_;
|
||||
auto dpix = Image.Data();
|
||||
for (int i = 0; i < Width * Height; i++)
|
||||
{
|
||||
int p = i * 4;
|
||||
int q = i * 3;
|
||||
float y = spix[p] * (1 / 255.f);
|
||||
float u = spix[p + 1] * (1 / 255.f) - 0.5f;
|
||||
float v = spix[p + 2] * (1 / 255.f) - 0.5f;
|
||||
|
||||
y = 1.1643f * (y - 0.0625f);
|
||||
y = 1.1643f * (y - 0.0625f);
|
||||
|
||||
float r = y + 1.5958f * v;
|
||||
float g = y - 0.39173f * u - 0.81290f * v;
|
||||
float b = y + 2.017f * u;
|
||||
float r = y + 1.5958f * v;
|
||||
float g = y - 0.39173f * u - 0.81290f * v;
|
||||
float b = y + 2.017f * u;
|
||||
|
||||
dpix[q + 0] = (uint8_t)(clamp(r, 0.f, 1.f) * 255);
|
||||
dpix[q + 1] = (uint8_t)(clamp(g, 0.f, 1.f) * 255);
|
||||
dpix[q + 2] = (uint8_t)(clamp(b, 0.f, 1.f) * 255);
|
||||
}
|
||||
}
|
||||
else memcpy(Image.Data(), data_, Width * Height * (pixelformat == Paletted ? 1 : 3));
|
||||
}
|
||||
dpix[q + 0] = (uint8_t)(clamp(r, 0.f, 1.f) * 255);
|
||||
dpix[q + 1] = (uint8_t)(clamp(g, 0.f, 1.f) * 255);
|
||||
dpix[q + 2] = (uint8_t)(clamp(b, 0.f, 1.f) * 255);
|
||||
}
|
||||
}
|
||||
else memcpy(Image.Data(), data_, Width * Height * (pixelformat == Paletted ? 1 : 3));
|
||||
}
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
|
|
@ -90,37 +90,37 @@ void AnimTexture::SetFrame(const uint8_t* palette, const void* data_)
|
|||
|
||||
FBitmap AnimTexture::GetBgraBitmap(const PalEntry* remap, int* trans)
|
||||
{
|
||||
FBitmap bmp;
|
||||
FBitmap bmp;
|
||||
|
||||
bmp.Create(Width, Height);
|
||||
bmp.Create(Width, Height);
|
||||
|
||||
auto spix = Image.Data();
|
||||
auto dpix = bmp.GetPixels();
|
||||
if (pixelformat == Paletted)
|
||||
{
|
||||
for (int i = 0; i < Width * Height; i++)
|
||||
{
|
||||
int p = i * 4;
|
||||
int index = spix[i];
|
||||
dpix[p + 0] = Palette[index * 3 + 2];
|
||||
dpix[p + 1] = Palette[index * 3 + 1];
|
||||
dpix[p + 2] = Palette[index * 3];
|
||||
dpix[p + 3] = 255;
|
||||
}
|
||||
}
|
||||
else if (pixelformat == RGB || pixelformat == YUV)
|
||||
{
|
||||
for (int i = 0; i < Width * Height; i++)
|
||||
{
|
||||
int p = i * 4;
|
||||
int q = i * 3;
|
||||
dpix[p + 0] = spix[q + 2];
|
||||
dpix[p + 1] = spix[q + 1];
|
||||
dpix[p + 2] = spix[q];
|
||||
dpix[p + 3] = 255;
|
||||
}
|
||||
}
|
||||
return bmp;
|
||||
auto spix = Image.Data();
|
||||
auto dpix = bmp.GetPixels();
|
||||
if (pixelformat == Paletted)
|
||||
{
|
||||
for (int i = 0; i < Width * Height; i++)
|
||||
{
|
||||
int p = i * 4;
|
||||
int index = spix[i];
|
||||
dpix[p + 0] = Palette[index * 3 + 2];
|
||||
dpix[p + 1] = Palette[index * 3 + 1];
|
||||
dpix[p + 2] = Palette[index * 3];
|
||||
dpix[p + 3] = 255;
|
||||
}
|
||||
}
|
||||
else if (pixelformat == RGB || pixelformat == YUV)
|
||||
{
|
||||
for (int i = 0; i < Width * Height; i++)
|
||||
{
|
||||
int p = i * 4;
|
||||
int q = i * 3;
|
||||
dpix[p + 0] = spix[q + 2];
|
||||
dpix[p + 1] = spix[q + 1];
|
||||
dpix[p + 2] = spix[q];
|
||||
dpix[p + 3] = 255;
|
||||
}
|
||||
}
|
||||
return bmp;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
|
@ -131,36 +131,36 @@ FBitmap AnimTexture::GetBgraBitmap(const PalEntry* remap, int* trans)
|
|||
|
||||
AnimTextures::AnimTextures()
|
||||
{
|
||||
active = 1;
|
||||
tex[0] = TexMan.FindGameTexture("AnimTextureFrame1", ETextureType::Override);
|
||||
tex[1] = TexMan.FindGameTexture("AnimTextureFrame2", ETextureType::Override);
|
||||
active = 1;
|
||||
tex[0] = TexMan.FindGameTexture("AnimTextureFrame1", ETextureType::Override);
|
||||
tex[1] = TexMan.FindGameTexture("AnimTextureFrame2", ETextureType::Override);
|
||||
}
|
||||
|
||||
AnimTextures::~AnimTextures()
|
||||
{
|
||||
Clean();
|
||||
Clean();
|
||||
}
|
||||
|
||||
void AnimTextures::Clean()
|
||||
{
|
||||
if (tex[0]) tex[0]->CleanHardwareData(true);
|
||||
if (tex[1]) tex[1]->CleanHardwareData(true);
|
||||
tex[0] = tex[1] = nullptr;
|
||||
if (tex[0]) tex[0]->CleanHardwareData(true);
|
||||
if (tex[1]) tex[1]->CleanHardwareData(true);
|
||||
tex[0] = tex[1] = nullptr;
|
||||
}
|
||||
|
||||
void AnimTextures::SetSize(int format, int width, int height)
|
||||
{
|
||||
static_cast<AnimTexture*>(tex[0]->GetTexture())->SetFrameSize(format, width, height);
|
||||
static_cast<AnimTexture*>(tex[1]->GetTexture())->SetFrameSize(format, width, height);
|
||||
tex[0]->SetSize(width, height);
|
||||
tex[1]->SetSize(width, height);
|
||||
tex[0]->CleanHardwareData();
|
||||
tex[1]->CleanHardwareData();
|
||||
static_cast<AnimTexture*>(tex[0]->GetTexture())->SetFrameSize(format, width, height);
|
||||
static_cast<AnimTexture*>(tex[1]->GetTexture())->SetFrameSize(format, width, height);
|
||||
tex[0]->SetSize(width, height);
|
||||
tex[1]->SetSize(width, height);
|
||||
tex[0]->CleanHardwareData();
|
||||
tex[1]->CleanHardwareData();
|
||||
}
|
||||
|
||||
void AnimTextures::SetFrame(const uint8_t* palette, const void* data)
|
||||
{
|
||||
active ^= 1;
|
||||
static_cast<AnimTexture*>(tex[active]->GetTexture())->SetFrame(palette, data);
|
||||
tex[active]->CleanHardwareData();
|
||||
active ^= 1;
|
||||
static_cast<AnimTexture*>(tex[active]->GetTexture())->SetFrame(palette, data);
|
||||
tex[active]->CleanHardwareData();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue