2017-08-04 23:08:15 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <QObject>
|
2014-01-30 13:35:29 +01:00
|
|
|
|
|
|
|
// Hyperion-utils includes
|
|
|
|
#include <utils/ColorRgb.h>
|
2017-08-04 23:08:15 +02:00
|
|
|
#include <hyperion/Grabber.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>
|
|
|
|
|
2017-08-04 23:08:15 +02:00
|
|
|
class X11Grabber : public Grabber
|
2014-01-30 13:35:29 +01:00
|
|
|
{
|
|
|
|
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-01-21 16:39:52 +01:00
|
|
|
bool Setup();
|
2016-07-24 15:18:34 +02:00
|
|
|
|
|
|
|
///
|
|
|
|
/// Captures a single snapshot of the display and writes the data to the given image. The
|
|
|
|
/// provided image should have the same dimensions as the configured values (_width and
|
|
|
|
/// _height)
|
|
|
|
///
|
|
|
|
/// @param[out] image The snapped screenshot (should be initialized with correct width and
|
|
|
|
/// height)
|
|
|
|
///
|
2017-08-12 07:55:32 +02:00
|
|
|
virtual int grabFrame(Image<ColorRgb> & image, bool forceUpdate=false);
|
2016-07-24 15:18:34 +02:00
|
|
|
|
|
|
|
///
|
|
|
|
/// update dimension according current screen
|
2017-08-12 07:55:32 +02:00
|
|
|
int updateScreenDimensions(bool force=false);
|
|
|
|
|
|
|
|
virtual void setVideoMode(VideoMode mode);
|
2016-07-24 15:18:34 +02:00
|
|
|
|
2014-01-30 13:35:29 +01:00
|
|
|
private:
|
2016-05-26 23:44:27 +02:00
|
|
|
bool _useXGetImage, _XShmAvailable, _XShmPixmapAvailable, _XRenderAvailable;
|
2017-08-04 23:08:15 +02:00
|
|
|
|
2016-05-26 23:44:27 +02: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;
|
2016-08-22 11:59:07 +02:00
|
|
|
|
|
|
|
XTransform _transform;
|
|
|
|
int _horizontalDecimation;
|
|
|
|
int _verticalDecimation;
|
2014-01-30 13:35:29 +01:00
|
|
|
|
|
|
|
unsigned _screenWidth;
|
|
|
|
unsigned _screenHeight;
|
2017-08-12 07:55:32 +02:00
|
|
|
unsigned _src_x;
|
|
|
|
unsigned _src_y;
|
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
|
|
|
};
|