mirror of
https://github.com/gnif/LookingGlass.git
synced 2024-12-23 06:11:46 +00:00
[host] linux: implement new truncated frame support
This commit is contained in:
parent
9f25f7fced
commit
2160dee23a
1 changed files with 15 additions and 17 deletions
|
@ -54,7 +54,6 @@ struct xcb * this = NULL;
|
||||||
// forwards
|
// forwards
|
||||||
|
|
||||||
static bool xcb_deinit();
|
static bool xcb_deinit();
|
||||||
static unsigned int xcb_getMaxFrameSize();
|
|
||||||
|
|
||||||
// implementation
|
// implementation
|
||||||
|
|
||||||
|
@ -109,7 +108,8 @@ static bool xcb_init(void)
|
||||||
DEBUG_INFO("Frame Size : %u x %u", this->width, this->height);
|
DEBUG_INFO("Frame Size : %u x %u", this->width, this->height);
|
||||||
|
|
||||||
this->seg = xcb_generate_id(this->xcb);
|
this->seg = xcb_generate_id(this->xcb);
|
||||||
this->shmID = shmget(IPC_PRIVATE, xcb_getMaxFrameSize(), IPC_CREAT | 0777);
|
const size_t maxFrameSize = this->width * this->height * 4;
|
||||||
|
this->shmID = shmget(IPC_PRIVATE, maxFrameSize, IPC_CREAT | 0777);
|
||||||
if (this->shmID == -1)
|
if (this->shmID == -1)
|
||||||
{
|
{
|
||||||
DEBUG_ERROR("shmget failed");
|
DEBUG_ERROR("shmget failed");
|
||||||
|
@ -165,11 +165,6 @@ static void xcb_free(void)
|
||||||
this = NULL;
|
this = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned int xcb_getMaxFrameSize(void)
|
|
||||||
{
|
|
||||||
return this->width * this->height * 4;
|
|
||||||
}
|
|
||||||
|
|
||||||
static unsigned int xcb_getMouseScale(void)
|
static unsigned int xcb_getMouseScale(void)
|
||||||
{
|
{
|
||||||
return 100;
|
return 100;
|
||||||
|
@ -200,12 +195,16 @@ static CaptureResult xcb_capture(void)
|
||||||
return CAPTURE_RESULT_OK;
|
return CAPTURE_RESULT_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static CaptureResult xcb_waitFrame(CaptureFrame * frame)
|
static CaptureResult xcb_waitFrame(CaptureFrame * frame,
|
||||||
|
const size_t maxFrameSize)
|
||||||
{
|
{
|
||||||
lgWaitEvent(this->frameEvent, TIMEOUT_INFINITE);
|
lgWaitEvent(this->frameEvent, TIMEOUT_INFINITE);
|
||||||
|
|
||||||
|
const unsigned int maxHeight = maxFrameSize / (this->width * 4);
|
||||||
|
|
||||||
frame->width = this->width;
|
frame->width = this->width;
|
||||||
frame->height = this->height;
|
frame->height = maxHeight > this->height ? this->height : maxHeight;
|
||||||
|
frame->realHeight = this->height;
|
||||||
frame->pitch = this->width * 4;
|
frame->pitch = this->width * 4;
|
||||||
frame->stride = this->width;
|
frame->stride = this->width;
|
||||||
frame->format = CAPTURE_FMT_BGRA;
|
frame->format = CAPTURE_FMT_BGRA;
|
||||||
|
@ -214,7 +213,7 @@ static CaptureResult xcb_waitFrame(CaptureFrame * frame)
|
||||||
return CAPTURE_RESULT_OK;
|
return CAPTURE_RESULT_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static CaptureResult xcb_getFrame(FrameBuffer * frame)
|
static CaptureResult xcb_getFrame(FrameBuffer * frame, const unsigned int height)
|
||||||
{
|
{
|
||||||
assert(this);
|
assert(this);
|
||||||
assert(this->initialized);
|
assert(this->initialized);
|
||||||
|
@ -227,7 +226,7 @@ static CaptureResult xcb_getFrame(FrameBuffer * frame)
|
||||||
return CAPTURE_RESULT_ERROR;
|
return CAPTURE_RESULT_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
framebuffer_write(frame, this->data, this->width * this->height * 4);
|
framebuffer_write(frame, this->data, this->width * height * 4);
|
||||||
free(img);
|
free(img);
|
||||||
|
|
||||||
this->hasFrame = false;
|
this->hasFrame = false;
|
||||||
|
@ -242,7 +241,6 @@ struct CaptureInterface Capture_XCB =
|
||||||
.init = xcb_init,
|
.init = xcb_init,
|
||||||
.deinit = xcb_deinit,
|
.deinit = xcb_deinit,
|
||||||
.free = xcb_free,
|
.free = xcb_free,
|
||||||
.getMaxFrameSize = xcb_getMaxFrameSize,
|
|
||||||
.getMouseScale = xcb_getMouseScale,
|
.getMouseScale = xcb_getMouseScale,
|
||||||
.capture = xcb_capture,
|
.capture = xcb_capture,
|
||||||
.waitFrame = xcb_waitFrame,
|
.waitFrame = xcb_waitFrame,
|
||||||
|
|
Loading…
Reference in a new issue