Changeset View
Changeset View
Standalone View
Standalone View
plugins/platforms/drm/drm_backend.h
Show All 17 Lines | |||||
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_DRM_BACKEND_H | 20 | #ifndef KWIN_DRM_BACKEND_H | ||
21 | #define KWIN_DRM_BACKEND_H | 21 | #define KWIN_DRM_BACKEND_H | ||
22 | #include "platform.h" | 22 | #include "platform.h" | ||
23 | #include "input.h" | 23 | #include "input.h" | ||
24 | 24 | | |||
25 | #include "drm_buffer.h" | 25 | #include "drm_buffer.h" | ||
26 | #if HAVE_GBM | ||||
27 | #include "drm_buffer_gbm.h" | ||||
28 | #endif | ||||
26 | #include "drm_inputeventfilter.h" | 29 | #include "drm_inputeventfilter.h" | ||
27 | #include "drm_pointer.h" | 30 | #include "drm_pointer.h" | ||
28 | 31 | | |||
29 | #include <QElapsedTimer> | 32 | #include <QElapsedTimer> | ||
30 | #include <QImage> | 33 | #include <QImage> | ||
31 | #include <QPointer> | 34 | #include <QPointer> | ||
32 | #include <QSize> | 35 | #include <QSize> | ||
33 | #include <xf86drmMode.h> | 36 | #include <xf86drmMode.h> | ||
Show All 16 Lines | |||||
50 | namespace KWin | 53 | namespace KWin | ||
51 | { | 54 | { | ||
52 | 55 | | |||
53 | class Udev; | 56 | class Udev; | ||
54 | class UdevMonitor; | 57 | class UdevMonitor; | ||
55 | 58 | | |||
56 | class DrmOutput; | 59 | class DrmOutput; | ||
57 | class DrmPlane; | 60 | class DrmPlane; | ||
61 | class DrmCrtc; | ||||
62 | class DrmConnector; | ||||
58 | 63 | | |||
59 | 64 | | |||
60 | class KWIN_EXPORT DrmBackend : public Platform | 65 | class KWIN_EXPORT DrmBackend : public Platform | ||
61 | { | 66 | { | ||
62 | Q_OBJECT | 67 | Q_OBJECT | ||
63 | Q_INTERFACES(KWin::Platform) | 68 | Q_INTERFACES(KWin::Platform) | ||
64 | Q_PLUGIN_METADATA(IID "org.kde.kwin.Platform" FILE "drm.json") | 69 | Q_PLUGIN_METADATA(IID "org.kde.kwin.Platform" FILE "drm.json") | ||
65 | public: | 70 | public: | ||
66 | explicit DrmBackend(QObject *parent = nullptr); | 71 | explicit DrmBackend(QObject *parent = nullptr); | ||
67 | virtual ~DrmBackend(); | 72 | virtual ~DrmBackend(); | ||
68 | 73 | | |||
69 | void configurationChangeRequested(KWayland::Server::OutputConfigurationInterface *config) override; | 74 | void configurationChangeRequested(KWayland::Server::OutputConfigurationInterface *config) override; | ||
70 | Screens *createScreens(QObject *parent = nullptr) override; | 75 | Screens *createScreens(QObject *parent = nullptr) override; | ||
71 | QPainterBackend *createQPainterBackend() override; | 76 | QPainterBackend *createQPainterBackend() override; | ||
72 | OpenGLBackend* createOpenGLBackend() override; | 77 | OpenGLBackend* createOpenGLBackend() override; | ||
73 | 78 | | |||
74 | void init() override; | 79 | void init() override; | ||
75 | DrmBuffer *createBuffer(const QSize &size); | 80 | DrmDumbBuffer *createBuffer(const QSize &size); | ||
76 | DrmBuffer *createBuffer(gbm_surface *surface); | 81 | DrmSurfaceBuffer *createBuffer(gbm_surface *surface); | ||
77 | void present(DrmBuffer *buffer, DrmOutput *output); | 82 | void present(DrmBuffer *buffer, DrmOutput *output); | ||
78 | 83 | | |||
79 | int fd() const { | 84 | int fd() const { | ||
80 | return m_fd; | 85 | return m_fd; | ||
81 | } | 86 | } | ||
82 | QVector<DrmOutput*> outputs() const { | 87 | QVector<DrmOutput*> outputs() const { | ||
83 | return m_outputs; | 88 | return m_outputs; | ||
84 | } | 89 | } | ||
85 | QVector<DrmBuffer*> buffers() const { | | |||
86 | return m_buffers; | | |||
87 | } | | |||
88 | QVector<DrmPlane*> planes() const { | 90 | QVector<DrmPlane*> planes() const { | ||
89 | return m_planes; | 91 | return m_planes; | ||
90 | } | 92 | } | ||
91 | void bufferDestroyed(DrmBuffer *b); | | |||
92 | 93 | | |||
93 | void outputWentOff(); | 94 | void outputWentOff(); | ||
94 | void checkOutputsAreOn(); | 95 | void checkOutputsAreOn(); | ||
95 | 96 | | |||
97 | // QPainter reuses buffers | ||||
98 | bool deleteBufferAfterPageFlip() const { | ||||
99 | return m_deleteBufferAfterPageFlip; | ||||
100 | } | ||||
96 | // returns use of AMS, default is not/legacy | 101 | // returns use of AMS, default is not/legacy | ||
97 | bool atomicModeSetting() const { | 102 | bool atomicModeSetting() const { | ||
98 | return m_atomicModeSetting; | 103 | return m_atomicModeSetting; | ||
99 | } | 104 | } | ||
100 | 105 | | |||
101 | void setGbmDevice(gbm_device *device) { | 106 | void setGbmDevice(gbm_device *device) { | ||
102 | m_gbmDevice = device; | 107 | m_gbmDevice = device; | ||
103 | } | 108 | } | ||
Show All 19 Lines | 125 | private: | |||
123 | void activate(bool active); | 128 | void activate(bool active); | ||
124 | void reactivate(); | 129 | void reactivate(); | ||
125 | void deactivate(); | 130 | void deactivate(); | ||
126 | void queryResources(); | 131 | void queryResources(); | ||
127 | void setCursor(); | 132 | void setCursor(); | ||
128 | void updateCursor(); | 133 | void updateCursor(); | ||
129 | void moveCursor(); | 134 | void moveCursor(); | ||
130 | void initCursor(); | 135 | void initCursor(); | ||
131 | quint32 findCrtc(drmModeRes *res, drmModeConnector *connector, bool *ok = nullptr); | | |||
132 | bool crtcIsUsed(quint32 crtc); | | |||
133 | void outputDpmsChanged(); | 136 | void outputDpmsChanged(); | ||
134 | void readOutputsConfiguration(); | 137 | void readOutputsConfiguration(); | ||
135 | QByteArray generateOutputConfigurationUuid() const; | 138 | QByteArray generateOutputConfigurationUuid() const; | ||
136 | DrmOutput *findOutput(quint32 connector); | 139 | DrmOutput *findOutput(quint32 connector); | ||
137 | DrmOutput *findOutput(const QByteArray &uuid); | 140 | DrmOutput *findOutput(const QByteArray &uuid); | ||
138 | QScopedPointer<Udev> m_udev; | 141 | QScopedPointer<Udev> m_udev; | ||
139 | QScopedPointer<UdevMonitor> m_udevMonitor; | 142 | QScopedPointer<UdevMonitor> m_udevMonitor; | ||
140 | int m_fd = -1; | 143 | int m_fd = -1; | ||
141 | int m_drmId = 0; | 144 | int m_drmId = 0; | ||
145 | // all crtcs | ||||
146 | QVector<DrmCrtc*> m_crtcs; | ||||
147 | // all connectors | ||||
148 | QVector<DrmConnector*> m_connectors; | ||||
149 | // currently active output pipelines (planes + crtc + encoder + connector) | ||||
142 | QVector<DrmOutput*> m_outputs; | 150 | QVector<DrmOutput*> m_outputs; | ||
143 | DrmBuffer *m_cursor[2]; | 151 | DrmDumbBuffer *m_cursor[2]; | ||
152 | bool m_deleteBufferAfterPageFlip; | ||||
144 | bool m_atomicModeSetting = false; | 153 | bool m_atomicModeSetting = false; | ||
145 | bool m_cursorEnabled = false; | 154 | bool m_cursorEnabled = false; | ||
146 | int m_cursorIndex = 0; | 155 | int m_cursorIndex = 0; | ||
147 | int m_pageFlipsPending = 0; | 156 | int m_pageFlipsPending = 0; | ||
148 | bool m_active = false; | 157 | bool m_active = false; | ||
149 | QVector<DrmBuffer*> m_buffers; | | |||
150 | // all available planes: primarys, cursors and overlays | 158 | // all available planes: primarys, cursors and overlays | ||
151 | QVector<DrmPlane*> m_planes; | 159 | QVector<DrmPlane*> m_planes; | ||
152 | QScopedPointer<DpmsInputEventFilter> m_dpmsFilter; | 160 | QScopedPointer<DpmsInputEventFilter> m_dpmsFilter; | ||
153 | KWayland::Server::OutputManagementInterface *m_outputManagement = nullptr; | 161 | KWayland::Server::OutputManagementInterface *m_outputManagement = nullptr; | ||
154 | gbm_device *m_gbmDevice = nullptr; | 162 | gbm_device *m_gbmDevice = nullptr; | ||
155 | }; | 163 | }; | ||
156 | 164 | | |||
157 | 165 | | |||
158 | } | 166 | } | ||
159 | 167 | | |||
160 | #endif | 168 | #endif | ||
161 | 169 | |