Skip to content

Commit

Permalink
[client] EGL: implement damage-aware RGB24 copy
Browse files Browse the repository at this point in the history
  • Loading branch information
Xyene authored and gnif committed Nov 6, 2023
1 parent 4faaccd commit 05e1893
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions client/renderers/EGL/texture_framebuffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 05e1893

Please sign in to comment.