[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); 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) static bool egl_texFBUpdate(EGL_Texture * texture, const EGL_TexUpdate * update)
{ {
TextureBuffer * parent = UPCAST(TextureBuffer, texture); TextureBuffer * parent = UPCAST(TextureBuffer, texture);
@ -114,27 +109,43 @@ static bool egl_texFBUpdate(EGL_Texture * texture, const EGL_TexUpdate * update)
update->rectCount * sizeof(FrameDamageRect)); update->rectCount * sizeof(FrameDamageRect));
damage->count += update->rectCount; damage->count += update->rectCount;
FrameDamageRect scaledDamageRects[damage->count]; if (texture->format.pixFmt == EGL_PF_BGR)
for (int i = 0; i < damage->count; i++)
{ {
FrameDamageRect rect = damage->rects[i]; FrameDamageRect scaledDamageRects[damage->count];
int originalX = rect.x; for (int i = 0; i < damage->count; i++)
int scaledX = scaleForBGR(originalX); {
rect.x = scaledX; FrameDamageRect rect = damage->rects[i];
rect.width = scaleForBGR(originalX + rect.width) - scaledX; int originalX = rect.x;
scaledDamageRects[i] = rect; int scaledX = originalX * 3 / 4;
} rect.x = scaledX;
rect.width = (((originalX + rect.width) * 3 + 3) / 4) - scaledX;
scaledDamageRects[i] = rect;
}
rectsFramebufferToBuffer( rectsFramebufferToBuffer(
scaledDamageRects, scaledDamageRects,
damage->count, damage->count,
texture->format.bpp, texture->format.bpp,
parent->buf[parent->bufIndex].map, parent->buf[parent->bufIndex].map,
texture->format.pitch, texture->format.pitch,
texture->format.height, texture->format.height,
update->frame, update->frame,
texture->format.pitch 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; parent->buf[parent->bufIndex].updated = true;