From 5d5e4ede1ac1b9a399204f0436c579ebfc90b0a3 Mon Sep 17 00:00:00 2001 From: Quantum Date: Sun, 1 Aug 2021 21:01:24 -0400 Subject: [PATCH] [client] egl: use new EGL damage count semantics After the damage queue PR, EGL damage count 0 means no change, and -1 means invalidate the entire window. However, several other places have different semantics, and we are not handling them correctly: 1. KVMFR uses 0 to signal invalidating the entire frame, so if we receive 0 rectangles in egl_on_frame, we should set damage count to -1. 2. The damage overlay treated 0 as full damage, which is now incorrect. This is fixed, and now it treats 0 as no update, and -1 as full damage. --- client/renderers/EGL/damage.c | 4 ++-- client/renderers/EGL/egl.c | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/client/renderers/EGL/damage.c b/client/renderers/EGL/damage.c index fcb1448e..883f6b9f 100644 --- a/client/renderers/EGL/damage.c +++ b/client/renderers/EGL/damage.c @@ -190,11 +190,11 @@ bool egl_damage_render(EGL_Damage * damage, bool rotate, const struct DesktopDam egl_shader_use(damage->shader); glUniformMatrix3x2fv(damage->uTransform, 1, GL_FALSE, damage->transform); - if (data) + if (data && data->count != 0) { damage->count = data->count; GLfloat vertices[KVMFR_MAX_DAMAGE_RECTS * 8]; - if (damage->count == 0) + if (damage->count == -1) { FrameDamageRect full = { .x = 0, .y = 0, .width = damage->width, .height = damage->height, diff --git a/client/renderers/EGL/egl.c b/client/renderers/EGL/egl.c index 2b1b4e04..1150c038 100644 --- a/client/renderers/EGL/egl.c +++ b/client/renderers/EGL/egl.c @@ -514,7 +514,8 @@ static bool egl_on_frame(void * opaque, const FrameBuffer * frame, int dmaFd, INTERLOCKED_SECTION(this->desktopDamageLock, { struct DesktopDamage * damage = this->desktopDamage + this->desktopDamageIdx; - if (damage->count == -1 || damage->count + damageRectsCount >= KVMFR_MAX_DAMAGE_RECTS) + if (damage->count == -1 || damageRectsCount == 0 || + damage->count + damageRectsCount >= KVMFR_MAX_DAMAGE_RECTS) damage->count = -1; else {