backends/x11/windowed: use DrmDevice
This commit is contained in:
parent
fb19774730
commit
08439957d0
4 changed files with 13 additions and 19 deletions
|
@ -43,6 +43,8 @@
|
|||
#include <gbm.h>
|
||||
#include <linux/input.h>
|
||||
#include <ranges>
|
||||
#include <unistd.h>
|
||||
#include <xf86drm.h>
|
||||
|
||||
namespace KWin
|
||||
{
|
||||
|
@ -166,10 +168,6 @@ X11WindowedBackend::~X11WindowedBackend()
|
|||
m_touchDevice.reset();
|
||||
m_eglDisplay.reset();
|
||||
|
||||
if (m_gbmDevice) {
|
||||
gbm_device_destroy(m_gbmDevice);
|
||||
}
|
||||
|
||||
if (m_connection) {
|
||||
if (m_keySymbols) {
|
||||
xcb_key_symbols_free(m_keySymbols);
|
||||
|
@ -309,9 +307,8 @@ void X11WindowedBackend::initDri3()
|
|||
UniqueCPtr<xcb_dri3_open_reply_t> reply(xcb_dri3_open_reply(m_connection, cookie, nullptr));
|
||||
if (reply && reply->nfd == 1) {
|
||||
int fd = xcb_dri3_open_reply_fds(m_connection, reply.get())[0];
|
||||
fcntl(fd, F_SETFD, fcntl(fd, F_GETFD) | FD_CLOEXEC);
|
||||
m_drmFileDescriptor = FileDescriptor{fd};
|
||||
m_gbmDevice = gbm_create_device(m_drmFileDescriptor.get());
|
||||
m_drmDevice = DrmDevice::open(QByteArray(drmGetDeviceNameFromFd2(fd)));
|
||||
::close(fd);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -687,9 +684,9 @@ xcb_window_t X11WindowedBackend::rootWindow() const
|
|||
return m_screen->root;
|
||||
}
|
||||
|
||||
gbm_device *X11WindowedBackend::gbmDevice() const
|
||||
DrmDevice *X11WindowedBackend::drmDevice() const
|
||||
{
|
||||
return m_gbmDevice;
|
||||
return m_drmDevice.get();
|
||||
}
|
||||
|
||||
X11WindowedInputDevice *X11WindowedBackend::pointerDevice() const
|
||||
|
@ -777,7 +774,7 @@ int X11WindowedBackend::driMinorVersion() const
|
|||
QList<CompositingType> X11WindowedBackend::supportedCompositors() const
|
||||
{
|
||||
QList<CompositingType> ret;
|
||||
if (m_gbmDevice) {
|
||||
if (m_drmDevice) {
|
||||
ret.append(OpenGLCompositing);
|
||||
}
|
||||
if (m_hasShm) {
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
*/
|
||||
#pragma once
|
||||
|
||||
#include "core/drmdevice.h"
|
||||
#include "core/inputbackend.h"
|
||||
#include "core/inputdevice.h"
|
||||
#include "core/outputbackend.h"
|
||||
|
@ -103,7 +104,7 @@ public:
|
|||
xcb_screen_t *screen() const;
|
||||
int screenNumer() const;
|
||||
xcb_window_t rootWindow() const;
|
||||
gbm_device *gbmDevice() const;
|
||||
DrmDevice *drmDevice() const;
|
||||
|
||||
bool hasXInput() const;
|
||||
|
||||
|
@ -174,8 +175,7 @@ private:
|
|||
int m_driMinorVersion = 0;
|
||||
QHash<uint32_t, QList<uint64_t>> m_driFormats;
|
||||
|
||||
FileDescriptor m_drmFileDescriptor;
|
||||
gbm_device *m_gbmDevice = nullptr;
|
||||
std::unique_ptr<DrmDevice> m_drmDevice;
|
||||
std::unique_ptr<EglDisplay> m_eglDisplay;
|
||||
|
||||
QList<X11WindowedOutput *> m_outputs;
|
||||
|
|
|
@ -179,8 +179,7 @@ std::chrono::nanoseconds X11WindowedEglCursorLayer::queryRenderTime() const
|
|||
}
|
||||
|
||||
X11WindowedEglBackend::X11WindowedEglBackend(X11WindowedBackend *backend)
|
||||
: m_allocator(std::make_unique<GbmGraphicsBufferAllocator>(backend->gbmDevice()))
|
||||
, m_backend(backend)
|
||||
: m_backend(backend)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -196,7 +195,7 @@ X11WindowedBackend *X11WindowedEglBackend::backend() const
|
|||
|
||||
GraphicsBufferAllocator *X11WindowedEglBackend::graphicsBufferAllocator() const
|
||||
{
|
||||
return m_allocator.get();
|
||||
return m_backend->drmDevice()->allocator();
|
||||
}
|
||||
|
||||
bool X11WindowedEglBackend::initializeEgl()
|
||||
|
@ -211,7 +210,7 @@ bool X11WindowedEglBackend::initializeEgl()
|
|||
}
|
||||
}
|
||||
|
||||
m_backend->setEglDisplay(EglDisplay::create(eglGetPlatformDisplayEXT(EGL_PLATFORM_GBM_KHR, m_backend->gbmDevice(), nullptr)));
|
||||
m_backend->setEglDisplay(EglDisplay::create(eglGetPlatformDisplayEXT(EGL_PLATFORM_GBM_KHR, m_backend->drmDevice()->gbmDevice(), nullptr)));
|
||||
}
|
||||
|
||||
auto display = m_backend->sceneEglDisplayObject();
|
||||
|
|
|
@ -17,7 +17,6 @@ namespace KWin
|
|||
|
||||
class EglSwapchainSlot;
|
||||
class EglSwapchain;
|
||||
class GraphicsBufferAllocator;
|
||||
class X11WindowedBackend;
|
||||
class X11WindowedOutput;
|
||||
class X11WindowedEglBackend;
|
||||
|
@ -99,7 +98,6 @@ private:
|
|||
std::unique_ptr<X11WindowedEglCursorLayer> cursorLayer;
|
||||
};
|
||||
|
||||
std::unique_ptr<GraphicsBufferAllocator> m_allocator;
|
||||
std::map<Output *, Layers> m_outputs;
|
||||
X11WindowedBackend *m_backend;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue