Skip to content
Permalink
Browse files

[client] fix xor support for masked color cursors

fixes #200
  • Loading branch information...
gnif committed Oct 9, 2019
1 parent 8ef1aee commit 4c0ca1c8e7a9fe338fadc0c39d11a04496fe6183
Showing with 36 additions and 41 deletions.
  1. +1 −1 VERSION
  2. +35 −40 client/renderers/EGL/cursor.c
@@ -1 +1 @@
B1-8-g4168cc8d78+1
B1-9-g8ef1aee35c+1
@@ -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);

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);

glDisable(GL_BLEND);
}
else
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->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->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);
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);
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);
}

0 comments on commit 4c0ca1c

Please sign in to comment.
You can’t perform that action at this time.