2014-01-30 13:35:29 +01:00
|
|
|
|
|
|
|
// Hyperion-utils includes
|
|
|
|
#include <utils/Image.h>
|
|
|
|
#include <utils/ColorRgb.h>
|
2014-12-14 14:26:59 +01:00
|
|
|
#include <utils/ImageResampler.h>
|
2014-01-30 13:35:29 +01:00
|
|
|
|
|
|
|
// X11 includes
|
|
|
|
#include <X11/Xlib.h>
|
2016-01-21 16:39:52 +01:00
|
|
|
#include <X11/extensions/Xrender.h>
|
|
|
|
#include <X11/extensions/XShm.h>
|
|
|
|
#include <sys/ipc.h>
|
|
|
|
#include <sys/shm.h>
|
|
|
|
|
2014-01-30 13:35:29 +01:00
|
|
|
class X11Grabber
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
2016-05-24 19:55:50 +02:00
|
|
|
X11Grabber(bool useXGetImage, int cropLeft, int cropRight, int cropTop, int cropBottom, int horizontalPixelDecimation, int verticalPixelDecimation);
|
2014-01-30 13:35:29 +01:00
|
|
|
|
|
|
|
virtual ~X11Grabber();
|
|
|
|
|
|
|
|
int open();
|
2016-01-21 16:39:52 +01:00
|
|
|
|
|
|
|
bool Setup();
|
2014-01-30 13:35:29 +01:00
|
|
|
|
|
|
|
Image<ColorRgb> & grab();
|
|
|
|
|
|
|
|
private:
|
2014-12-14 14:26:59 +01:00
|
|
|
ImageResampler _imageResampler;
|
2016-05-24 19:55:50 +02:00
|
|
|
|
|
|
|
bool _useXGetImage, _XShmAvailable, _XShmPixmapAvailable, _XRenderAvailable;
|
2014-12-14 14:26:59 +01:00
|
|
|
int _cropLeft;
|
|
|
|
int _cropRight;
|
|
|
|
int _cropTop;
|
|
|
|
int _cropBottom;
|
2016-01-17 18:00:38 +01:00
|
|
|
|
2016-01-21 16:39:52 +01:00
|
|
|
XImage* _xImage;
|
|
|
|
XShmSegmentInfo _shminfo;
|
2014-01-30 13:35:29 +01:00
|
|
|
|
|
|
|
/// Reference to the X11 display (nullptr if not opened)
|
2016-01-21 16:39:52 +01:00
|
|
|
Display* _x11Display;
|
|
|
|
Window _window;
|
|
|
|
XWindowAttributes _windowAttr;
|
2016-05-24 19:55:50 +02:00
|
|
|
|
|
|
|
Pixmap _pixmap;
|
|
|
|
XRenderPictFormat* _srcFormat;
|
|
|
|
XRenderPictFormat* _dstFormat;
|
|
|
|
XRenderPictureAttributes _pictAttr;
|
|
|
|
Picture _srcPicture;
|
|
|
|
Picture _dstPicture;
|
2014-01-30 13:35:29 +01:00
|
|
|
|
|
|
|
unsigned _screenWidth;
|
|
|
|
unsigned _screenHeight;
|
2016-01-21 16:39:52 +01:00
|
|
|
unsigned _croppedWidth;
|
|
|
|
unsigned _croppedHeight;
|
2014-01-30 13:35:29 +01:00
|
|
|
|
|
|
|
Image<ColorRgb> _image;
|
2016-01-21 16:39:52 +01:00
|
|
|
|
|
|
|
void freeResources();
|
|
|
|
void setupResources();
|
|
|
|
|
2014-01-30 13:35:29 +01:00
|
|
|
int updateScreenDimensions();
|
|
|
|
};
|