From 4aba15f31c077e0f1870a755c1a222893ebc8b09 Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Wed, 8 Nov 2023 14:10:09 +1100 Subject: [PATCH] [client] egl: only scale damage rects if it's packed BGR --- client/renderers/EGL/texture_framebuffer.c | 59 +++++++++++++--------- 1 file changed, 35 insertions(+), 24 deletions(-) diff --git a/client/renderers/EGL/texture_framebuffer.c b/client/renderers/EGL/texture_framebuffer.c index 0e508e4d..9a0e197d 100644 --- a/client/renderers/EGL/texture_framebuffer.c +++ b/client/renderers/EGL/texture_framebuffer.c @@ -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,27 +109,43 @@ static bool egl_texFBUpdate(EGL_Texture * texture, const EGL_TexUpdate * update) update->rectCount * sizeof(FrameDamageRect)); damage->count += update->rectCount; - FrameDamageRect scaledDamageRects[damage->count]; - for (int i = 0; i < damage->count; i++) + if (texture->format.pixFmt == EGL_PF_BGR) { - 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; - } + FrameDamageRect scaledDamageRects[damage->count]; + for (int i = 0; i < damage->count; i++) + { + FrameDamageRect rect = damage->rects[i]; + int originalX = rect.x; + int scaledX = originalX * 3 / 4; + rect.x = scaledX; + rect.width = (((originalX + rect.width) * 3 + 3) / 4) - scaledX; + scaledDamageRects[i] = rect; + } - rectsFramebufferToBuffer( - scaledDamageRects, - damage->count, - texture->format.bpp, - parent->buf[parent->bufIndex].map, - texture->format.pitch, - texture->format.height, - update->frame, - texture->format.pitch - ); + rectsFramebufferToBuffer( + scaledDamageRects, + damage->count, + texture->format.bpp, + parent->buf[parent->bufIndex].map, + texture->format.pitch, + texture->format.height, + update->frame, + 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;