Changeset View
Changeset View
Standalone View
Standalone View
plugins/platforms/virtual/virtual_backend.h
Show All 14 Lines | |||||
15 | GNU General Public License for more details. | 15 | GNU General Public License for more details. | ||
16 | 16 | | |||
17 | You should have received a copy of the GNU General Public License | 17 | You should have received a copy of the GNU General Public License | ||
18 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 18 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
19 | *********************************************************************/ | 19 | *********************************************************************/ | ||
20 | #ifndef KWIN_VIRTUAL_BACKEND_H | 20 | #ifndef KWIN_VIRTUAL_BACKEND_H | ||
21 | #define KWIN_VIRTUAL_BACKEND_H | 21 | #define KWIN_VIRTUAL_BACKEND_H | ||
22 | #include "platform.h" | 22 | #include "platform.h" | ||
23 | #include "virtual_output.h" | ||||
23 | 24 | | |||
24 | #include <kwin_export.h> | 25 | #include <kwin_export.h> | ||
25 | 26 | | |||
26 | #include <QObject> | 27 | #include <QObject> | ||
27 | #include <QSize> | 28 | #include <QRect> | ||
28 | 29 | | |||
29 | class QTemporaryDir; | 30 | class QTemporaryDir; | ||
30 | 31 | | |||
31 | struct gbm_device; | 32 | struct gbm_device; | ||
32 | 33 | | |||
33 | namespace KWin | 34 | namespace KWin | ||
34 | { | 35 | { | ||
35 | namespace ColorCorrect { | 36 | struct ColorCorrect::GammaRamp; | ||
36 | class Manager; | | |||
37 | struct GammaRamp; | | |||
38 | } | | |||
39 | | ||||
40 | 37 | | |||
41 | class KWIN_EXPORT VirtualBackend : public Platform | 38 | class KWIN_EXPORT VirtualBackend : public Platform | ||
42 | { | 39 | { | ||
43 | Q_OBJECT | 40 | Q_OBJECT | ||
44 | Q_INTERFACES(KWin::Platform) | 41 | Q_INTERFACES(KWin::Platform) | ||
45 | Q_PLUGIN_METADATA(IID "org.kde.kwin.Platform" FILE "virtual.json") | 42 | Q_PLUGIN_METADATA(IID "org.kde.kwin.Platform" FILE "virtual.json") | ||
46 | Q_PROPERTY(QSize size READ size NOTIFY sizeChanged) | 43 | | ||
47 | public: | 44 | public: | ||
48 | VirtualBackend(QObject *parent = nullptr); | 45 | VirtualBackend(QObject *parent = nullptr); | ||
49 | virtual ~VirtualBackend(); | 46 | virtual ~VirtualBackend(); | ||
50 | void init() override; | 47 | void init() override; | ||
51 | 48 | | |||
52 | QSize size() const { | | |||
53 | return m_size; | | |||
54 | } | | |||
55 | int outputCount() const { | 49 | int outputCount() const { | ||
56 | return m_outputCount; | 50 | return m_outputs.size(); | ||
51 | } | ||||
52 | const QVector<VirtualOutput> outputs() const { | ||||
53 | return m_outputs; | ||||
57 | } | 54 | } | ||
58 | qreal outputScale() const { | 55 | qreal outputScale() const { | ||
59 | return m_outputScale; | 56 | return m_outputScale; | ||
60 | } | 57 | } | ||
61 | 58 | | |||
62 | bool saveFrames() const { | 59 | bool saveFrames() const { | ||
63 | return !m_screenshotDir.isNull(); | 60 | return !m_screenshotDir.isNull(); | ||
64 | } | 61 | } | ||
65 | QString screenshotDirPath() const; | 62 | QString screenshotDirPath() const; | ||
66 | 63 | | |||
67 | Screens *createScreens(QObject *parent = nullptr) override; | 64 | Screens *createScreens(QObject *parent = nullptr) override; | ||
68 | QPainterBackend* createQPainterBackend() override; | 65 | QPainterBackend* createQPainterBackend() override; | ||
69 | OpenGLBackend *createOpenGLBackend() override; | 66 | OpenGLBackend *createOpenGLBackend() override; | ||
70 | 67 | | |||
71 | Q_INVOKABLE void setOutputCount(int count) { | 68 | Q_INVOKABLE void setVirtualOutputs(int count, QVector<QRect> geometries = QVector<QRect>()); | ||
72 | m_outputCount = count; | | |||
73 | m_gammaSizes = QVector<int>(count, 200); | | |||
74 | m_gammaResults = QVector<bool>(count, true); | | |||
75 | } | | |||
76 | 69 | | |||
77 | Q_INVOKABLE void setOutputScale(qreal scale) { | 70 | Q_INVOKABLE void setOutputScale(qreal scale) { | ||
78 | m_outputScale = scale; | 71 | m_outputScale = scale; | ||
79 | } | 72 | } | ||
80 | 73 | | |||
81 | int drmFd() const { | 74 | int drmFd() const { | ||
82 | return m_drmFd; | 75 | return m_drmFd; | ||
83 | } | 76 | } | ||
84 | void setDrmFd(int fd) { | 77 | void setDrmFd(int fd) { | ||
85 | m_drmFd = fd; | 78 | m_drmFd = fd; | ||
86 | } | 79 | } | ||
87 | 80 | | |||
88 | gbm_device *gbmDevice() const { | 81 | gbm_device *gbmDevice() const { | ||
89 | return m_gbmDevice; | 82 | return m_gbmDevice; | ||
90 | } | 83 | } | ||
91 | void setGbmDevice(gbm_device *device) { | 84 | void setGbmDevice(gbm_device *device) { | ||
92 | m_gbmDevice = device; | 85 | m_gbmDevice = device; | ||
graesslin: please move the implementation into the cpp file | |||||
93 | } | 86 | } | ||
94 | virtual int gammaRampSize(int screen) const override; | 87 | virtual int gammaRampSize(int screen) const override; | ||
95 | virtual bool setGammaRamp(int screen, ColorCorrect::GammaRamp &gamma) override; | 88 | virtual bool setGammaRamp(int screen, ColorCorrect::GammaRamp &gamma) override; | ||
96 | 89 | | |||
97 | QVector<CompositingType> supportedCompositors() const override { | 90 | QVector<CompositingType> supportedCompositors() const override { | ||
98 | return QVector<CompositingType>{OpenGLCompositing, QPainterCompositing}; | 91 | return QVector<CompositingType>{OpenGLCompositing, QPainterCompositing}; | ||
99 | } | 92 | } | ||
100 | 93 | | |||
101 | Q_SIGNALS: | 94 | Q_SIGNALS: | ||
102 | void sizeChanged(); | 95 | void virtualOutputsSet(bool countChanged); | ||
103 | void outputGeometriesChanged(const QVector<QRect> &geometries); | | |||
104 | 96 | | |||
105 | private: | 97 | private: | ||
106 | QSize m_size; | 98 | QVector<VirtualOutput> m_outputs; | ||
107 | int m_outputCount = 1; | 99 | | ||
108 | qreal m_outputScale = 1; | 100 | qreal m_outputScale = 1; | ||
101 | | ||||
109 | QScopedPointer<QTemporaryDir> m_screenshotDir; | 102 | QScopedPointer<QTemporaryDir> m_screenshotDir; | ||
110 | int m_drmFd = -1; | 103 | int m_drmFd = -1; | ||
111 | gbm_device *m_gbmDevice = nullptr; | 104 | gbm_device *m_gbmDevice = nullptr; | ||
112 | | ||||
113 | QVector<int> m_gammaSizes = QVector<int>(1, 200); | | |||
114 | QVector<bool> m_gammaResults = QVector<bool>(1, true); | | |||
115 | }; | 105 | }; | ||
116 | 106 | | |||
117 | } | 107 | } | ||
118 | 108 | | |||
119 | #endif | 109 | #endif |
please move the implementation into the cpp file