hyperion.ng
X11Grabber.h
1 #pragma once
2 
3 #include <QObject>
4 
5 // Hyperion-utils includes
6 #include <utils/ColorRgb.h>
7 #include <hyperion/Grabber.h>
8 
9 // X11 includes
10 #include <X11/Xlib.h>
11 #include <X11/extensions/Xrender.h>
12 #include <X11/extensions/XShm.h>
13 #include <sys/ipc.h>
14 #include <sys/shm.h>
15 
16 class X11Grabber : public Grabber
17 {
18 public:
19 
20  X11Grabber(int cropLeft, int cropRight, int cropTop, int cropBottom, int pixelDecimation);
21 
22  virtual ~X11Grabber();
23 
24  bool Setup();
25 
34  virtual int grabFrame(Image<ColorRgb> & image, bool forceUpdate=false);
35 
38  int updateScreenDimensions(bool force=false);
39 
40  virtual void setVideoMode(VideoMode mode);
41 
45  virtual bool setWidthHeight(int width, int height) { return true; };
46 
50  virtual void setPixelDecimation(int pixelDecimation);
51 
59  virtual void setCropping(unsigned cropLeft, unsigned cropRight, unsigned cropTop, unsigned cropBottom);
60 
61 private:
62  bool _XShmAvailable, _XShmPixmapAvailable, _XRenderAvailable;
63 
64  XImage* _xImage;
65  XShmSegmentInfo _shminfo;
66 
68  Display* _x11Display;
69  Window _window;
70  XWindowAttributes _windowAttr;
71 
72  Pixmap _pixmap;
73  XRenderPictFormat* _srcFormat;
74  XRenderPictFormat* _dstFormat;
75  XRenderPictureAttributes _pictAttr;
76  Picture _srcPicture;
77  Picture _dstPicture;
78 
79  XTransform _transform;
80  int _pixelDecimation;
81 
82  unsigned _screenWidth;
83  unsigned _screenHeight;
84  unsigned _src_x;
85  unsigned _src_y;
86 
87  Image<ColorRgb> _image;
88 
89  void freeResources();
90  void setupResources();
91 };
int updateScreenDimensions(bool force=false)
update dimension according current screen
Definition: X11Grabber.cpp:192
virtual bool setWidthHeight(int width, int height)
Apply new width/height values, overwrite Grabber.h implementation as X11 doesn&#39;t use width/height...
Definition: X11Grabber.h:45
virtual int grabFrame(Image< ColorRgb > &image, bool forceUpdate=false)
Captures a single snapshot of the display and writes the data to the given image. ...
Definition: X11Grabber.cpp:117
virtual void setCropping(unsigned cropLeft, unsigned cropRight, unsigned cropTop, unsigned cropBottom)
Set the crop values.
Definition: X11Grabber.cpp:291
The Grabber class is responsible to apply image resizes (with or without ImageResampler) Overwrite th...
Definition: Grabber.h:17
virtual void setPixelDecimation(int pixelDecimation)
Apply new pixelDecimation.
Definition: X11Grabber.cpp:282
Definition: X11Grabber.h:16
virtual void setVideoMode(VideoMode mode)
Set the video mode (2D/3D)
Definition: X11Grabber.cpp:276