From 00eb26a34fbad2d25d62ac2cda3534235a8389cb Mon Sep 17 00:00:00 2001 From: Quantum Date: Sun, 11 Jul 2021 03:52:41 -0400 Subject: [PATCH] [client] egl: do not use damage when overlays are visible This allows the overlays to show up correctly. --- client/renderers/EGL/egl.c | 36 +++++++++++++++++++++++------------- client/renderers/EGL/fps.c | 5 +++-- client/renderers/EGL/fps.h | 2 +- client/renderers/EGL/help.c | 5 +++-- client/renderers/EGL/help.h | 2 +- 5 files changed, 31 insertions(+), 19 deletions(-) diff --git a/client/renderers/EGL/egl.c b/client/renderers/EGL/egl.c index 726c18af..18534406 100644 --- a/client/renderers/EGL/egl.c +++ b/client/renderers/EGL/egl.c @@ -124,6 +124,7 @@ struct Inst bool cursorLastValid; struct CursorState cursorLast; + bool hadOverlay; _Atomic(struct DesktopDamage *) desktopDamage; }; @@ -832,6 +833,7 @@ bool egl_render(void * opaque, LG_RendererRotate rotate) bool hasLastCursor = this->cursorLastValid; bool cursorRendered = false; + bool hasOverlay = false; struct CursorState cursorState; struct DesktopDamage * desktopDamage = NULL; @@ -878,12 +880,15 @@ bool egl_render(void * opaque, LG_RendererRotate rotate) } if (!this->waitDone) + { egl_splash_render(this->splash, a, this->splashRatio); + hasOverlay = true; + } } - else + else if (!this->start) { - if (!this->start) - egl_splash_render(this->splash, 1.0f, this->splashRatio); + egl_splash_render(this->splash, 1.0f, this->splashRatio); + hasOverlay = true; } if (this->showAlert) @@ -900,13 +905,26 @@ bool egl_render(void * opaque, LG_RendererRotate rotate) this->cursorLastValid = false; } else + { egl_alert_render(this->alert, this->screenScaleX, this->screenScaleY); + hasOverlay = true; + } + } + + hasOverlay |= egl_fps_render(this->fps, this->screenScaleX, this->screenScaleY); + hasOverlay |= egl_help_render(this->help, this->screenScaleX, this->screenScaleY); + + if (app_renderImGui()) + { + ImGui_ImplOpenGL3_NewFrame(); + ImGui_ImplOpenGL3_RenderDrawData(igGetDrawData()); + hasOverlay = true; } struct Rect damage[KVMFR_MAX_DAMAGE_RECTS + 2]; int damageIdx = 0; - if (this->waitDone) + if (!hasOverlay && !this->hadOverlay) { if (cursorRendered && hasLastCursor) { @@ -953,15 +971,7 @@ bool egl_render(void * opaque, LG_RendererRotate rotate) } } } - - egl_fps_render(this->fps, this->screenScaleX, this->screenScaleY); - egl_help_render(this->help, this->screenScaleX, this->screenScaleY); - - if (app_renderImGui()) - { - ImGui_ImplOpenGL3_NewFrame(); - ImGui_ImplOpenGL3_RenderDrawData(igGetDrawData()); - } + this->hadOverlay = hasOverlay; app_eglSwapBuffers(this->display, this->surface, damage, damageIdx); return true; diff --git a/client/renderers/EGL/fps.c b/client/renderers/EGL/fps.c index 18282815..00d24788 100644 --- a/client/renderers/EGL/fps.c +++ b/client/renderers/EGL/fps.c @@ -187,10 +187,10 @@ void egl_fps_update(EGL_FPS * fps, const float avgFPS, const float renderFPS) fps->font->release(fps->fontObj, bmp); } -void egl_fps_render(EGL_FPS * fps, const float scaleX, const float scaleY) +bool egl_fps_render(EGL_FPS * fps, const float scaleX, const float scaleY) { if (!fps->display || !fps->ready) - return; + return false; glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); @@ -208,4 +208,5 @@ void egl_fps_render(EGL_FPS * fps, const float scaleX, const float scaleY) egl_model_render(fps->model); glDisable(GL_BLEND); + return true; } diff --git a/client/renderers/EGL/fps.h b/client/renderers/EGL/fps.h index 59e45771..f211a5d4 100644 --- a/client/renderers/EGL/fps.h +++ b/client/renderers/EGL/fps.h @@ -32,4 +32,4 @@ void egl_fps_free(EGL_FPS ** fps); void egl_fps_set_display(EGL_FPS * fps, bool display); void egl_fps_set_font (EGL_FPS * fps, LG_Font * fontObj); void egl_fps_update(EGL_FPS * fps, const float avgUPS, const float avgFPS); -void egl_fps_render(EGL_FPS * fps, const float scaleX, const float scaleY); \ No newline at end of file +bool egl_fps_render(EGL_FPS * fps, const float scaleX, const float scaleY); diff --git a/client/renderers/EGL/help.c b/client/renderers/EGL/help.c index 1b6d4dbf..3713f923 100644 --- a/client/renderers/EGL/help.c +++ b/client/renderers/EGL/help.c @@ -160,7 +160,7 @@ void egl_help_set_font(EGL_Help * help, LG_FontObj fontObj) help->fontObj = fontObj; } -void egl_help_render(EGL_Help * help, const float scaleX, const float scaleY) +bool egl_help_render(EGL_Help * help, const float scaleX, const float scaleY) { LG_FontBitmap * bmp = atomic_exchange(&help->bmp, NULL); if (bmp) @@ -194,7 +194,7 @@ void egl_help_render(EGL_Help * help, const float scaleX, const float scaleY) } if (!help->shouldRender) - return; + return false; glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); @@ -212,4 +212,5 @@ void egl_help_render(EGL_Help * help, const float scaleX, const float scaleY) egl_model_render(help->model); glDisable(GL_BLEND); + return true; } diff --git a/client/renderers/EGL/help.h b/client/renderers/EGL/help.h index d5ac3b00..3df289d5 100644 --- a/client/renderers/EGL/help.h +++ b/client/renderers/EGL/help.h @@ -31,4 +31,4 @@ void egl_help_free(EGL_Help ** help); void egl_help_set_text(EGL_Help * help, const char * help_text); void egl_help_set_font(EGL_Help * help, LG_FontObj fontObj); -void egl_help_render(EGL_Help * help, const float scaleX, const float scaleY); +bool egl_help_render(EGL_Help * help, const float scaleX, const float scaleY);