Skip to content

Commit

Permalink
- fixed bad texture canvas checks when in truecolor software rendering.
Browse files Browse the repository at this point in the history
  • Loading branch information
coelckers committed Aug 9, 2019
1 parent 53c2d7e commit 1e4a320
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions src/rendering/swrenderer/textures/swcanvastexture.cpp
Expand Up @@ -153,23 +153,15 @@ void FSWCanvasTexture::Unload ()
void FSWCanvasTexture::UpdatePixels(bool truecolor)
{

if (Canvas->IsBgra())
{
ImageHelpers::FlipNonSquareBlock(PixelsBgra.Data(), (const uint32_t*)Canvas->GetPixels(), GetWidth(), GetHeight(), Canvas->GetPitch());
}
else
{
ImageHelpers::FlipNonSquareBlockRemap(Pixels.Data(), Canvas->GetPixels(), GetWidth(), GetHeight(), Canvas->GetPitch(), GPalette.Remap);
}

if (truecolor)
{
ImageHelpers::FlipNonSquareBlock(PixelsBgra.Data(), (const uint32_t*)CanvasBgra->GetPixels(), GetWidth(), GetHeight(), CanvasBgra->GetPitch());
// True color render still sometimes uses palette textures (for sprites, mostly).
// We need to make sure that both pixel buffers contain data:
int width = GetWidth();
int height = GetHeight();
uint8_t *palbuffer = const_cast<uint8_t*>(GetPixels(0));
const uint32_t *bgrabuffer = GetPixelsBgra();
uint8_t* palbuffer = const_cast<uint8_t*>(GetPixels(0));
const uint32_t* bgrabuffer = GetPixelsBgra();
for (int x = 0; x < width; x++)
{
for (int y = 0; y < height; y++)
Expand All @@ -184,6 +176,10 @@ void FSWCanvasTexture::UpdatePixels(bool truecolor)
bgrabuffer += height;
}
}
else
{
ImageHelpers::FlipNonSquareBlockRemap(Pixels.Data(), Canvas->GetPixels(), GetWidth(), GetHeight(), Canvas->GetPitch(), GPalette.Remap);
}

static_cast<FCanvasTexture*>(mTexture)->SetUpdated(false);
}

0 comments on commit 1e4a320

Please sign in to comment.