[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

@@ -50,6 +50,7 @@
#include "common/version.h"
#include "common/paths.h"
#include "common/cpuinfo.h"
#include "common/ll.h"
#include "core.h"
#include "app.h"
@@ -809,7 +810,9 @@ int main_frameThread(void * unused)
lgmpClientUnsubscribe(&queue);
RENDERER(onRestart);
app_useSpiceDisplay(true);
if (g_state.state != APP_STATE_SHUTDOWN)
app_useSpiceDisplay(true);
if (g_state.useDMA)
{
@@ -873,6 +876,14 @@ void spiceReady(void)
static void spice_surfaceCreate(unsigned int surfaceId, PSSurfaceFormat format,
unsigned int width, unsigned int height)
{
DEBUG_INFO("Create SPICE surface: id: %d, size: %dx%d",
surfaceId, width, height);
g_state.srcSize.x = width;
g_state.srcSize.y = height;
g_state.haveSrcSize = true;
core_updatePositionInfo();
renderQueue_spiceConfigure(width, height);
if (g_state.lgr)
RENDERER(spiceShow, true);
@@ -880,6 +891,7 @@ static void spice_surfaceCreate(unsigned int surfaceId, PSSurfaceFormat format,
static void spice_surfaceDestroy(unsigned int surfaceId)
{
DEBUG_INFO("Destroy spice surface %d", surfaceId);
if (g_state.lgr)
RENDERER(spiceShow, false);
}
@@ -893,7 +905,7 @@ static void spice_drawFill(unsigned int surfaceId, int x, int y, int width,
static void spice_drawBitmap(unsigned int surfaceId, PSBitmapFormat format,
bool topDown, int x, int y, int width, int height, int stride, void * data)
{
renderQueue_spiceDrawBitmap(x, y, width, height, stride, data);
renderQueue_spiceDrawBitmap(x, y, width, height, stride, data, topDown);
}
int spiceThread(void * arg)
@@ -1579,8 +1591,8 @@ restart:
{
if (!lgmpClientSessionValid(g_state.lgmp))
{
g_state.state = APP_STATE_RESTART;
DEBUG_INFO("Waiting for the host to restart...");
g_state.state = APP_STATE_RESTART;
break;
}
g_state.ds->wait(100);

View File

@@ -32,6 +32,15 @@ void renderQueue_init(void)
l_renderQueue = ll_new();
}
void renderQueue_free(void)
{
if (!l_renderQueue)
return;
renderQueue_clear();
ll_free(l_renderQueue);
}
void renderQueue_clear(void)
{
RenderCommand * cmd;
@@ -68,7 +77,7 @@ void renderQueue_spiceDrawFill(int x, int y, int width, int height,
}
void renderQueue_spiceDrawBitmap(int x, int y, int width, int height, int stride,
void * data)
void * data, bool topDown)
{
RenderCommand * cmd = malloc(sizeof(*cmd));
cmd->op = SPICE_OP_DRAW_BITMAP;
@@ -78,17 +87,12 @@ void renderQueue_spiceDrawBitmap(int x, int y, int width, int height, int stride
cmd->drawBitmap.height = height;
cmd->drawBitmap.stride = stride;
cmd->drawBitmap.data = malloc(height * stride);
cmd->drawBitmap.topDown = topDown;
memcpy(cmd->drawBitmap.data, data, height * stride);
ll_push(l_renderQueue, cmd);
app_invalidateWindow(true);
}
void renderQueue_free(void)
{
renderQueue_clear();
ll_free(l_renderQueue);
}
void renderQueue_process(void)
{
RenderCommand * cmd;
@@ -112,7 +116,8 @@ void renderQueue_process(void)
RENDERER(spiceDrawBitmap,
cmd->drawBitmap.x , cmd->drawBitmap.y,
cmd->drawBitmap.width , cmd->drawBitmap.height,
cmd->drawBitmap.stride, cmd->drawBitmap.data);
cmd->drawBitmap.stride, cmd->drawBitmap.data,
cmd->drawBitmap.topDown);
free(cmd->drawBitmap.data);
break;
}

View File

@@ -52,6 +52,7 @@ typedef struct
int width, height;
int stride;
uint8_t * data;
bool topDown;
}
drawBitmap;
};
@@ -69,4 +70,4 @@ void renderQueue_spiceDrawFill(int x, int y, int width, int height,
uint32_t color);
void renderQueue_spiceDrawBitmap(int x, int y, int width, int height, int stride,
void * data);
void * data, bool topDown);