[client] egl: implemented SPICE display support

This commit is contained in:
Geoffrey McRae
2022-05-22 18:19:58 +10:00
parent 6699018ed1
commit 247e867f18
17 changed files with 273 additions and 86 deletions

View File

@@ -46,7 +46,8 @@ static void egl_texBuffer_cleanup(TextureBuffer * this)
// common functions
bool egl_texBufferInit(EGL_Texture ** texture, EGLDisplay * display)
bool egl_texBufferInit(EGL_Texture ** texture, EGL_TexType type,
EGLDisplay * display)
{
TextureBuffer * this;
if (!*texture)
@@ -140,14 +141,29 @@ EGL_TexStatus egl_texBufferGet(EGL_Texture * texture, GLuint * tex)
// streaming functions
bool egl_texBufferStreamInit(EGL_Texture ** texture, EGLDisplay * display)
bool egl_texBufferStreamInit(EGL_Texture ** texture, EGL_TexType type,
EGLDisplay * display)
{
if (!egl_texBufferInit(texture, display))
if (!egl_texBufferInit(texture, type, display))
return false;
TextureBuffer * this = UPCAST(TextureBuffer, *texture);
this->texCount = 2;
switch(type)
{
case EGL_TEXTYPE_BUFFER_STREAM:
case EGL_TEXTYPE_DMABUF:
this->texCount = 2;
break;
case EGL_TEXTYPE_BUFFER_MAP:
this->texCount = 1;
break;
default:
DEBUG_UNREACHABLE();
}
LG_LOCK_INIT(this->copyLock);
return true;
}
@@ -168,8 +184,32 @@ static bool egl_texBufferStreamUpdate(EGL_Texture * texture,
DEBUG_ASSERT(update->type == EGL_TEXTYPE_BUFFER);
LG_LOCK(this->copyLock);
memcpy(this->buf[this->bufIndex].map, update->buffer,
texture->format.bufferSize);
uint8_t * dst = this->buf[this->bufIndex].map +
texture->format.stride * update->y +
update->x * texture->format.bpp;
if (update->topDown)
{
const uint8_t * src = update->buffer;
for(int y = 0; y < update->height; ++y)
{
memcpy(dst, src, update->stride);
dst += texture->format.stride;
src += update->stride;
}
}
else
{
const uint8_t * src = update->buffer + update->stride * update->height;
for(int y = 0; y < update->height; ++y)
{
src -= update->stride;
memcpy(dst, src, update->stride);
dst += texture->format.stride;
}
}
this->buf[this->bufIndex].updated = true;
LG_UNLOCK(this->copyLock);