[client] fix xor support for masked color cursors

fixes #200
This commit is contained in:
Geoffrey McRae 2019-10-09 19:48:42 +11:00
parent 8ef1aee35c
commit 4c0ca1c8e7
2 changed files with 35 additions and 40 deletions

View file

@ -1 +1 @@
B1-8-g4168cc8d78+1 B1-9-g8ef1aee35c+1

View file

@ -207,24 +207,10 @@ void egl_cursor_render(EGL_Cursor * cursor)
uint8_t * data = cursor->data; uint8_t * data = cursor->data;
// tmp buffer for masked colour
uint32_t tmp[cursor->width * cursor->height];
switch(cursor->type) switch(cursor->type)
{ {
case LG_CURSOR_MASKED_COLOR: case LG_CURSOR_MASKED_COLOR:
{ // fall through
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.
}
case LG_CURSOR_COLOR: case LG_CURSOR_COLOR:
{ {
@ -262,10 +248,11 @@ void egl_cursor_render(EGL_Cursor * cursor)
LG_UNLOCK(cursor->lock); LG_UNLOCK(cursor->lock);
} }
if (cursor->type == LG_CURSOR_MONOCHROME)
{
glEnable(GL_BLEND); glEnable(GL_BLEND);
switch(cursor->type)
{
case LG_CURSOR_MONOCHROME:
{
egl_shader_use(cursor->shader); egl_shader_use(cursor->shader);
glUniform4f(cursor->uMousePos, cursor->x, cursor->y, cursor->w, cursor->h / 2); glUniform4f(cursor->uMousePos, cursor->x, cursor->y, cursor->w, cursor->h / 2);
glBlendFunc(GL_ZERO, GL_SRC_COLOR); glBlendFunc(GL_ZERO, GL_SRC_COLOR);
@ -277,18 +264,26 @@ void egl_cursor_render(EGL_Cursor * cursor)
glBlendFunc(GL_ONE_MINUS_DST_COLOR, GL_ZERO); glBlendFunc(GL_ONE_MINUS_DST_COLOR, GL_ZERO);
egl_model_set_texture(cursor->model, cursor->textureMono); egl_model_set_texture(cursor->model, cursor->textureMono);
egl_model_render(cursor->model); egl_model_render(cursor->model);
break;
glDisable(GL_BLEND);
} }
else
{
glEnable(GL_BLEND);
case LG_CURSOR_COLOR:
{
egl_shader_use(cursor->shader); egl_shader_use(cursor->shader);
glUniform4f(cursor->uMousePos, cursor->x, cursor->y, cursor->w, cursor->h); glUniform4f(cursor->uMousePos, cursor->x, cursor->y, cursor->w, cursor->h);
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
egl_model_render(cursor->model); egl_model_render(cursor->model);
break;
}
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); glDisable(GL_BLEND);
} }
}