mirror of
https://github.com/gnif/LookingGlass.git
synced 2024-11-22 05:27:20 +00:00
[client] updates for new protocol and vsync disable method
This commit is contained in:
parent
818164da7f
commit
301d394f50
@ -145,15 +145,15 @@ int renderThread(void * unused)
|
||||
{
|
||||
bool error = false;
|
||||
struct KVMFRHeader header;
|
||||
volatile uint64_t * dataPos = &state.shm->dataPos;
|
||||
volatile int32_t * updateCount = &state.shm->updateCount - 1;
|
||||
|
||||
while(state.running)
|
||||
{
|
||||
// if the next frame isn't aready available
|
||||
if (header.dataPos == *dataPos)
|
||||
if (header.updateCount == *updateCount)
|
||||
{
|
||||
// poll until we have a new frame, or we time out
|
||||
while(header.dataPos == *dataPos && state.running) {
|
||||
while(header.updateCount == *updateCount && state.running) {
|
||||
const struct timespec s = {
|
||||
.tv_sec = 0,
|
||||
.tv_nsec = 1000
|
||||
@ -174,35 +174,41 @@ int renderThread(void * unused)
|
||||
// check the header's magic and version are valid
|
||||
if (
|
||||
memcmp(header.magic, KVMFR_HEADER_MAGIC, sizeof(KVMFR_HEADER_MAGIC)) != 0 ||
|
||||
header.version != KVMFR_HEADER_VERSION ||
|
||||
(
|
||||
header.dataPos == 0 ||
|
||||
header.width == 0 ||
|
||||
header.height == 0 ||
|
||||
header.stride == 0 ||
|
||||
header.frameType >= FRAME_TYPE_MAX
|
||||
)
|
||||
)
|
||||
header.version != KVMFR_HEADER_VERSION
|
||||
){
|
||||
usleep(1000);
|
||||
continue;
|
||||
}
|
||||
|
||||
if(header.flags & KVMFR_HEADER_FLAG_FRAME)
|
||||
{
|
||||
if (
|
||||
header.frame.type >= FRAME_TYPE_MAX ||
|
||||
header.frame.width == 0 ||
|
||||
header.frame.height == 0 ||
|
||||
header.frame.stride == 0 ||
|
||||
header.frame.dataPos == 0 ||
|
||||
header.frame.dataPos > state.shmSize
|
||||
){
|
||||
usleep(1000);
|
||||
continue;
|
||||
}
|
||||
|
||||
// setup the renderer format with the frame format details
|
||||
LG_RendererFormat lgrFormat;
|
||||
lgrFormat.width = header.width;
|
||||
lgrFormat.height = header.height;
|
||||
lgrFormat.stride = header.stride;
|
||||
lgrFormat.width = header.frame.width;
|
||||
lgrFormat.height = header.frame.height;
|
||||
lgrFormat.stride = header.frame.stride;
|
||||
|
||||
switch(header.frameType)
|
||||
switch(header.frame.type)
|
||||
{
|
||||
case FRAME_TYPE_ARGB:
|
||||
lgrFormat.pitch = header.stride * 4;
|
||||
lgrFormat.pitch = header.frame.stride * 4;
|
||||
lgrFormat.bpp = 32;
|
||||
break;
|
||||
|
||||
case FRAME_TYPE_RGB:
|
||||
lgrFormat.pitch = header.stride * 3;
|
||||
lgrFormat.pitch = header.frame.stride * 3;
|
||||
lgrFormat.bpp = 24;
|
||||
break;
|
||||
|
||||
@ -217,7 +223,7 @@ int renderThread(void * unused)
|
||||
|
||||
// check the header's dataPos is sane
|
||||
const size_t dataSize = lgrFormat.height * lgrFormat.pitch;
|
||||
if (header.dataPos + dataSize > state.shmSize)
|
||||
if (header.frame.dataPos + dataSize > state.shmSize)
|
||||
{
|
||||
DEBUG_ERROR("The guest sent an invalid dataPos");
|
||||
break;
|
||||
@ -286,16 +292,16 @@ int renderThread(void * unused)
|
||||
}
|
||||
}
|
||||
|
||||
state.srcSize.x = header.width;
|
||||
state.srcSize.y = header.height;
|
||||
state.srcSize.x = header.frame.width;
|
||||
state.srcSize.y = header.frame.height;
|
||||
if (params.autoResize)
|
||||
SDL_SetWindowSize(state.window, header.width, header.height);
|
||||
SDL_SetWindowSize(state.window, header.frame.width, header.frame.height);
|
||||
updatePositionInfo();
|
||||
}
|
||||
|
||||
if (!state.lgr->render(
|
||||
state.lgrData,
|
||||
(uint8_t *)state.shm + header.dataPos,
|
||||
(uint8_t *)state.shm + header.frame.dataPos,
|
||||
params.useMipmap
|
||||
))
|
||||
{
|
||||
@ -303,6 +309,7 @@ int renderThread(void * unused)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (state.lgr)
|
||||
state.lgr->deinitialize(state.lgrData);
|
||||
@ -477,8 +484,8 @@ int eventThread(void * arg)
|
||||
x = (float)x * state.scaleX;
|
||||
y = (float)y * state.scaleY;
|
||||
}
|
||||
x -= state.shm->mouseX;
|
||||
y -= state.shm->mouseY;
|
||||
x -= state.shm->cursor.x;
|
||||
y -= state.shm->cursor.y;
|
||||
realignGuest = false;
|
||||
|
||||
if (!spice_mouse_motion(x, y))
|
||||
@ -605,6 +612,9 @@ int run()
|
||||
FcPatternDestroy(pat);
|
||||
}
|
||||
|
||||
if (!params.vsync)
|
||||
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 0);
|
||||
|
||||
state.window = SDL_CreateWindow(
|
||||
"Looking Glass (Client)",
|
||||
params.center ? SDL_WINDOWPOS_CENTERED : params.x,
|
||||
|
Loading…
Reference in New Issue
Block a user