[client] egl: only scale damage rects if it's packed BGR

This commit is contained in:
Geoffrey McRae 2023-11-08 14:10:09 +11:00
parent a455078e0f
commit 4aba15f31c

View file

@ -78,11 +78,6 @@ bool egl_texFBSetup(EGL_Texture * texture, const EGL_TexSetup * setup)
return egl_texBufferStreamSetup(texture, setup);
}
static int scaleForBGR(int x)
{
return x * 3 / 4;
}
static bool egl_texFBUpdate(EGL_Texture * texture, const EGL_TexUpdate * update)
{
TextureBuffer * parent = UPCAST(TextureBuffer, texture);
@ -114,14 +109,16 @@ static bool egl_texFBUpdate(EGL_Texture * texture, const EGL_TexUpdate * update)
update->rectCount * sizeof(FrameDamageRect));
damage->count += update->rectCount;
if (texture->format.pixFmt == EGL_PF_BGR)
{
FrameDamageRect scaledDamageRects[damage->count];
for (int i = 0; i < damage->count; i++)
{
FrameDamageRect rect = damage->rects[i];
int originalX = rect.x;
int scaledX = scaleForBGR(originalX);
int scaledX = originalX * 3 / 4;
rect.x = scaledX;
rect.width = scaleForBGR(originalX + rect.width) - scaledX;
rect.width = (((originalX + rect.width) * 3 + 3) / 4) - scaledX;
scaledDamageRects[i] = rect;
}
@ -136,6 +133,20 @@ static bool egl_texFBUpdate(EGL_Texture * texture, const EGL_TexUpdate * update)
texture->format.pitch
);
}
else
{
rectsFramebufferToBuffer(
damage->rects,
damage->count,
texture->format.bpp,
parent->buf[parent->bufIndex].map,
texture->format.pitch,
texture->format.height,
update->frame,
texture->format.pitch
);
}
}
parent->buf[parent->bufIndex].updated = true;