KWin
Loading...
Searching...
No Matches
drm_backend.h
Go to the documentation of this file.
1/*
2 KWin - the KDE window manager
3 This file is part of the KDE project.
4
5 SPDX-FileCopyrightText: 2015 Martin Gräßlin <mgraesslin@kde.org>
6
7 SPDX-License-Identifier: GPL-2.0-or-later
8*/
9#pragma once
10#include "core/outputbackend.h"
11
12#include <QList>
13#include <QPointer>
14#include <QSize>
15#include <QSocketNotifier>
16
17#include <memory>
18#include <sys/types.h>
19
20namespace KWin
21{
22
23class Session;
24class Udev;
25class UdevMonitor;
26class UdevDevice;
27
28class DrmAbstractOutput;
29class Cursor;
30class DrmGpu;
31class DrmVirtualOutput;
32class DrmRenderBackend;
33
34class KWIN_EXPORT DrmBackend : public OutputBackend
35{
36 Q_OBJECT
37
38public:
39 explicit DrmBackend(Session *session, QObject *parent = nullptr);
40 ~DrmBackend() override;
41
42 std::unique_ptr<InputBackend> createInputBackend() override;
43 std::unique_ptr<QPainterBackend> createQPainterBackend() override;
44 std::unique_ptr<OpenGLBackend> createOpenGLBackend() override;
45 EglDisplay *sceneEglDisplayObject() const override;
46
47 bool initialize() override;
48
49 Outputs outputs() const override;
50 Session *session() const override;
51
52 QList<CompositingType> supportedCompositors() const override;
53
54 QString supportInformation() const override;
55 Output *createVirtualOutput(const QString &name, const QSize &size, double scale) override;
56 void removeVirtualOutput(Output *output) override;
57
58 DrmGpu *primaryGpu() const;
59 DrmGpu *findGpu(dev_t deviceId) const;
60 size_t gpuCount() const;
61
62 void setRenderBackend(DrmRenderBackend *backend);
63 DrmRenderBackend *renderBackend() const;
64
65 void releaseBuffers();
66 void updateOutputs();
67
68 const std::vector<std::unique_ptr<DrmGpu>> &gpus() const;
69
70public Q_SLOTS:
71 void sceneInitialized() override;
72
73Q_SIGNALS:
74 void gpuAdded(DrmGpu *gpu);
75 void gpuRemoved(DrmGpu *gpu);
76
77protected:
78 bool applyOutputChanges(const OutputConfiguration &config) override;
79
80private:
81 friend class DrmGpu;
82 void addOutput(DrmAbstractOutput *output);
83 void removeOutput(DrmAbstractOutput *output);
84 void handleUdevEvent();
85 DrmGpu *addGpu(const QString &fileName);
86
87 std::unique_ptr<Udev> m_udev;
88 std::unique_ptr<UdevMonitor> m_udevMonitor;
89 std::unique_ptr<QSocketNotifier> m_socketNotifier;
90 Session *m_session;
91 QList<DrmAbstractOutput *> m_outputs;
92 QList<QUuid> m_recentlyUnpluggedDpmsOffOutputs;
93
94 const QStringList m_explicitGpus;
95 std::vector<std::unique_ptr<DrmGpu>> m_gpus;
96 DrmRenderBackend *m_renderBackend = nullptr;
97};
98
99}
void gpuRemoved(DrmGpu *gpu)
void gpuAdded(DrmGpu *gpu)
~DrmBackend() override