wayland: Switch to ClientBuffer
The main motivation behind the split is to simplify client buffer code and allow adding new features easier, for example referencing the shm pool when a shm buffer is destroyed, or monitoring for readable linux dmabuf file descriptors, etc. Also, a referenced ClientBuffer cannot be destroyed, unlike the old BufferInterface.
This commit is contained in:
parent
95e954da30
commit
964c487d4f
26 changed files with 200 additions and 275 deletions
|
@ -31,7 +31,6 @@
|
|||
#include <KWayland/Client/shm_pool.h>
|
||||
#include <KWayland/Client/surface.h>
|
||||
|
||||
#include <KWaylandServer/buffer_interface.h>
|
||||
#include <KWaylandServer/clientconnection.h>
|
||||
#include <KWaylandServer/seat_interface.h>
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
#include <KWayland/Client/seat.h>
|
||||
#include <KWayland/Client/surface.h>
|
||||
#include <KWayland/Client/pointer.h>
|
||||
#include <KWaylandServer/buffer_interface.h>
|
||||
#include <KWaylandServer/shmclientbuffer.h>
|
||||
#include <KWaylandServer/surface_interface.h>
|
||||
|
||||
#include <QPainter>
|
||||
|
@ -347,7 +347,8 @@ void SceneQPainterTest::testX11Window()
|
|||
QVERIFY(waitForXwaylandBuffer(client, client->size()));
|
||||
QImage compareImage(client->clientSize(), QImage::Format_RGB32);
|
||||
compareImage.fill(Qt::white);
|
||||
QCOMPARE(client->surface()->buffer()->data().copy(QRect(client->clientPos(), client->clientSize())), compareImage);
|
||||
auto buffer = qobject_cast<KWaylandServer::ShmClientBuffer *>(client->surface()->buffer());
|
||||
QCOMPARE(buffer->data().copy(QRect(client->clientPos(), client->clientSize())), compareImage);
|
||||
|
||||
// enough time for rendering the window
|
||||
QTest::qWait(100);
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
#include "ui_debug_console.h"
|
||||
|
||||
// KWayland
|
||||
#include <KWaylandServer/buffer_interface.h>
|
||||
#include <KWaylandServer/shmclientbuffer.h>
|
||||
#include <KWaylandServer/clientconnection.h>
|
||||
#include <KWaylandServer/subcompositor_interface.h>
|
||||
#include <KWaylandServer/surface_interface.h>
|
||||
|
@ -1422,10 +1422,8 @@ QVariant SurfaceTreeModel::data(const QModelIndex &index, int role) const
|
|||
.arg(surface->client()->processId())
|
||||
.arg(surface->id());
|
||||
} else if (role == Qt::DecorationRole) {
|
||||
if (auto buffer = surface->buffer()) {
|
||||
if (buffer->shmBuffer()) {
|
||||
return buffer->data().scaled(QSize(64, 64), Qt::KeepAspectRatio);
|
||||
}
|
||||
if (auto buffer = qobject_cast<KWaylandServer::ShmClientBuffer *>(surface->buffer())) {
|
||||
return buffer->data().scaled(QSize(64, 64), Qt::KeepAspectRatio);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
#include <KWaylandServer/fakeinput_interface.h>
|
||||
#include <KWaylandServer/relativepointer_v1_interface.h>
|
||||
#include <KWaylandServer/seat_interface.h>
|
||||
#include <KWaylandServer/buffer_interface.h>
|
||||
#include <KWaylandServer/shmclientbuffer.h>
|
||||
#include <KWaylandServer/surface_interface.h>
|
||||
#include <KWaylandServer/tablet_v2_interface.h>
|
||||
#include <KWaylandServer/keyboard_interface.h>
|
||||
|
@ -1594,7 +1594,7 @@ public:
|
|||
private:
|
||||
void refresh()
|
||||
{
|
||||
auto buffer = m_surface->buffer();
|
||||
auto buffer = qobject_cast<KWaylandServer::ShmClientBuffer *>(m_surface->buffer());
|
||||
if (!buffer) {
|
||||
updateCursor({}, {});
|
||||
return;
|
||||
|
|
|
@ -10,56 +10,40 @@
|
|||
|
||||
#include "wayland_server.h"
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
namespace KWin
|
||||
{
|
||||
|
||||
DmabufBuffer::DmabufBuffer(const QVector<Plane> &planes,
|
||||
uint32_t format,
|
||||
const QSize &size,
|
||||
Flags flags)
|
||||
: KWaylandServer::LinuxDmabufUnstableV1Buffer(format, size)
|
||||
, m_planes(planes)
|
||||
, m_format(format)
|
||||
, m_size(size)
|
||||
, m_flags(flags)
|
||||
LinuxDmaBufV1ClientBuffer::LinuxDmaBufV1ClientBuffer(const QVector<KWaylandServer::LinuxDmaBufV1Plane> &planes,
|
||||
quint32 format,
|
||||
const QSize &size,
|
||||
quint32 flags)
|
||||
: KWaylandServer::LinuxDmaBufV1ClientBuffer(size, format, flags, planes)
|
||||
{
|
||||
waylandServer()->addLinuxDmabufBuffer(this);
|
||||
}
|
||||
|
||||
DmabufBuffer::~DmabufBuffer()
|
||||
LinuxDmaBufV1ClientBuffer::~LinuxDmaBufV1ClientBuffer()
|
||||
{
|
||||
// Close all open file descriptors
|
||||
for (int i = 0; i < m_planes.count(); i++) {
|
||||
if (m_planes[i].fd != -1)
|
||||
::close(m_planes[i].fd);
|
||||
m_planes[i].fd = -1;
|
||||
}
|
||||
if (waylandServer()) {
|
||||
waylandServer()->removeLinuxDmabufBuffer(this);
|
||||
}
|
||||
}
|
||||
|
||||
LinuxDmabuf::LinuxDmabuf()
|
||||
: KWaylandServer::LinuxDmabufUnstableV1Interface::Impl()
|
||||
LinuxDmaBufV1RendererInterface::LinuxDmaBufV1RendererInterface()
|
||||
{
|
||||
Q_ASSERT(waylandServer());
|
||||
waylandServer()->linuxDmabuf()->setImpl(this);
|
||||
waylandServer()->linuxDmabuf()->setRendererInterface(this);
|
||||
}
|
||||
|
||||
LinuxDmabuf::~LinuxDmabuf()
|
||||
LinuxDmaBufV1RendererInterface::~LinuxDmaBufV1RendererInterface()
|
||||
{
|
||||
waylandServer()->linuxDmabuf()->setImpl(nullptr);
|
||||
waylandServer()->linuxDmabuf()->setRendererInterface(nullptr);
|
||||
}
|
||||
|
||||
using Plane = KWaylandServer::LinuxDmabufUnstableV1Interface::Plane;
|
||||
using Flags = KWaylandServer::LinuxDmabufUnstableV1Interface::Flags;
|
||||
|
||||
KWaylandServer::LinuxDmabufUnstableV1Buffer* LinuxDmabuf::importBuffer(const QVector<Plane> &planes,
|
||||
uint32_t format,
|
||||
const QSize &size,
|
||||
Flags flags)
|
||||
KWaylandServer::LinuxDmaBufV1ClientBuffer *LinuxDmaBufV1RendererInterface::importBuffer(const QVector<KWaylandServer::LinuxDmaBufV1Plane> &planes,
|
||||
quint32 format,
|
||||
const QSize &size,
|
||||
quint32 flags)
|
||||
{
|
||||
Q_UNUSED(planes)
|
||||
Q_UNUSED(format)
|
||||
|
@ -69,7 +53,7 @@ KWaylandServer::LinuxDmabufUnstableV1Buffer* LinuxDmabuf::importBuffer(const QVe
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
void LinuxDmabuf::setSupportedFormatsAndModifiers(QHash<uint32_t, QSet<uint64_t> > &set)
|
||||
void LinuxDmaBufV1RendererInterface::setSupportedFormatsAndModifiers(const QHash<uint32_t, QSet<uint64_t>> &set)
|
||||
{
|
||||
waylandServer()->linuxDmabuf()->setSupportedFormatsWithModifiers(set);
|
||||
}
|
||||
|
|
|
@ -10,54 +10,34 @@
|
|||
|
||||
#include <kwin_export.h>
|
||||
|
||||
#include <KWaylandServer/linuxdmabuf_v1_interface.h>
|
||||
|
||||
#include <QVector>
|
||||
#include <KWaylandServer/linuxdmabufv1clientbuffer.h>
|
||||
|
||||
namespace KWin
|
||||
{
|
||||
|
||||
class KWIN_EXPORT DmabufBuffer : public KWaylandServer::LinuxDmabufUnstableV1Buffer
|
||||
class KWIN_EXPORT LinuxDmaBufV1ClientBuffer : public KWaylandServer::LinuxDmaBufV1ClientBuffer
|
||||
{
|
||||
public:
|
||||
using Plane = KWaylandServer::LinuxDmabufUnstableV1Interface::Plane;
|
||||
using Flags = KWaylandServer::LinuxDmabufUnstableV1Interface::Flags;
|
||||
|
||||
DmabufBuffer(const QVector<Plane> &planes,
|
||||
uint32_t format,
|
||||
const QSize &size,
|
||||
Flags flags);
|
||||
|
||||
~DmabufBuffer() override;
|
||||
|
||||
const QVector<Plane> &planes() const { return m_planes; }
|
||||
uint32_t format() const { return m_format; }
|
||||
QSize size() const { return m_size; }
|
||||
Flags flags() const { return m_flags; }
|
||||
|
||||
private:
|
||||
QVector<Plane> m_planes;
|
||||
uint32_t m_format;
|
||||
QSize m_size;
|
||||
Flags m_flags;
|
||||
LinuxDmaBufV1ClientBuffer(const QVector<KWaylandServer::LinuxDmaBufV1Plane> &planes,
|
||||
quint32 format,
|
||||
const QSize &size,
|
||||
quint32 flags);
|
||||
~LinuxDmaBufV1ClientBuffer() override;
|
||||
};
|
||||
|
||||
class KWIN_EXPORT LinuxDmabuf : public KWaylandServer::LinuxDmabufUnstableV1Interface::Impl
|
||||
class KWIN_EXPORT LinuxDmaBufV1RendererInterface : public KWaylandServer::LinuxDmaBufV1ClientBufferIntegration::RendererInterface
|
||||
{
|
||||
public:
|
||||
using Plane = KWaylandServer::LinuxDmabufUnstableV1Interface::Plane;
|
||||
using Flags = KWaylandServer::LinuxDmabufUnstableV1Interface::Flags;
|
||||
explicit LinuxDmaBufV1RendererInterface();
|
||||
~LinuxDmaBufV1RendererInterface() override;
|
||||
|
||||
explicit LinuxDmabuf();
|
||||
~LinuxDmabuf() override;
|
||||
|
||||
KWaylandServer::LinuxDmabufUnstableV1Buffer *importBuffer(const QVector<Plane> &planes,
|
||||
uint32_t format,
|
||||
const QSize &size,
|
||||
Flags flags) override;
|
||||
KWaylandServer::LinuxDmaBufV1ClientBuffer *importBuffer(const QVector<KWaylandServer::LinuxDmaBufV1Plane> &planes,
|
||||
quint32 format,
|
||||
const QSize &size,
|
||||
quint32 flags) override;
|
||||
|
||||
protected:
|
||||
void setSupportedFormatsAndModifiers(QHash<uint32_t, QSet<uint64_t> > &set);
|
||||
void setSupportedFormatsAndModifiers(const QHash<uint32_t, QSet<uint64_t>> &set);
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -11,8 +11,9 @@
|
|||
#include "logging.h"
|
||||
#include "surfaceitem_wayland.h"
|
||||
|
||||
#include <KWaylandServer/buffer_interface.h>
|
||||
#include <KWaylandServer/linuxdmabuf_v1_interface.h>
|
||||
#include <KWaylandServer/drmclientbuffer.h>
|
||||
#include <KWaylandServer/linuxdmabufv1clientbuffer.h>
|
||||
#include <KWaylandServer/shmclientbuffer.h>
|
||||
|
||||
namespace KWin
|
||||
{
|
||||
|
@ -35,16 +36,14 @@ AbstractEglBackend *BasicEGLSurfaceTextureWayland::backend() const
|
|||
|
||||
bool BasicEGLSurfaceTextureWayland::create()
|
||||
{
|
||||
KWaylandServer::BufferInterface *buffer = m_pixmap->buffer();
|
||||
if (Q_UNLIKELY(!buffer)) {
|
||||
return false;
|
||||
}
|
||||
if (buffer->linuxDmabufBuffer()) {
|
||||
if (auto buffer = qobject_cast<KWaylandServer::LinuxDmaBufV1ClientBuffer *>(m_pixmap->buffer())) {
|
||||
return loadDmabufTexture(buffer);
|
||||
} else if (buffer->shmBuffer()) {
|
||||
} else if (auto buffer = qobject_cast<KWaylandServer::ShmClientBuffer *>(m_pixmap->buffer())) {
|
||||
return loadShmTexture(buffer);
|
||||
} else {
|
||||
} else if (auto buffer = qobject_cast<KWaylandServer::DrmClientBuffer *>(m_pixmap->buffer())) {
|
||||
return loadEglTexture(buffer);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -60,20 +59,16 @@ void BasicEGLSurfaceTextureWayland::destroy()
|
|||
|
||||
void BasicEGLSurfaceTextureWayland::update(const QRegion ®ion)
|
||||
{
|
||||
KWaylandServer::BufferInterface *buffer = m_pixmap->buffer();
|
||||
if (Q_UNLIKELY(!buffer)) {
|
||||
return;
|
||||
}
|
||||
if (buffer->linuxDmabufBuffer()) {
|
||||
if (auto buffer = qobject_cast<KWaylandServer::LinuxDmaBufV1ClientBuffer *>(m_pixmap->buffer())) {
|
||||
updateDmabufTexture(buffer);
|
||||
} else if (buffer->shmBuffer()) {
|
||||
} else if (auto buffer = qobject_cast<KWaylandServer::ShmClientBuffer *>(m_pixmap->buffer())) {
|
||||
updateShmTexture(buffer, region);
|
||||
} else {
|
||||
} else if (auto buffer = qobject_cast<KWaylandServer::DrmClientBuffer *>(m_pixmap->buffer())) {
|
||||
updateEglTexture(buffer);
|
||||
}
|
||||
}
|
||||
|
||||
bool BasicEGLSurfaceTextureWayland::loadShmTexture(KWaylandServer::BufferInterface *buffer)
|
||||
bool BasicEGLSurfaceTextureWayland::loadShmTexture(KWaylandServer::ShmClientBuffer *buffer)
|
||||
{
|
||||
const QImage &image = buffer->data();
|
||||
if (Q_UNLIKELY(image.isNull())) {
|
||||
|
@ -89,7 +84,7 @@ bool BasicEGLSurfaceTextureWayland::loadShmTexture(KWaylandServer::BufferInterfa
|
|||
return true;
|
||||
}
|
||||
|
||||
void BasicEGLSurfaceTextureWayland::updateShmTexture(KWaylandServer::BufferInterface *buffer, const QRegion ®ion)
|
||||
void BasicEGLSurfaceTextureWayland::updateShmTexture(KWaylandServer::ShmClientBuffer *buffer, const QRegion ®ion)
|
||||
{
|
||||
if (Q_UNLIKELY(m_bufferType != BufferType::Shm)) {
|
||||
destroy();
|
||||
|
@ -108,7 +103,7 @@ void BasicEGLSurfaceTextureWayland::updateShmTexture(KWaylandServer::BufferInter
|
|||
}
|
||||
}
|
||||
|
||||
bool BasicEGLSurfaceTextureWayland::loadEglTexture(KWaylandServer::BufferInterface *buffer)
|
||||
bool BasicEGLSurfaceTextureWayland::loadEglTexture(KWaylandServer::DrmClientBuffer *buffer)
|
||||
{
|
||||
const AbstractEglBackendFunctions *funcs = backend()->functions();
|
||||
if (Q_UNLIKELY(!funcs->eglQueryWaylandBufferWL)) {
|
||||
|
@ -137,13 +132,16 @@ bool BasicEGLSurfaceTextureWayland::loadEglTexture(KWaylandServer::BufferInterfa
|
|||
return true;
|
||||
}
|
||||
|
||||
void BasicEGLSurfaceTextureWayland::updateEglTexture(KWaylandServer::BufferInterface *buffer)
|
||||
void BasicEGLSurfaceTextureWayland::updateEglTexture(KWaylandServer::DrmClientBuffer *buffer)
|
||||
{
|
||||
if (Q_UNLIKELY(m_bufferType != BufferType::Egl)) {
|
||||
destroy();
|
||||
create();
|
||||
return;
|
||||
}
|
||||
if (Q_UNLIKELY(!buffer->resource())) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_texture->bind();
|
||||
EGLImageKHR image = attach(buffer);
|
||||
|
@ -156,9 +154,9 @@ void BasicEGLSurfaceTextureWayland::updateEglTexture(KWaylandServer::BufferInter
|
|||
}
|
||||
}
|
||||
|
||||
bool BasicEGLSurfaceTextureWayland::loadDmabufTexture(KWaylandServer::BufferInterface *buffer)
|
||||
bool BasicEGLSurfaceTextureWayland::loadDmabufTexture(KWaylandServer::LinuxDmaBufV1ClientBuffer *buffer)
|
||||
{
|
||||
auto dmabuf = static_cast<EglDmabufBuffer *>(buffer->linuxDmabufBuffer());
|
||||
auto dmabuf = static_cast<EglDmabufBuffer *>(buffer);
|
||||
if (Q_UNLIKELY(dmabuf->images().constFirst() == EGL_NO_IMAGE_KHR)) {
|
||||
qCritical(KWIN_OPENGL) << "Invalid dmabuf-based wl_buffer";
|
||||
return false;
|
||||
|
@ -172,13 +170,13 @@ bool BasicEGLSurfaceTextureWayland::loadDmabufTexture(KWaylandServer::BufferInte
|
|||
m_texture->bind();
|
||||
glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, static_cast<GLeglImageOES>(dmabuf->images().constFirst()));
|
||||
m_texture->unbind();
|
||||
m_texture->setYInverted(!(dmabuf->flags() & KWaylandServer::LinuxDmabufUnstableV1Interface::YInverted));
|
||||
m_texture->setYInverted(dmabuf->origin() == KWaylandServer::ClientBuffer::Origin::TopLeft);
|
||||
m_bufferType = BufferType::DmaBuf;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void BasicEGLSurfaceTextureWayland::updateDmabufTexture(KWaylandServer::BufferInterface *buffer)
|
||||
void BasicEGLSurfaceTextureWayland::updateDmabufTexture(KWaylandServer::LinuxDmaBufV1ClientBuffer *buffer)
|
||||
{
|
||||
if (Q_UNLIKELY(m_bufferType != BufferType::DmaBuf)) {
|
||||
destroy();
|
||||
|
@ -186,35 +184,22 @@ void BasicEGLSurfaceTextureWayland::updateDmabufTexture(KWaylandServer::BufferIn
|
|||
return;
|
||||
}
|
||||
|
||||
auto dmabuf = static_cast<EglDmabufBuffer *>(buffer->linuxDmabufBuffer());
|
||||
auto dmabuf = static_cast<EglDmabufBuffer *>(buffer);
|
||||
m_texture->bind();
|
||||
glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, static_cast<GLeglImageOES>(dmabuf->images().constFirst()));
|
||||
m_texture->unbind();
|
||||
// The origin in a dmabuf-buffer is at the upper-left corner, so the meaning
|
||||
// of Y-inverted is the inverse of OpenGL.
|
||||
m_texture->setYInverted(!(dmabuf->flags() & KWaylandServer::LinuxDmabufUnstableV1Interface::YInverted));
|
||||
m_texture->setYInverted(dmabuf->origin() == KWaylandServer::ClientBuffer::Origin::TopLeft);
|
||||
}
|
||||
|
||||
EGLImageKHR BasicEGLSurfaceTextureWayland::attach(KWaylandServer::BufferInterface *buffer)
|
||||
EGLImageKHR BasicEGLSurfaceTextureWayland::attach(KWaylandServer::DrmClientBuffer *buffer)
|
||||
{
|
||||
const AbstractEglBackendFunctions *funcs = backend()->functions();
|
||||
|
||||
EGLint format;
|
||||
funcs->eglQueryWaylandBufferWL(backend()->eglDisplay(), buffer->resource(),
|
||||
EGL_TEXTURE_FORMAT, &format);
|
||||
if (format != EGL_TEXTURE_RGB && format != EGL_TEXTURE_RGBA) {
|
||||
qCDebug(KWIN_OPENGL) << "Unsupported texture format: " << format;
|
||||
if (buffer->textureFormat() != EGL_TEXTURE_RGB && buffer->textureFormat() != EGL_TEXTURE_RGBA) {
|
||||
qCDebug(KWIN_OPENGL) << "Unsupported texture format: " << buffer->textureFormat();
|
||||
return EGL_NO_IMAGE_KHR;
|
||||
}
|
||||
|
||||
EGLint yInverted;
|
||||
if (!funcs->eglQueryWaylandBufferWL(backend()->eglDisplay(), buffer->resource(),
|
||||
EGL_WAYLAND_Y_INVERTED_WL, &yInverted)) {
|
||||
// If EGL_WAYLAND_Y_INVERTED_WL is not supported wl_buffer should be treated as
|
||||
// if value were EGL_TRUE.
|
||||
yInverted = EGL_TRUE;
|
||||
}
|
||||
|
||||
const EGLint attribs[] = {
|
||||
EGL_WAYLAND_PLANE_WL, 0,
|
||||
EGL_NONE
|
||||
|
@ -224,7 +209,7 @@ EGLImageKHR BasicEGLSurfaceTextureWayland::attach(KWaylandServer::BufferInterfac
|
|||
static_cast<EGLClientBuffer>(buffer->resource()), attribs);
|
||||
if (image != EGL_NO_IMAGE_KHR) {
|
||||
glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, static_cast<GLeglImageOES>(image));
|
||||
m_texture->setYInverted(yInverted);
|
||||
m_texture->setYInverted(buffer->origin() == KWaylandServer::ClientBuffer::Origin::TopLeft);
|
||||
}
|
||||
return image;
|
||||
}
|
||||
|
|
|
@ -12,7 +12,9 @@
|
|||
|
||||
namespace KWaylandServer
|
||||
{
|
||||
class BufferInterface;
|
||||
class DrmClientBuffer;
|
||||
class ShmClientBuffer;
|
||||
class LinuxDmaBufV1ClientBuffer;
|
||||
}
|
||||
|
||||
namespace KWin
|
||||
|
@ -32,13 +34,13 @@ public:
|
|||
void update(const QRegion ®ion) override;
|
||||
|
||||
private:
|
||||
bool loadShmTexture(KWaylandServer::BufferInterface *buffer);
|
||||
void updateShmTexture(KWaylandServer::BufferInterface *buffer, const QRegion ®ion);
|
||||
bool loadEglTexture(KWaylandServer::BufferInterface *buffer);
|
||||
void updateEglTexture(KWaylandServer::BufferInterface *buffer);
|
||||
bool loadDmabufTexture(KWaylandServer::BufferInterface *buffer);
|
||||
void updateDmabufTexture(KWaylandServer::BufferInterface *buffer);
|
||||
EGLImageKHR attach(KWaylandServer::BufferInterface *buffer);
|
||||
bool loadShmTexture(KWaylandServer::ShmClientBuffer *buffer);
|
||||
void updateShmTexture(KWaylandServer::ShmClientBuffer *buffer, const QRegion ®ion);
|
||||
bool loadEglTexture(KWaylandServer::DrmClientBuffer *buffer);
|
||||
void updateEglTexture(KWaylandServer::DrmClientBuffer *buffer);
|
||||
bool loadDmabufTexture(KWaylandServer::LinuxDmaBufV1ClientBuffer *buffer);
|
||||
void updateDmabufTexture(KWaylandServer::LinuxDmaBufV1ClientBuffer *buffer);
|
||||
EGLImageKHR attach(KWaylandServer::DrmClientBuffer *buffer);
|
||||
void destroy();
|
||||
|
||||
enum class BufferType {
|
||||
|
|
|
@ -122,10 +122,10 @@ YuvFormat yuvFormats[] = {
|
|||
};
|
||||
|
||||
EglDmabufBuffer::EglDmabufBuffer(EGLImage image,
|
||||
const QVector<Plane> &planes,
|
||||
const QVector<KWaylandServer::LinuxDmaBufV1Plane> &planes,
|
||||
uint32_t format,
|
||||
const QSize &size,
|
||||
Flags flags,
|
||||
quint32 flags,
|
||||
EglDmabuf *interfaceImpl)
|
||||
: EglDmabufBuffer(planes, format, size, flags, interfaceImpl)
|
||||
{
|
||||
|
@ -134,12 +134,12 @@ EglDmabufBuffer::EglDmabufBuffer(EGLImage image,
|
|||
}
|
||||
|
||||
|
||||
EglDmabufBuffer::EglDmabufBuffer(const QVector<Plane> &planes,
|
||||
EglDmabufBuffer::EglDmabufBuffer(const QVector<KWaylandServer::LinuxDmaBufV1Plane> &planes,
|
||||
uint32_t format,
|
||||
const QSize &size,
|
||||
Flags flags,
|
||||
quint32 flags,
|
||||
EglDmabuf *interfaceImpl)
|
||||
: DmabufBuffer(planes, format, size, flags)
|
||||
: LinuxDmaBufV1ClientBuffer(planes, format, size, flags)
|
||||
, m_interfaceImpl(interfaceImpl)
|
||||
{
|
||||
m_importType = ImportType::Conversion;
|
||||
|
@ -168,10 +168,7 @@ void EglDmabufBuffer::removeImages()
|
|||
m_images.clear();
|
||||
}
|
||||
|
||||
using Plane = KWaylandServer::LinuxDmabufUnstableV1Interface::Plane;
|
||||
using Flags = KWaylandServer::LinuxDmabufUnstableV1Interface::Flags;
|
||||
|
||||
EGLImage EglDmabuf::createImage(const QVector<Plane> &planes,
|
||||
EGLImage EglDmabuf::createImage(const QVector<KWaylandServer::LinuxDmaBufV1Plane> &planes,
|
||||
uint32_t format,
|
||||
const QSize &size)
|
||||
{
|
||||
|
@ -248,10 +245,10 @@ EGLImage EglDmabuf::createImage(const QVector<Plane> &planes,
|
|||
return image;
|
||||
}
|
||||
|
||||
KWaylandServer::LinuxDmabufUnstableV1Buffer* EglDmabuf::importBuffer(const QVector<Plane> &planes,
|
||||
uint32_t format,
|
||||
const QSize &size,
|
||||
Flags flags)
|
||||
KWaylandServer::LinuxDmaBufV1ClientBuffer *EglDmabuf::importBuffer(const QVector<KWaylandServer::LinuxDmaBufV1Plane> &planes,
|
||||
quint32 format,
|
||||
const QSize &size,
|
||||
quint32 flags)
|
||||
{
|
||||
Q_ASSERT(planes.count() > 0);
|
||||
|
||||
|
@ -268,10 +265,10 @@ KWaylandServer::LinuxDmabufUnstableV1Buffer* EglDmabuf::importBuffer(const QVect
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
KWaylandServer::LinuxDmabufUnstableV1Buffer* EglDmabuf::yuvImport(const QVector<Plane> &planes,
|
||||
uint32_t format,
|
||||
const QSize &size,
|
||||
Flags flags)
|
||||
KWaylandServer::LinuxDmaBufV1ClientBuffer *EglDmabuf::yuvImport(const QVector<KWaylandServer::LinuxDmaBufV1Plane> &planes,
|
||||
quint32 format,
|
||||
const QSize &size,
|
||||
quint32 flags)
|
||||
{
|
||||
YuvFormat yuvFormat;
|
||||
for (YuvFormat f : yuvFormats) {
|
||||
|
@ -291,7 +288,7 @@ KWaylandServer::LinuxDmabufUnstableV1Buffer* EglDmabuf::yuvImport(const QVector<
|
|||
|
||||
for (int i = 0; i < yuvFormat.outputPlanes; i++) {
|
||||
int planeIndex = yuvFormat.planes[i].planeIndex;
|
||||
Plane plane = {
|
||||
KWaylandServer::LinuxDmaBufV1Plane plane = {
|
||||
planes[planeIndex].fd,
|
||||
planes[planeIndex].offset,
|
||||
planes[planeIndex].stride,
|
||||
|
@ -300,7 +297,7 @@ KWaylandServer::LinuxDmabufUnstableV1Buffer* EglDmabuf::yuvImport(const QVector<
|
|||
const auto planeFormat = yuvFormat.planes[i].format;
|
||||
const auto planeSize = QSize(size.width() / yuvFormat.planes[i].widthDivisor,
|
||||
size.height() / yuvFormat.planes[i].heightDivisor);
|
||||
auto *image = createImage(QVector<Plane>(1, plane),
|
||||
auto *image = createImage(QVector<KWaylandServer::LinuxDmaBufV1Plane>(1, plane),
|
||||
planeFormat,
|
||||
planeSize);
|
||||
if (!image) {
|
||||
|
@ -332,8 +329,7 @@ EglDmabuf* EglDmabuf::factory(AbstractEglBackend *backend)
|
|||
}
|
||||
|
||||
EglDmabuf::EglDmabuf(AbstractEglBackend *backend)
|
||||
: LinuxDmabuf()
|
||||
, m_backend(backend)
|
||||
: m_backend(backend)
|
||||
{
|
||||
auto prevBuffersSet = waylandServer()->linuxDmabufBuffers();
|
||||
for (auto *buffer : prevBuffersSet) {
|
||||
|
@ -439,7 +435,7 @@ void EglDmabuf::setSupportedFormatsAndModifiers()
|
|||
set.insert(format, QSet<uint64_t>());
|
||||
}
|
||||
|
||||
LinuxDmabuf::setSupportedFormatsAndModifiers(set);
|
||||
LinuxDmaBufV1RendererInterface::setSupportedFormatsAndModifiers(set);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -19,28 +19,25 @@ namespace KWin
|
|||
{
|
||||
class EglDmabuf;
|
||||
|
||||
class EglDmabufBuffer : public DmabufBuffer
|
||||
class EglDmabufBuffer : public LinuxDmaBufV1ClientBuffer
|
||||
{
|
||||
public:
|
||||
using Plane = KWaylandServer::LinuxDmabufUnstableV1Interface::Plane;
|
||||
using Flags = KWaylandServer::LinuxDmabufUnstableV1Interface::Flags;
|
||||
|
||||
enum class ImportType {
|
||||
Direct,
|
||||
Conversion
|
||||
};
|
||||
|
||||
EglDmabufBuffer(EGLImage image,
|
||||
const QVector<Plane> &planes,
|
||||
uint32_t format,
|
||||
const QVector<KWaylandServer::LinuxDmaBufV1Plane> &planes,
|
||||
quint32 format,
|
||||
const QSize &size,
|
||||
Flags flags,
|
||||
quint32 flags,
|
||||
EglDmabuf *interfaceImpl);
|
||||
|
||||
EglDmabufBuffer(const QVector<Plane> &planes,
|
||||
uint32_t format,
|
||||
EglDmabufBuffer(const QVector<KWaylandServer::LinuxDmaBufV1Plane> &planes,
|
||||
quint32 format,
|
||||
const QSize &size,
|
||||
Flags flags,
|
||||
quint32 flags,
|
||||
EglDmabuf *interfaceImpl);
|
||||
|
||||
~EglDmabufBuffer() override;
|
||||
|
@ -57,31 +54,28 @@ private:
|
|||
ImportType m_importType;
|
||||
};
|
||||
|
||||
class EglDmabuf : public LinuxDmabuf
|
||||
class EglDmabuf : public LinuxDmaBufV1RendererInterface
|
||||
{
|
||||
public:
|
||||
using Plane = KWaylandServer::LinuxDmabufUnstableV1Interface::Plane;
|
||||
using Flags = KWaylandServer::LinuxDmabufUnstableV1Interface::Flags;
|
||||
|
||||
static EglDmabuf* factory(AbstractEglBackend *backend);
|
||||
|
||||
explicit EglDmabuf(AbstractEglBackend *backend);
|
||||
~EglDmabuf() override;
|
||||
|
||||
KWaylandServer::LinuxDmabufUnstableV1Buffer *importBuffer(const QVector<Plane> &planes,
|
||||
uint32_t format,
|
||||
const QSize &size,
|
||||
Flags flags) override;
|
||||
KWaylandServer::LinuxDmaBufV1ClientBuffer *importBuffer(const QVector<KWaylandServer::LinuxDmaBufV1Plane> &planes,
|
||||
quint32 format,
|
||||
const QSize &size,
|
||||
quint32 flags) override;
|
||||
|
||||
private:
|
||||
EGLImage createImage(const QVector<Plane> &planes,
|
||||
EGLImage createImage(const QVector<KWaylandServer::LinuxDmaBufV1Plane> &planes,
|
||||
uint32_t format,
|
||||
const QSize &size);
|
||||
|
||||
KWaylandServer::LinuxDmabufUnstableV1Buffer *yuvImport(const QVector<Plane> &planes,
|
||||
uint32_t format,
|
||||
const QSize &size,
|
||||
Flags flags);
|
||||
KWaylandServer::LinuxDmaBufV1ClientBuffer *yuvImport(const QVector<KWaylandServer::LinuxDmaBufV1Plane> &planes,
|
||||
quint32 format,
|
||||
const QSize &size,
|
||||
quint32 flags);
|
||||
|
||||
void setSupportedFormatsAndModifiers();
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#include "platformqpaintersurfacetexture_wayland.h"
|
||||
#include "surfaceitem_wayland.h"
|
||||
|
||||
#include <KWaylandServer/buffer_interface.h>
|
||||
#include <KWaylandServer/shmclientbuffer.h>
|
||||
#include <KWaylandServer/surface_interface.h>
|
||||
|
||||
#include <QPainter>
|
||||
|
@ -24,7 +24,7 @@ PlatformQPainterSurfaceTextureWayland::PlatformQPainterSurfaceTextureWayland(QPa
|
|||
|
||||
bool PlatformQPainterSurfaceTextureWayland::create()
|
||||
{
|
||||
KWaylandServer::BufferInterface *buffer = m_pixmap->buffer();
|
||||
auto buffer = qobject_cast<KWaylandServer::ShmClientBuffer *>(m_pixmap->buffer());
|
||||
if (Q_LIKELY(buffer)) {
|
||||
// The buffer data is copied as the buffer interface returns a QImage
|
||||
// which doesn't own the data of the underlying wl_shm_buffer object.
|
||||
|
@ -35,7 +35,7 @@ bool PlatformQPainterSurfaceTextureWayland::create()
|
|||
|
||||
void PlatformQPainterSurfaceTextureWayland::update(const QRegion ®ion)
|
||||
{
|
||||
KWaylandServer::BufferInterface *buffer = m_pixmap->buffer();
|
||||
auto buffer = qobject_cast<KWaylandServer::ShmClientBuffer *>(m_pixmap->buffer());
|
||||
if (Q_UNLIKELY(!buffer)) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
#include <xf86drmMode.h>
|
||||
#include <gbm.h>
|
||||
// KWaylandServer
|
||||
#include "KWaylandServer/buffer_interface.h"
|
||||
#include "KWaylandServer/clientbuffer.h"
|
||||
#include <drm_fourcc.h>
|
||||
|
||||
namespace KWin
|
||||
|
@ -35,14 +35,13 @@ GbmBuffer::GbmBuffer(GbmSurface *surface, gbm_bo *bo)
|
|||
m_stride = gbm_bo_get_stride(m_bo);
|
||||
}
|
||||
|
||||
GbmBuffer::GbmBuffer(gbm_bo *buffer, KWaylandServer::BufferInterface *bufferInterface)
|
||||
GbmBuffer::GbmBuffer(gbm_bo *buffer, KWaylandServer::ClientBuffer *clientBuffer)
|
||||
: m_bo(buffer)
|
||||
, m_bufferInterface(bufferInterface)
|
||||
, m_clientBuffer(clientBuffer)
|
||||
, m_stride(gbm_bo_get_stride(m_bo))
|
||||
{
|
||||
if (m_bufferInterface) {
|
||||
m_bufferInterface->ref();
|
||||
connect(m_bufferInterface, &KWaylandServer::BufferInterface::aboutToBeDestroyed, this, &GbmBuffer::clearBufferInterface);
|
||||
if (m_clientBuffer) {
|
||||
m_clientBuffer->ref();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -53,8 +52,9 @@ GbmBuffer::~GbmBuffer()
|
|||
|
||||
void GbmBuffer::releaseBuffer()
|
||||
{
|
||||
if (m_bufferInterface) {
|
||||
clearBufferInterface();
|
||||
if (m_clientBuffer) {
|
||||
m_clientBuffer->unref();
|
||||
m_clientBuffer = nullptr;
|
||||
}
|
||||
if (!m_bo) {
|
||||
return;
|
||||
|
@ -83,12 +83,6 @@ bool GbmBuffer::map(uint32_t flags)
|
|||
return m_data;
|
||||
}
|
||||
|
||||
void GbmBuffer::clearBufferInterface()
|
||||
{
|
||||
disconnect(m_bufferInterface, &KWaylandServer::BufferInterface::aboutToBeDestroyed, this, &DrmGbmBuffer::clearBufferInterface);
|
||||
m_bufferInterface->unref();
|
||||
m_bufferInterface = nullptr;
|
||||
}
|
||||
|
||||
DrmGbmBuffer::DrmGbmBuffer(DrmGpu *gpu, GbmSurface *surface, gbm_bo *bo)
|
||||
: DrmBuffer(gpu), GbmBuffer(surface, bo)
|
||||
|
@ -96,8 +90,8 @@ DrmGbmBuffer::DrmGbmBuffer(DrmGpu *gpu, GbmSurface *surface, gbm_bo *bo)
|
|||
initialize();
|
||||
}
|
||||
|
||||
DrmGbmBuffer::DrmGbmBuffer(DrmGpu *gpu, gbm_bo *buffer, KWaylandServer::BufferInterface *bufferInterface)
|
||||
: DrmBuffer(gpu), GbmBuffer(buffer, bufferInterface)
|
||||
DrmGbmBuffer::DrmGbmBuffer(DrmGpu *gpu, gbm_bo *buffer, KWaylandServer::ClientBuffer *clientBuffer)
|
||||
: DrmBuffer(gpu), GbmBuffer(buffer, clientBuffer)
|
||||
{
|
||||
initialize();
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ struct gbm_bo;
|
|||
|
||||
namespace KWaylandServer
|
||||
{
|
||||
class BufferInterface;
|
||||
class ClientBuffer;
|
||||
}
|
||||
|
||||
namespace KWin
|
||||
|
@ -31,7 +31,7 @@ class GbmBuffer : public QObject
|
|||
Q_OBJECT
|
||||
public:
|
||||
GbmBuffer(GbmSurface *surface, gbm_bo *bo);
|
||||
GbmBuffer(gbm_bo *buffer, KWaylandServer::BufferInterface *bufferInterface);
|
||||
GbmBuffer(gbm_bo *buffer, KWaylandServer::ClientBuffer *clientBuffer);
|
||||
virtual ~GbmBuffer();
|
||||
|
||||
gbm_bo* getBo() const {
|
||||
|
@ -51,20 +51,18 @@ public:
|
|||
protected:
|
||||
GbmSurface *m_surface = nullptr;
|
||||
gbm_bo *m_bo = nullptr;
|
||||
KWaylandServer::BufferInterface *m_bufferInterface = nullptr;
|
||||
KWaylandServer::ClientBuffer *m_clientBuffer = nullptr;
|
||||
|
||||
void *m_data = nullptr;
|
||||
void *m_mapping = nullptr;
|
||||
uint32_t m_stride = 0;
|
||||
|
||||
void clearBufferInterface();
|
||||
};
|
||||
|
||||
class DrmGbmBuffer : public DrmBuffer, public GbmBuffer
|
||||
{
|
||||
public:
|
||||
DrmGbmBuffer(DrmGpu *gpu, GbmSurface *surface, gbm_bo *bo);
|
||||
DrmGbmBuffer(DrmGpu *gpu, gbm_bo *buffer, KWaylandServer::BufferInterface *bufferInterface);
|
||||
DrmGbmBuffer(DrmGpu *gpu, gbm_bo *buffer, KWaylandServer::ClientBuffer *clientBuffer);
|
||||
~DrmGbmBuffer() override;
|
||||
|
||||
bool needsModeChange(DrmBuffer *b) const override {
|
||||
|
|
|
@ -33,12 +33,10 @@
|
|||
#include <gbm.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <egl_dmabuf.h>
|
||||
#include <drm_fourcc.h>
|
||||
// kwayland server
|
||||
#include "KWaylandServer/surface_interface.h"
|
||||
#include "KWaylandServer/buffer_interface.h"
|
||||
#include "KWaylandServer/linuxdmabuf_v1_interface.h"
|
||||
#include "KWaylandServer/linuxdmabufv1clientbuffer.h"
|
||||
#include "KWaylandServer/clientconnection.h"
|
||||
|
||||
namespace KWin
|
||||
|
@ -598,47 +596,50 @@ bool EglGbmBackend::scanout(int screenId, SurfaceItem *surfaceItem)
|
|||
}
|
||||
|
||||
KWaylandServer::SurfaceInterface *surface = item->surface();
|
||||
if (!surface || !surface->buffer() || !surface->buffer()->linuxDmabufBuffer()) {
|
||||
if (!surface) {
|
||||
return false;
|
||||
}
|
||||
|
||||
auto buffer = qobject_cast<KWaylandServer::LinuxDmaBufV1ClientBuffer *>(surface->buffer());
|
||||
if (!buffer) {
|
||||
return false;
|
||||
}
|
||||
auto buffer = surface->buffer();
|
||||
Output &output = m_outputs[screenId];
|
||||
if (buffer->linuxDmabufBuffer()->size() != output.output->modeSize()) {
|
||||
if (buffer->size() != output.output->modeSize()) {
|
||||
return false;
|
||||
}
|
||||
EglDmabufBuffer *dmabuf = static_cast<EglDmabufBuffer*>(buffer->linuxDmabufBuffer());
|
||||
if (!dmabuf || !dmabuf->planes().count() ||
|
||||
!gbm_device_is_format_supported(m_gpu->gbmDevice(), dmabuf->format(), GBM_BO_USE_SCANOUT)) {
|
||||
if (!buffer->planes().count() ||
|
||||
!gbm_device_is_format_supported(m_gpu->gbmDevice(), buffer->format(), GBM_BO_USE_SCANOUT)) {
|
||||
return false;
|
||||
}
|
||||
gbm_bo *importedBuffer;
|
||||
if (dmabuf->planes()[0].modifier != DRM_FORMAT_MOD_INVALID
|
||||
|| dmabuf->planes()[0].offset > 0
|
||||
|| dmabuf->planes().size() > 1) {
|
||||
if (buffer->planes()[0].modifier != DRM_FORMAT_MOD_INVALID
|
||||
|| buffer->planes()[0].offset > 0
|
||||
|| buffer->planes().size() > 1) {
|
||||
if (!m_gpu->addFB2ModifiersSupported()) {
|
||||
return false;
|
||||
}
|
||||
gbm_import_fd_modifier_data data = {};
|
||||
data.format = dmabuf->format();
|
||||
data.width = (uint32_t) dmabuf->size().width();
|
||||
data.height = (uint32_t) dmabuf->size().height();
|
||||
data.num_fds = dmabuf->planes().count();
|
||||
data.modifier = dmabuf->planes()[0].modifier;
|
||||
for (int i = 0; i < dmabuf->planes().count(); i++) {
|
||||
auto plane = dmabuf->planes()[i];
|
||||
data.format = buffer->format();
|
||||
data.width = (uint32_t) buffer->size().width();
|
||||
data.height = (uint32_t) buffer->size().height();
|
||||
data.num_fds = buffer->planes().count();
|
||||
data.modifier = buffer->planes()[0].modifier;
|
||||
for (int i = 0; i < buffer->planes().count(); i++) {
|
||||
auto plane = buffer->planes()[i];
|
||||
data.fds[i] = plane.fd;
|
||||
data.offsets[i] = plane.offset;
|
||||
data.strides[i] = plane.stride;
|
||||
}
|
||||
importedBuffer = gbm_bo_import(m_gpu->gbmDevice(), GBM_BO_IMPORT_FD_MODIFIER, &data, GBM_BO_USE_SCANOUT);
|
||||
} else {
|
||||
auto plane = dmabuf->planes()[0];
|
||||
auto plane = buffer->planes()[0];
|
||||
gbm_import_fd_data data = {};
|
||||
data.fd = plane.fd;
|
||||
data.width = (uint32_t) dmabuf->size().width();
|
||||
data.height = (uint32_t) dmabuf->size().height();
|
||||
data.width = (uint32_t) buffer->size().width();
|
||||
data.height = (uint32_t) buffer->size().height();
|
||||
data.stride = plane.stride;
|
||||
data.format = dmabuf->format();
|
||||
data.format = buffer->format();
|
||||
importedBuffer = gbm_bo_import(m_gpu->gbmDevice(), GBM_BO_IMPORT_FD, &data, GBM_BO_USE_SCANOUT);
|
||||
}
|
||||
if (!importedBuffer) {
|
||||
|
|
|
@ -19,7 +19,6 @@ struct gbm_bo;
|
|||
|
||||
namespace KWaylandServer
|
||||
{
|
||||
class BufferInterface;
|
||||
class SurfaceInterface;
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
#include "drm_pipeline.h"
|
||||
|
||||
#include <QOpenGLContext>
|
||||
#include <KWaylandServer/buffer_interface.h>
|
||||
#include <KWaylandServer/clientbuffer.h>
|
||||
#include <KWaylandServer/display.h>
|
||||
#include <KWaylandServer/eglstream_controller_interface.h>
|
||||
#include <KWaylandServer/resource.h>
|
||||
|
@ -664,7 +664,7 @@ void EglStreamSurfaceTextureWayland::copyExternalTexture(GLuint tex)
|
|||
glViewport(oldViewport[0], oldViewport[1], oldViewport[2], oldViewport[3]);
|
||||
}
|
||||
|
||||
bool EglStreamSurfaceTextureWayland::attachBuffer(KWaylandServer::BufferInterface *buffer)
|
||||
bool EglStreamSurfaceTextureWayland::attachBuffer(KWaylandServer::ClientBuffer *buffer)
|
||||
{
|
||||
GLenum oldFormat = m_format;
|
||||
m_format = buffer->hasAlphaChannel() ? GL_RGBA : GL_RGB;
|
||||
|
@ -679,7 +679,7 @@ bool EglStreamSurfaceTextureWayland::attachBuffer(KWaylandServer::BufferInterfac
|
|||
}
|
||||
|
||||
bool EglStreamSurfaceTextureWayland::checkBuffer(KWaylandServer::SurfaceInterface *surface,
|
||||
KWaylandServer::BufferInterface *buffer)
|
||||
KWaylandServer::ClientBuffer *buffer)
|
||||
{
|
||||
EGLAttrib attribs[] = {
|
||||
EGL_WAYLAND_EGLSTREAM_WL, (EGLAttrib)buffer->resource(),
|
||||
|
|
|
@ -98,9 +98,9 @@ private:
|
|||
bool acquireStreamFrame(EGLStreamKHR stream);
|
||||
void createFbo();
|
||||
void copyExternalTexture(GLuint tex);
|
||||
bool attachBuffer(KWaylandServer::BufferInterface *buffer);
|
||||
bool attachBuffer(KWaylandServer::ClientBuffer *buffer);
|
||||
bool checkBuffer(KWaylandServer::SurfaceInterface *surface,
|
||||
KWaylandServer::BufferInterface *buffer);
|
||||
KWaylandServer::ClientBuffer *buffer);
|
||||
|
||||
EglStreamBackend *m_backend;
|
||||
GLuint m_fbo, m_rbo, m_textureId;
|
||||
|
|
|
@ -31,7 +31,6 @@
|
|||
|
||||
// KDE
|
||||
#include <KWayland/Client/surface.h>
|
||||
#include <KWaylandServer/buffer_interface.h>
|
||||
#include <KWaylandServer/display.h>
|
||||
|
||||
// Qt
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
// KDecoration
|
||||
#include <KDecoration2/Decoration>
|
||||
// KWayland
|
||||
#include <KWaylandServer/buffer_interface.h>
|
||||
#include <KWaylandServer/shmclientbuffer.h>
|
||||
#include <KWaylandServer/datadevice_interface.h>
|
||||
#include <KWaylandServer/display.h>
|
||||
#include <KWaylandServer/pointer_interface.h>
|
||||
|
@ -1115,7 +1115,7 @@ void CursorImage::updateServerCursor()
|
|||
}
|
||||
return;
|
||||
}
|
||||
auto buffer = cursorSurface->buffer();
|
||||
auto buffer = qobject_cast<KWaylandServer::ShmClientBuffer *>(cursorSurface->buffer());
|
||||
if (!buffer) {
|
||||
if (needsEmit) {
|
||||
Q_EMIT changed();
|
||||
|
@ -1184,7 +1184,7 @@ void CursorImage::updateDragCursor()
|
|||
QImage additionalIcon;
|
||||
if (auto ddi = waylandServer()->seat()->dragSource()) {
|
||||
if (const KWaylandServer::DragAndDropIcon *dragIcon = ddi->icon()) {
|
||||
if (KWaylandServer::BufferInterface *buffer = dragIcon->surface()->buffer()) {
|
||||
if (auto buffer = qobject_cast<KWaylandServer::ShmClientBuffer *>(dragIcon->surface()->buffer())) {
|
||||
additionalIcon = buffer->data().copy();
|
||||
additionalIcon.setDevicePixelRatio(dragIcon->surface()->bufferScale());
|
||||
additionalIcon.setOffset(dragIcon->position());
|
||||
|
@ -1212,7 +1212,7 @@ void CursorImage::updateDragCursor()
|
|||
}
|
||||
return;
|
||||
}
|
||||
auto buffer = cursorSurface->buffer();
|
||||
auto buffer = qobject_cast<KWaylandServer::ShmClientBuffer *>(cursorSurface->buffer());
|
||||
if (!buffer) {
|
||||
if (needsEmit) {
|
||||
Q_EMIT changed();
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#include <KDecoration2/Decoration>
|
||||
#include <KDecoration2/DecorationShadow>
|
||||
|
||||
#include <KWaylandServer/buffer_interface.h>
|
||||
#include <KWaylandServer/shmclientbuffer.h>
|
||||
#include <KWaylandServer/shadow_interface.h>
|
||||
#include <KWaylandServer/surface_interface.h>
|
||||
|
||||
|
@ -214,20 +214,29 @@ bool Shadow::init(KDecoration2::Decoration *decoration)
|
|||
return true;
|
||||
}
|
||||
|
||||
static QPixmap shadowTileForBuffer(KWaylandServer::ClientBuffer *buffer)
|
||||
{
|
||||
auto shmBuffer = qobject_cast<KWaylandServer::ShmClientBuffer *>(buffer);
|
||||
if (shmBuffer) {
|
||||
return QPixmap::fromImage(shmBuffer->data().copy());
|
||||
}
|
||||
return QPixmap();
|
||||
}
|
||||
|
||||
bool Shadow::init(const QPointer< KWaylandServer::ShadowInterface > &shadow)
|
||||
{
|
||||
if (!shadow) {
|
||||
return false;
|
||||
}
|
||||
|
||||
m_shadowElements[ShadowElementTop] = shadow->top() ? QPixmap::fromImage(shadow->top()->data().copy()) : QPixmap();
|
||||
m_shadowElements[ShadowElementTopRight] = shadow->topRight() ? QPixmap::fromImage(shadow->topRight()->data().copy()) : QPixmap();
|
||||
m_shadowElements[ShadowElementRight] = shadow->right() ? QPixmap::fromImage(shadow->right()->data().copy()) : QPixmap();
|
||||
m_shadowElements[ShadowElementBottomRight] = shadow->bottomRight() ? QPixmap::fromImage(shadow->bottomRight()->data().copy()) : QPixmap();
|
||||
m_shadowElements[ShadowElementBottom] = shadow->bottom() ? QPixmap::fromImage(shadow->bottom()->data().copy()) : QPixmap();
|
||||
m_shadowElements[ShadowElementBottomLeft] = shadow->bottomLeft() ? QPixmap::fromImage(shadow->bottomLeft()->data().copy()) : QPixmap();
|
||||
m_shadowElements[ShadowElementLeft] = shadow->left() ? QPixmap::fromImage(shadow->left()->data().copy()) : QPixmap();
|
||||
m_shadowElements[ShadowElementTopLeft] = shadow->topLeft() ? QPixmap::fromImage(shadow->topLeft()->data().copy()) : QPixmap();
|
||||
m_shadowElements[ShadowElementTop] = shadowTileForBuffer(shadow->top());
|
||||
m_shadowElements[ShadowElementTopRight] = shadowTileForBuffer(shadow->topRight());
|
||||
m_shadowElements[ShadowElementRight] = shadowTileForBuffer(shadow->right());
|
||||
m_shadowElements[ShadowElementBottomRight] = shadowTileForBuffer(shadow->bottomRight());
|
||||
m_shadowElements[ShadowElementBottom] = shadowTileForBuffer(shadow->bottom());
|
||||
m_shadowElements[ShadowElementBottomLeft] = shadowTileForBuffer(shadow->bottomLeft());
|
||||
m_shadowElements[ShadowElementLeft] = shadowTileForBuffer(shadow->left());
|
||||
m_shadowElements[ShadowElementTopLeft] = shadowTileForBuffer(shadow->topLeft());
|
||||
|
||||
m_offset = shadow->offset().toMargins();
|
||||
Q_EMIT offsetChanged();
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#include "composite.h"
|
||||
#include "scene.h"
|
||||
|
||||
#include <KWaylandServer/buffer_interface.h>
|
||||
#include <KWaylandServer/clientbuffer.h>
|
||||
#include <KWaylandServer/subcompositor_interface.h>
|
||||
#include <KWaylandServer/surface_interface.h>
|
||||
|
||||
|
@ -111,7 +111,7 @@ void SurfaceItemWayland::handleChildSubSurfacesChanged()
|
|||
SurfaceItemWayland *subsurfaceItem = getOrCreateSubSurfaceItem(below[i]);
|
||||
subsurfaceItem->setZ(i - below.count());
|
||||
}
|
||||
|
||||
|
||||
for (int i = 0; i < above.count(); ++i) {
|
||||
SurfaceItemWayland *subsurfaceItem = getOrCreateSubSurfaceItem(above[i]);
|
||||
subsurfaceItem->setZ(i);
|
||||
|
@ -149,7 +149,7 @@ KWaylandServer::SurfaceInterface *SurfacePixmapWayland::surface() const
|
|||
return m_item->surface();
|
||||
}
|
||||
|
||||
KWaylandServer::BufferInterface *SurfacePixmapWayland::buffer() const
|
||||
KWaylandServer::ClientBuffer *SurfacePixmapWayland::buffer() const
|
||||
{
|
||||
return m_buffer;
|
||||
}
|
||||
|
@ -169,31 +169,20 @@ void SurfacePixmapWayland::update()
|
|||
|
||||
bool SurfacePixmapWayland::isValid() const
|
||||
{
|
||||
// Referenced buffers get destroyed under our nose, check also the platform texture
|
||||
// to work around BufferInterface's weird api.
|
||||
return m_buffer || platformTexture()->isValid();
|
||||
return m_buffer;
|
||||
}
|
||||
|
||||
void SurfacePixmapWayland::clearBuffer()
|
||||
{
|
||||
setBuffer(nullptr);
|
||||
}
|
||||
|
||||
void SurfacePixmapWayland::setBuffer(KWaylandServer::BufferInterface *buffer)
|
||||
void SurfacePixmapWayland::setBuffer(KWaylandServer::ClientBuffer *buffer)
|
||||
{
|
||||
if (m_buffer == buffer) {
|
||||
return;
|
||||
}
|
||||
if (m_buffer) {
|
||||
disconnect(m_buffer, &KWaylandServer::BufferInterface::aboutToBeDestroyed,
|
||||
this, &SurfacePixmapWayland::clearBuffer);
|
||||
m_buffer->unref();
|
||||
}
|
||||
m_buffer = buffer;
|
||||
if (m_buffer) {
|
||||
m_buffer->ref();
|
||||
connect(m_buffer, &KWaylandServer::BufferInterface::aboutToBeDestroyed,
|
||||
this, &SurfacePixmapWayland::clearBuffer);
|
||||
m_hasAlphaChannel = m_buffer->hasAlphaChannel();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
namespace KWaylandServer
|
||||
{
|
||||
class BufferInterface;
|
||||
class ClientBuffer;
|
||||
class SubSurfaceInterface;
|
||||
class SurfaceInterface;
|
||||
}
|
||||
|
@ -63,18 +63,17 @@ public:
|
|||
|
||||
SurfaceItemWayland *item() const;
|
||||
KWaylandServer::SurfaceInterface *surface() const;
|
||||
KWaylandServer::BufferInterface *buffer() const;
|
||||
KWaylandServer::ClientBuffer *buffer() const;
|
||||
|
||||
void create() override;
|
||||
void update() override;
|
||||
bool isValid() const override;
|
||||
|
||||
private:
|
||||
void clearBuffer();
|
||||
void setBuffer(KWaylandServer::BufferInterface *buffer);
|
||||
void setBuffer(KWaylandServer::ClientBuffer *buffer);
|
||||
|
||||
SurfaceItemWayland *m_item;
|
||||
KWaylandServer::BufferInterface *m_buffer = nullptr;
|
||||
KWaylandServer::ClientBuffer *m_buffer = nullptr;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
#include <KWaylandServer/dpms_interface.h>
|
||||
#include <KWaylandServer/idle_interface.h>
|
||||
#include <KWaylandServer/idleinhibit_v1_interface.h>
|
||||
#include <KWaylandServer/linuxdmabuf_v1_interface.h>
|
||||
#include <KWaylandServer/linuxdmabufv1clientbuffer.h>
|
||||
#include <KWaylandServer/output_interface.h>
|
||||
#include <KWaylandServer/plasmashell_interface.h>
|
||||
#include <KWaylandServer/plasmavirtualdesktop_interface.h>
|
||||
|
@ -537,11 +537,10 @@ bool WaylandServer::init(InitializationFlags flags)
|
|||
return true;
|
||||
}
|
||||
|
||||
KWaylandServer::LinuxDmabufUnstableV1Interface *WaylandServer::linuxDmabuf()
|
||||
KWaylandServer::LinuxDmaBufV1ClientBufferIntegration *WaylandServer::linuxDmabuf()
|
||||
{
|
||||
if (!m_linuxDmabuf) {
|
||||
m_linuxDmabuf = new LinuxDmabufUnstableV1Interface(m_display, m_display);
|
||||
m_linuxDmabuf->create();
|
||||
m_linuxDmabuf = new LinuxDmaBufV1ClientBufferIntegration(m_display);
|
||||
}
|
||||
return m_linuxDmabuf;
|
||||
}
|
||||
|
|
|
@ -54,8 +54,8 @@ class OutputConfigurationInterface;
|
|||
class XdgForeignV2Interface;
|
||||
class XdgOutputManagerV1Interface;
|
||||
class KeyStateInterface;
|
||||
class LinuxDmabufUnstableV1Interface;
|
||||
class LinuxDmabufUnstableV1Buffer;
|
||||
class LinuxDmaBufV1ClientBufferIntegration;
|
||||
class LinuxDmaBufV1ClientBuffer;
|
||||
class TabletManagerV2Interface;
|
||||
class KeyboardShortcutsInhibitManagerV1Interface;
|
||||
class XdgDecorationManagerV1Interface;
|
||||
|
@ -137,7 +137,7 @@ public:
|
|||
|
||||
bool isKeyboardShortcutsInhibited() const;
|
||||
|
||||
KWaylandServer::LinuxDmabufUnstableV1Interface *linuxDmabuf();
|
||||
KWaylandServer::LinuxDmaBufV1ClientBufferIntegration *linuxDmabuf();
|
||||
|
||||
KWaylandServer::InputMethodV1Interface *inputMethod() const {
|
||||
return m_inputMethod;
|
||||
|
@ -235,13 +235,13 @@ public:
|
|||
void simulateUserActivity();
|
||||
void updateKeyState(KWin::Xkb::LEDs leds);
|
||||
|
||||
QSet<KWaylandServer::LinuxDmabufUnstableV1Buffer*> linuxDmabufBuffers() const {
|
||||
QSet<KWaylandServer::LinuxDmaBufV1ClientBuffer*> linuxDmabufBuffers() const {
|
||||
return m_linuxDmabufBuffers;
|
||||
}
|
||||
void addLinuxDmabufBuffer(KWaylandServer::LinuxDmabufUnstableV1Buffer *buffer) {
|
||||
void addLinuxDmabufBuffer(KWaylandServer::LinuxDmaBufV1ClientBuffer *buffer) {
|
||||
m_linuxDmabufBuffers << buffer;
|
||||
}
|
||||
void removeLinuxDmabufBuffer(KWaylandServer::LinuxDmabufUnstableV1Buffer *buffer) {
|
||||
void removeLinuxDmabufBuffer(KWaylandServer::LinuxDmaBufV1ClientBuffer *buffer) {
|
||||
m_linuxDmabufBuffers.remove(buffer);
|
||||
}
|
||||
|
||||
|
@ -288,9 +288,9 @@ private:
|
|||
KWaylandServer::IdleInterface *m_idle = nullptr;
|
||||
KWaylandServer::XdgOutputManagerV1Interface *m_xdgOutputManagerV1 = nullptr;
|
||||
KWaylandServer::XdgDecorationManagerV1Interface *m_xdgDecorationManagerV1 = nullptr;
|
||||
KWaylandServer::LinuxDmabufUnstableV1Interface *m_linuxDmabuf = nullptr;
|
||||
KWaylandServer::LinuxDmaBufV1ClientBufferIntegration *m_linuxDmabuf = nullptr;
|
||||
KWaylandServer::KeyboardShortcutsInhibitManagerV1Interface *m_keyboardShortcutsInhibitManager = nullptr;
|
||||
QSet<KWaylandServer::LinuxDmabufUnstableV1Buffer*> m_linuxDmabufBuffers;
|
||||
QSet<KWaylandServer::LinuxDmaBufV1ClientBuffer*> m_linuxDmabufBuffers;
|
||||
QPointer<KWaylandServer::ClientConnection> m_xwaylandConnection;
|
||||
KWaylandServer::InputMethodV1Interface *m_inputMethod = nullptr;
|
||||
KWaylandServer::ClientConnection *m_inputMethodServerConnection = nullptr;
|
||||
|
|
|
@ -12,9 +12,9 @@
|
|||
#include "workspace.h"
|
||||
|
||||
#include <KWaylandServer/display.h>
|
||||
#include <KWaylandServer/clientbuffer.h>
|
||||
#include <KWaylandServer/clientconnection.h>
|
||||
#include <KWaylandServer/surface_interface.h>
|
||||
#include <KWaylandServer/buffer_interface.h>
|
||||
|
||||
#include <QFileInfo>
|
||||
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
#include <KDecoration2/DecoratedClient>
|
||||
#include <KDecoration2/Decoration>
|
||||
#include <KWaylandServer/appmenu_interface.h>
|
||||
#include <KWaylandServer/buffer_interface.h>
|
||||
#include <KWaylandServer/output_interface.h>
|
||||
#include <KWaylandServer/plasmashell_interface.h>
|
||||
#include <KWaylandServer/seat_interface.h>
|
||||
|
|
Loading…
Reference in a new issue