6b2e6cfd53
One of the annoying things about EGL headers is that they include platform headers by default, e.g. on X11, it's Xlib.h, etc. The problem with Xlib.h is that it uses the define compiler directive to declare constants and those constants have very generic names, e.g. 'None', which typically conflict with enums, etc. In order to work around bad things coming from Xlib.h, we include fixx11.h file that contains some workarounds to redefine some Xlib's types. There's a flag or rather two flags (EGL_NO_PLATFORM_SPECIFIC_TYPES and EGL_NO_X11) that are cross-vendor and they can be used to prevent EGL headers from including platform specific headers, such as Xlib.h [1] The benefit of setting those two flags is that you can simply include EGL/egl.h or epoxy/egl.h and the world won't explode due to Xlib.h MESA_EGL_NO_X11_HEADERS is set to support older versions of Mesa. [1] https://github.com/KhronosGroup/EGL-Registry/pull/111
145 lines
2.9 KiB
C++
145 lines
2.9 KiB
C++
/*
|
|
KWin - the KDE window manager
|
|
This file is part of the KDE project.
|
|
|
|
SPDX-FileCopyrightText: 2020 Xaver Hugl <xaver.hugl@gmail.com>
|
|
|
|
SPDX-License-Identifier: GPL-2.0-or-later
|
|
*/
|
|
|
|
#ifndef DRM_GPU_H
|
|
#define DRM_GPU_H
|
|
|
|
#include <qobject.h>
|
|
#include <QVector>
|
|
|
|
#include <epoxy/egl.h>
|
|
|
|
#include "drm_buffer.h"
|
|
|
|
struct gbm_device;
|
|
|
|
namespace KWin
|
|
{
|
|
|
|
class DrmOutput;
|
|
class DrmPlane;
|
|
class DrmCrtc;
|
|
class DrmConnector;
|
|
class DrmBackend;
|
|
class AbstractEglBackend;
|
|
|
|
class DrmGpu : public QObject
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
DrmGpu(DrmBackend *backend, QByteArray devNode, int fd, int drmId);
|
|
~DrmGpu();
|
|
|
|
// getters
|
|
QVector<DrmOutput*> outputs() const {
|
|
return m_outputs;
|
|
}
|
|
|
|
int fd() const {
|
|
return m_fd;
|
|
}
|
|
|
|
int drmId() const {
|
|
return m_drmId;
|
|
}
|
|
|
|
bool atomicModeSetting() const {
|
|
return m_atomicModeSetting;
|
|
}
|
|
|
|
bool useEglStreams() const {
|
|
return m_useEglStreams;
|
|
}
|
|
|
|
bool deleteBufferAfterPageFlip() const {
|
|
return m_deleteBufferAfterPageFlip;
|
|
}
|
|
|
|
QByteArray devNode() const {
|
|
return m_devNode;
|
|
}
|
|
|
|
gbm_device *gbmDevice() const {
|
|
return m_gbmDevice;
|
|
}
|
|
|
|
EGLDisplay eglDisplay() const {
|
|
return m_eglDisplay;
|
|
}
|
|
|
|
QVector<DrmPlane*> planes() const {
|
|
return m_planes;
|
|
}
|
|
|
|
AbstractEglBackend *eglBackend() {
|
|
return m_eglBackend;
|
|
}
|
|
|
|
void setGbmDevice(gbm_device *d) {
|
|
m_gbmDevice = d;
|
|
}
|
|
|
|
void setEglDisplay(EGLDisplay display) {
|
|
m_eglDisplay = display;
|
|
}
|
|
|
|
void setDeleteBufferAfterPageFlip(bool deleteBuffer) {
|
|
m_deleteBufferAfterPageFlip = deleteBuffer;
|
|
}
|
|
|
|
DrmDumbBuffer *createBuffer(const QSize &size) const {
|
|
return new DrmDumbBuffer(m_fd, size);
|
|
}
|
|
|
|
void setEglBackend(AbstractEglBackend *eglBackend) {
|
|
m_eglBackend = eglBackend;
|
|
}
|
|
|
|
Q_SIGNALS:
|
|
void outputAdded(DrmOutput *output);
|
|
void outputRemoved(DrmOutput *output);
|
|
void outputEnabled(DrmOutput *output);
|
|
void outputDisabled(DrmOutput *output);
|
|
|
|
protected:
|
|
|
|
friend class DrmBackend;
|
|
void tryAMS();
|
|
bool updateOutputs();
|
|
|
|
private:
|
|
DrmOutput *findOutput(quint32 connector);
|
|
|
|
DrmBackend* const m_backend;
|
|
AbstractEglBackend *m_eglBackend;
|
|
|
|
const QByteArray m_devNode;
|
|
QSize m_cursorSize;
|
|
const int m_fd;
|
|
const int m_drmId;
|
|
bool m_atomicModeSetting;
|
|
bool m_useEglStreams;
|
|
bool m_deleteBufferAfterPageFlip;
|
|
gbm_device* m_gbmDevice;
|
|
EGLDisplay m_eglDisplay = EGL_NO_DISPLAY;
|
|
|
|
// all available planes: primarys, cursors and overlays
|
|
QVector<DrmPlane*> m_planes;
|
|
QVector<DrmPlane*> m_overlayPlanes;
|
|
// crtcs
|
|
QVector<DrmCrtc*> m_crtcs;
|
|
// connectors
|
|
QVector<DrmConnector*> m_connectors;
|
|
// active output pipelines (planes + crtc + encoder + connector)
|
|
QVector<DrmOutput*> m_outputs;
|
|
};
|
|
|
|
}
|
|
|
|
#endif // DRM_GPU_H
|