mirror of
https://github.com/gnif/LookingGlass.git
synced 2024-11-25 14:57:20 +00:00
[c-host] linux: add getFrame support to xcb capture
This commit is contained in:
parent
61108ba760
commit
67c7c79dae
@ -19,6 +19,7 @@ Place, Suite 330, Boston, MA 02111-1307 USA
|
|||||||
|
|
||||||
#include "capture/interface.h"
|
#include "capture/interface.h"
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
#include <string.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
@ -39,6 +40,7 @@ struct xcb
|
|||||||
unsigned int width;
|
unsigned int width;
|
||||||
unsigned int height;
|
unsigned int height;
|
||||||
|
|
||||||
|
bool hasFrame;
|
||||||
xcb_shm_get_image_cookie_t imgC;
|
xcb_shm_get_image_cookie_t imgC;
|
||||||
xcb_xfixes_get_cursor_image_cookie_t curC;
|
xcb_xfixes_get_cursor_image_cookie_t curC;
|
||||||
};
|
};
|
||||||
@ -157,21 +159,58 @@ static CaptureResult xcb_capture(bool * hasFrameUpdate, bool * hasPointerUpdate)
|
|||||||
assert(this);
|
assert(this);
|
||||||
assert(this->initialized);
|
assert(this->initialized);
|
||||||
|
|
||||||
this->imgC = xcb_shm_get_image_unchecked(
|
if (!this->hasFrame)
|
||||||
this->xcb,
|
{
|
||||||
this->xcbScreen->root,
|
this->imgC = xcb_shm_get_image_unchecked(
|
||||||
0, 0,
|
this->xcb,
|
||||||
this->width,
|
this->xcbScreen->root,
|
||||||
this->height,
|
0, 0,
|
||||||
~0,
|
this->width,
|
||||||
XCB_IMAGE_FORMAT_Z_PIXMAP,
|
this->height,
|
||||||
this->seg,
|
~0,
|
||||||
0);
|
XCB_IMAGE_FORMAT_Z_PIXMAP,
|
||||||
|
this->seg,
|
||||||
|
0);
|
||||||
|
|
||||||
|
*hasFrameUpdate = true;
|
||||||
|
this->hasFrame = true;
|
||||||
|
}
|
||||||
|
|
||||||
*hasFrameUpdate = true;
|
|
||||||
return CAPTURE_RESULT_OK;
|
return CAPTURE_RESULT_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool xcb_getFrame(CaptureFrame * frame)
|
||||||
|
{
|
||||||
|
assert(this);
|
||||||
|
assert(this->initialized);
|
||||||
|
assert(frame);
|
||||||
|
assert(frame->data);
|
||||||
|
|
||||||
|
if (!this->hasFrame)
|
||||||
|
{
|
||||||
|
DEBUG_ERROR("No frame to get");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
xcb_shm_get_image_reply_t * img;
|
||||||
|
img = xcb_shm_get_image_reply(this->xcb, this->imgC, NULL);
|
||||||
|
if (!img)
|
||||||
|
{
|
||||||
|
DEBUG_ERROR("Failed to get image reply");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
frame->width = this->width;
|
||||||
|
frame->height = this->height;
|
||||||
|
frame->pitch = this->width * 4;
|
||||||
|
frame->format = CAPTURE_FMT_BGRA;
|
||||||
|
memcpy(frame->data, this->data, this->width * this->height * 4);
|
||||||
|
|
||||||
|
free(img);
|
||||||
|
this->hasFrame = false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
struct CaptureInterface Capture_XCB =
|
struct CaptureInterface Capture_XCB =
|
||||||
{
|
{
|
||||||
.getName = xcb_getName,
|
.getName = xcb_getName,
|
||||||
@ -180,5 +219,6 @@ struct CaptureInterface Capture_XCB =
|
|||||||
.deinit = xcb_deinit,
|
.deinit = xcb_deinit,
|
||||||
.free = xcb_free,
|
.free = xcb_free,
|
||||||
.getMaxFrameSize = xcb_getMaxFrameSize,
|
.getMaxFrameSize = xcb_getMaxFrameSize,
|
||||||
.capture = xcb_capture
|
.capture = xcb_capture,
|
||||||
|
.getFrame = xcb_getFrame
|
||||||
};
|
};
|
Loading…
Reference in New Issue
Block a user