backends/wayland: use DrmDevice
This commit is contained in:
parent
d0b69f3503
commit
fb19774730
4 changed files with 15 additions and 19 deletions
|
@ -8,6 +8,7 @@
|
|||
SPDX-License-Identifier: GPL-2.0-or-later
|
||||
*/
|
||||
#include "wayland_backend.h"
|
||||
#include "core/drmdevice.h"
|
||||
#include "input.h"
|
||||
#include "wayland_display.h"
|
||||
#include "wayland_egl_backend.h"
|
||||
|
@ -425,10 +426,6 @@ WaylandBackend::~WaylandBackend()
|
|||
|
||||
m_seat.reset();
|
||||
m_display.reset();
|
||||
|
||||
if (m_gbmDevice) {
|
||||
gbm_device_destroy(m_gbmDevice);
|
||||
}
|
||||
qCDebug(KWIN_WAYLAND_BACKEND) << "Destroyed Wayland display";
|
||||
}
|
||||
|
||||
|
@ -440,10 +437,8 @@ bool WaylandBackend::initialize()
|
|||
}
|
||||
|
||||
if (WaylandLinuxDmabufV1 *dmabuf = m_display->linuxDmabuf()) {
|
||||
m_drmFileDescriptor = FileDescriptor(open(dmabuf->mainDevice(), O_RDWR | O_CLOEXEC));
|
||||
if (m_drmFileDescriptor.isValid()) {
|
||||
m_gbmDevice = gbm_create_device(m_drmFileDescriptor.get());
|
||||
} else {
|
||||
m_drmDevice = DrmDevice::open(dmabuf->mainDevice());
|
||||
if (!m_drmDevice) {
|
||||
qCWarning(KWIN_WAYLAND_BACKEND) << "Failed to open drm render node" << dmabuf->mainDevice();
|
||||
}
|
||||
}
|
||||
|
@ -560,7 +555,7 @@ void WaylandBackend::togglePointerLock()
|
|||
QList<CompositingType> WaylandBackend::supportedCompositors() const
|
||||
{
|
||||
QList<CompositingType> ret;
|
||||
if (m_display->linuxDmabuf() && m_gbmDevice) {
|
||||
if (m_display->linuxDmabuf() && m_drmDevice) {
|
||||
ret.append(OpenGLCompositing);
|
||||
}
|
||||
ret.append(QPainterCompositing);
|
||||
|
@ -675,6 +670,11 @@ EglDisplay *WaylandBackend::sceneEglDisplayObject() const
|
|||
return m_eglDisplay.get();
|
||||
}
|
||||
|
||||
DrmDevice *WaylandBackend::drmDevice() const
|
||||
{
|
||||
return m_drmDevice.get();
|
||||
}
|
||||
|
||||
WaylandBuffer::WaylandBuffer(wl_buffer *handle, GraphicsBuffer *graphicsBuffer)
|
||||
: m_graphicsBuffer(graphicsBuffer)
|
||||
, m_handle(handle)
|
||||
|
|
|
@ -46,6 +46,7 @@ class Touch;
|
|||
namespace KWin
|
||||
{
|
||||
class GraphicsBuffer;
|
||||
class DrmDevice;
|
||||
|
||||
namespace Wayland
|
||||
{
|
||||
|
@ -241,10 +242,7 @@ public:
|
|||
|
||||
wl_buffer *importBuffer(GraphicsBuffer *graphicsBuffer);
|
||||
|
||||
gbm_device *gbmDevice() const
|
||||
{
|
||||
return m_gbmDevice;
|
||||
}
|
||||
DrmDevice *drmDevice() const;
|
||||
|
||||
void setEglBackend(WaylandEglBackend *eglBackend)
|
||||
{
|
||||
|
@ -267,8 +265,7 @@ private:
|
|||
WaylandEglBackend *m_eglBackend = nullptr;
|
||||
QList<WaylandOutput *> m_outputs;
|
||||
bool m_pointerLockRequested = false;
|
||||
FileDescriptor m_drmFileDescriptor;
|
||||
gbm_device *m_gbmDevice = nullptr;
|
||||
std::unique_ptr<DrmDevice> m_drmDevice;
|
||||
std::unique_ptr<EglDisplay> m_eglDisplay;
|
||||
std::map<GraphicsBuffer *, std::unique_ptr<WaylandBuffer>> m_buffers;
|
||||
};
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
*/
|
||||
|
||||
#include "wayland_egl_backend.h"
|
||||
#include "core/drmdevice.h"
|
||||
#include "core/gbmgraphicsbufferallocator.h"
|
||||
#include "opengl/eglswapchain.h"
|
||||
#include "opengl/glrendertimequery.h"
|
||||
|
@ -229,7 +230,6 @@ std::chrono::nanoseconds WaylandEglCursorLayer::queryRenderTime() const
|
|||
WaylandEglBackend::WaylandEglBackend(WaylandBackend *b)
|
||||
: AbstractEglBackend()
|
||||
, m_backend(b)
|
||||
, m_allocator(std::make_unique<GbmGraphicsBufferAllocator>(b->gbmDevice()))
|
||||
{
|
||||
connect(m_backend, &WaylandBackend::outputAdded, this, &WaylandEglBackend::createEglWaylandOutput);
|
||||
connect(m_backend, &WaylandBackend::outputRemoved, this, [this](Output *output) {
|
||||
|
@ -251,7 +251,7 @@ WaylandBackend *WaylandEglBackend::backend() const
|
|||
|
||||
GraphicsBufferAllocator *WaylandEglBackend::graphicsBufferAllocator() const
|
||||
{
|
||||
return m_allocator.get();
|
||||
return m_backend->drmDevice()->allocator();
|
||||
}
|
||||
|
||||
void WaylandEglBackend::cleanupSurfaces()
|
||||
|
@ -280,7 +280,7 @@ bool WaylandEglBackend::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();
|
||||
|
|
|
@ -123,7 +123,6 @@ private:
|
|||
};
|
||||
|
||||
WaylandBackend *m_backend;
|
||||
std::unique_ptr<GraphicsBufferAllocator> m_allocator;
|
||||
std::map<Output *, Layers> m_outputs;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue