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>
|
2016-06-29 16:48:53 +02:00
|
|
|
#include <utils/Logger.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-26 23:44:27 +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();
|
|
|
|
|
2016-06-07 23:12:18 +02:00
|
|
|
///
|
|
|
|
/// Set the video mode (2D/3D)
|
|
|
|
/// @param[in] mode The new video mode
|
|
|
|
///
|
|
|
|
void setVideoMode(const VideoMode videoMode);
|
2016-01-21 16:39:52 +01:00
|
|
|
|
|
|
|
bool Setup();
|
2014-01-30 13:35:29 +01:00
|
|
|
|
|
|
|
Image<ColorRgb> & grab();
|
|
|
|
|
|
|
|
private:
|
2016-05-26 23:44:27 +02:00
|
|
|
ImageResampler _imageResampler;
|
|
|
|
|
|
|
|
bool _useXGetImage, _XShmAvailable, _XShmPixmapAvailable, _XRenderAvailable;
|
|
|
|
int _cropLeft;
|
|
|
|
int _cropRight;
|
|
|
|
int _cropTop;
|
|
|
|
int _cropBottom;
|
|
|
|
|
|
|
|
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();
|
2016-06-29 16:48:53 +02:00
|
|
|
|
|
|
|
Logger * _log;
|
2014-01-30 13:35:29 +01:00
|
|
|
};
|