From 4c0ca1c8e7a9fe338fadc0c39d11a04496fe6183 Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Wed, 9 Oct 2019 19:48:42 +1100 Subject: [PATCH] [client] fix xor support for masked color cursors fixes #200 --- VERSION | 2 +- client/renderers/EGL/cursor.c | 73 ++++++++++++++++------------------- 2 files changed, 35 insertions(+), 40 deletions(-) diff --git a/VERSION b/VERSION index c0b18f8a..c8695349 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -B1-8-g4168cc8d78+1 \ No newline at end of file +B1-9-g8ef1aee35c+1 \ No newline at end of file diff --git a/client/renderers/EGL/cursor.c b/client/renderers/EGL/cursor.c index 1691ce4e..9c1e1870 100644 --- a/client/renderers/EGL/cursor.c +++ b/client/renderers/EGL/cursor.c @@ -207,24 +207,10 @@ void egl_cursor_render(EGL_Cursor * cursor) uint8_t * data = cursor->data; - // tmp buffer for masked colour - uint32_t tmp[cursor->width * cursor->height]; - switch(cursor->type) { case LG_CURSOR_MASKED_COLOR: - { - for(int i = 0; i < cursor->width * cursor->height; ++i) - { - const uint32_t c = ((uint32_t *)data)[i]; - tmp[i] = (c & ~0xFF000000) | (c & 0xFF000000 ? 0x0 : 0xFF000000); - } - data = (uint8_t *)tmp; - // fall through to LG_CURSOR_COLOR - // - // technically we should also create an XOR texture from the data but this - // usage seems very rare in modern software. - } + // fall through case LG_CURSOR_COLOR: { @@ -262,33 +248,42 @@ void egl_cursor_render(EGL_Cursor * cursor) LG_UNLOCK(cursor->lock); } - if (cursor->type == LG_CURSOR_MONOCHROME) + glEnable(GL_BLEND); + switch(cursor->type) { - glEnable(GL_BLEND); + case LG_CURSOR_MONOCHROME: + { + egl_shader_use(cursor->shader); + glUniform4f(cursor->uMousePos, cursor->x, cursor->y, cursor->w, cursor->h / 2); + glBlendFunc(GL_ZERO, GL_SRC_COLOR); + egl_model_set_texture(cursor->model, cursor->texture); + egl_model_render(cursor->model); - egl_shader_use(cursor->shader); - glUniform4f(cursor->uMousePos, cursor->x, cursor->y, cursor->w, cursor->h / 2); - glBlendFunc(GL_ZERO, GL_SRC_COLOR); - egl_model_set_texture(cursor->model, cursor->texture); - egl_model_render(cursor->model); + egl_shader_use(cursor->shaderMono); + glUniform4f(cursor->uMousePosMono, cursor->x, cursor->y, cursor->w, cursor->h / 2); + glBlendFunc(GL_ONE_MINUS_DST_COLOR, GL_ZERO); + egl_model_set_texture(cursor->model, cursor->textureMono); + egl_model_render(cursor->model); + break; + } - egl_shader_use(cursor->shaderMono); - glUniform4f(cursor->uMousePosMono, cursor->x, cursor->y, cursor->w, cursor->h / 2); - glBlendFunc(GL_ONE_MINUS_DST_COLOR, GL_ZERO); - egl_model_set_texture(cursor->model, cursor->textureMono); - egl_model_render(cursor->model); + case LG_CURSOR_COLOR: + { + egl_shader_use(cursor->shader); + glUniform4f(cursor->uMousePos, cursor->x, cursor->y, cursor->w, cursor->h); + glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); + egl_model_render(cursor->model); + break; + } - glDisable(GL_BLEND); - } - else - { - glEnable(GL_BLEND); - - egl_shader_use(cursor->shader); - glUniform4f(cursor->uMousePos, cursor->x, cursor->y, cursor->w, cursor->h); - glBlendFunc(GL_ONE,GL_ONE_MINUS_SRC_ALPHA); - egl_model_render(cursor->model); - - glDisable(GL_BLEND); + case LG_CURSOR_MASKED_COLOR: + { + egl_shader_use(cursor->shaderMono); + glUniform4f(cursor->uMousePos, cursor->x, cursor->y, cursor->w, cursor->h); + glBlendFunc(GL_ONE_MINUS_DST_COLOR, GL_ZERO); + egl_model_render(cursor->model); + break; + } } + glDisable(GL_BLEND); } \ No newline at end of file