From 0da4cba6569daebf705519cdcaa4a57efe17321f Mon Sep 17 00:00:00 2001 From: Tudor Brindus Date: Sun, 5 Nov 2023 21:45:02 -0500 Subject: [PATCH] [client] EGL: implement damage-aware RGB24 copy --- client/renderers/EGL/texture_framebuffer.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/client/renderers/EGL/texture_framebuffer.c b/client/renderers/EGL/texture_framebuffer.c index 983b1fc02..0e508e4d9 100644 --- a/client/renderers/EGL/texture_framebuffer.c +++ b/client/renderers/EGL/texture_framebuffer.c @@ -78,6 +78,11 @@ 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); @@ -105,12 +110,23 @@ static bool egl_texFBUpdate(EGL_Texture * texture, const EGL_TexUpdate * update) } else { - //FIXME! This is broken for BGR24 memcpy(damage->rects + damage->count, update->rects, update->rectCount * sizeof(FrameDamageRect)); damage->count += update->rectCount; + + 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); + rect.x = scaledX; + rect.width = scaleForBGR(originalX + rect.width) - scaledX; + scaledDamageRects[i] = rect; + } + rectsFramebufferToBuffer( - damage->rects, + scaledDamageRects, damage->count, texture->format.bpp, parent->buf[parent->bufIndex].map,