From d0722349e6d0116d8fa307591630813a35a8a191 Mon Sep 17 00:00:00 2001 From: Quantum Date: Sun, 25 Jul 2021 02:35:28 -0400 Subject: [PATCH] [client] egl: make damage overlay support rendering rotated rectangles --- client/renderers/EGL/damage.c | 14 +++++++++++--- client/renderers/EGL/damage.h | 2 +- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/client/renderers/EGL/damage.c b/client/renderers/EGL/damage.c index e63bc3fb..fcb1448e 100644 --- a/client/renderers/EGL/damage.c +++ b/client/renderers/EGL/damage.c @@ -48,6 +48,7 @@ struct EGL_Damage int width , height; float translateX, translateY; float scaleX , scaleY; + bool rotate; // uniforms GLint uTransform; @@ -133,10 +134,12 @@ void egl_damage_free(EGL_Damage ** damage) static void update_matrix(EGL_Damage * damage) { - damage->transform[0] = 2.0f * damage->scaleX / damage->width; + int width = damage->rotate ? damage->height : damage->width; + int height = damage->rotate ? damage->width : damage->height; + damage->transform[0] = 2.0f * damage->scaleX / width; damage->transform[1] = 0.0f; damage->transform[2] = 0.0f; - damage->transform[3] = -2.0f * damage->scaleY / damage->height; + damage->transform[3] = -2.0f * damage->scaleY / height; damage->transform[4] = damage->translateX - damage->scaleX; damage->transform[5] = damage->translateY + damage->scaleY; } @@ -170,11 +173,16 @@ inline static void rectToVertices(GLfloat * vertex, const FrameDamageRect * rect vertex[7] = rect->y + rect->height; } -bool egl_damage_render(EGL_Damage * damage, const struct DesktopDamage * data) +bool egl_damage_render(EGL_Damage * damage, bool rotate, const struct DesktopDamage * data) { if (!damage->show || (!data && damage->count == -1)) return false; + if (rotate != damage->rotate) + { + damage->rotate = rotate; + update_matrix(damage); + } glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); diff --git a/client/renderers/EGL/damage.h b/client/renderers/EGL/damage.h index e0066650..8c9b51a7 100644 --- a/client/renderers/EGL/damage.h +++ b/client/renderers/EGL/damage.h @@ -37,4 +37,4 @@ void egl_damage_free(EGL_Damage ** damage); void egl_damage_setup(EGL_Damage * damage, int width, int height); void egl_damage_resize(EGL_Damage * damage, float translateX, float translateY, float scaleX, float scaleY); -bool egl_damage_render(EGL_Damage * damage, const struct DesktopDamage * data); +bool egl_damage_render(EGL_Damage * damage, bool rotate, const struct DesktopDamage * data);