wayland: Drop ClientBuffer

The ClientBuffer type is empty now, most of the things have been
upstreamed to the GraphicsBuffer type. So let's drop it to simplify the
type hierarchy.
master
Vlad Zahorodnii 1 year ago
parent 82c6538ee4
commit 0d2e361eca

@ -15,7 +15,6 @@
#include "drm_gpu.h"
#include "drm_logging.h"
#include "kwineglutils_p.h"
#include "wayland/clientbuffer.h"
#include "wayland/linuxdmabufv1clientbuffer.h"
#include <cerrno>
@ -117,7 +116,7 @@ void *GbmBuffer::mappedData() const
return m_data;
}
KWaylandServer::ClientBuffer *GbmBuffer::clientBuffer() const
GraphicsBuffer *GbmBuffer::clientBuffer() const
{
return m_clientBuffer;
}

@ -19,7 +19,6 @@ struct gbm_bo;
namespace KWaylandServer
{
class ClientBuffer;
class LinuxDmaBufV1ClientBuffer;
}
@ -27,6 +26,7 @@ namespace KWin
{
class GbmSurface;
class GraphicsBuffer;
class GLTexture;
class GbmSwapchain;
@ -40,7 +40,7 @@ public:
gbm_bo *bo() const;
void *mappedData() const;
KWaylandServer::ClientBuffer *clientBuffer() const;
GraphicsBuffer *clientBuffer() const;
uint32_t flags() const;
bool map(uint32_t flags);
@ -53,7 +53,7 @@ private:
gbm_bo *const m_bo;
const std::weak_ptr<GbmSwapchain> m_swapchain;
KWaylandServer::ClientBuffer *const m_clientBuffer = nullptr;
GraphicsBuffer *const m_clientBuffer = nullptr;
const uint32_t m_flags;
void *m_data = nullptr;
void *m_mapping = nullptr;

@ -6,8 +6,8 @@
#include "scene/surfaceitem_wayland.h"
#include "composite.h"
#include "core/graphicsbuffer.h"
#include "core/renderbackend.h"
#include "wayland/clientbuffer.h"
#include "wayland/subcompositor_interface.h"
#include "wayland/surface_interface.h"
#include "window.h"
@ -164,7 +164,7 @@ KWaylandServer::SurfaceInterface *SurfacePixmapWayland::surface() const
return m_item->surface();
}
KWaylandServer::ClientBuffer *SurfacePixmapWayland::buffer() const
GraphicsBuffer *SurfacePixmapWayland::buffer() const
{
return m_buffer;
}
@ -187,7 +187,7 @@ bool SurfacePixmapWayland::isValid() const
return m_buffer;
}
void SurfacePixmapWayland::setBuffer(KWaylandServer::ClientBuffer *buffer)
void SurfacePixmapWayland::setBuffer(GraphicsBuffer *buffer)
{
if (m_buffer == buffer) {
return;

@ -10,7 +10,6 @@
namespace KWaylandServer
{
class ClientBuffer;
class SubSurfaceInterface;
class SurfaceInterface;
}
@ -18,6 +17,7 @@ class SurfaceInterface;
namespace KWin
{
class GraphicsBuffer;
class X11Window;
/**
@ -66,17 +66,17 @@ public:
SurfaceItemWayland *item() const;
KWaylandServer::SurfaceInterface *surface() const;
KWaylandServer::ClientBuffer *buffer() const;
GraphicsBuffer *buffer() const;
void create() override;
void update() override;
bool isValid() const override;
private:
void setBuffer(KWaylandServer::ClientBuffer *buffer);
void setBuffer(GraphicsBuffer *buffer);
SurfaceItemWayland *m_item;
KWaylandServer::ClientBuffer *m_buffer = nullptr;
GraphicsBuffer *m_buffer = nullptr;
};
/**

@ -199,7 +199,7 @@ bool Shadow::init(KDecoration2::Decoration *decoration)
return true;
}
static QImage shadowTileForBuffer(KWaylandServer::ClientBuffer *buffer)
static QImage shadowTileForBuffer(GraphicsBuffer *buffer)
{
auto shmBuffer = qobject_cast<KWaylandServer::ShmClientBuffer *>(buffer);
if (shmBuffer) {

@ -214,7 +214,6 @@ target_sources(kwin PRIVATE
abstract_drop_handler.cpp
appmenu_interface.cpp
blur_interface.cpp
clientbuffer.cpp
clientconnection.cpp
compositor_interface.cpp
contenttype_v1_interface.cpp

@ -166,7 +166,7 @@ void ShadowTest::testCreateShadow()
QVERIFY(!serverSurface->shadow());
}
static QImage bufferToImage(ClientBuffer *clientBuffer)
static QImage bufferToImage(KWin::GraphicsBuffer *clientBuffer)
{
auto shmBuffer = qobject_cast<ShmClientBuffer *>(clientBuffer);
if (shmBuffer) {

@ -8,7 +8,6 @@
#include <QPainter>
#include <QtTest>
// KWin
#include "wayland/clientbuffer.h"
#include "wayland/compositor_interface.h"
#include "wayland/display.h"
#include "wayland/idleinhibit_v1_interface.h"
@ -395,7 +394,7 @@ void TestWaylandSurface::testAttachBuffer()
QVERIFY(unmappedSpy.isEmpty());
// now the ServerSurface should have the black image attached as a buffer
KWaylandServer::ClientBuffer *buffer = serverSurface->buffer();
KWin::GraphicsBuffer *buffer = serverSurface->buffer();
buffer->ref();
auto shmBuffer = qobject_cast<KWaylandServer::ShmClientBuffer *>(buffer);
QVERIFY(shmBuffer);
@ -411,7 +410,7 @@ void TestWaylandSurface::testAttachBuffer()
QVERIFY(damageSpy.wait());
QCOMPARE(mappedSpy.count(), 1);
QVERIFY(unmappedSpy.isEmpty());
KWaylandServer::ClientBuffer *buffer2 = serverSurface->buffer();
KWin::GraphicsBuffer *buffer2 = serverSurface->buffer();
buffer2->ref();
auto shmBuffer2 = qobject_cast<KWaylandServer::ShmClientBuffer *>(buffer2);
QVERIFY(shmBuffer2);
@ -446,7 +445,7 @@ void TestWaylandSurface::testAttachBuffer()
}
QVERIFY(redBuffer.data()->isReleased());
KWaylandServer::ClientBuffer *buffer3 = serverSurface->buffer();
KWin::GraphicsBuffer *buffer3 = serverSurface->buffer();
buffer3->ref();
auto shmBuffer3 = qobject_cast<KWaylandServer::ShmClientBuffer *>(buffer3);
QVERIFY(shmBuffer3);
@ -542,7 +541,7 @@ void TestWaylandSurface::testMultipleSurfaces()
QVERIFY(damageSpy1.wait());
// now the ServerSurface should have the black image attached as a buffer
ClientBuffer *buffer1 = serverSurface1->buffer();
KWin::GraphicsBuffer *buffer1 = serverSurface1->buffer();
QVERIFY(buffer1);
QImage buffer1Data = qobject_cast<ShmClientBuffer *>(buffer1)->data();
QCOMPARE(buffer1Data, black);
@ -561,7 +560,7 @@ void TestWaylandSurface::testMultipleSurfaces()
QSignalSpy damageSpy2(serverSurface2, &KWaylandServer::SurfaceInterface::damaged);
QVERIFY(damageSpy2.wait());
ClientBuffer *buffer2 = serverSurface2->buffer();
KWin::GraphicsBuffer *buffer2 = serverSurface2->buffer();
QVERIFY(buffer2);
QImage buffer2Data = qobject_cast<ShmClientBuffer *>(buffer2)->data();
QCOMPARE(buffer2Data, red);

@ -1,25 +0,0 @@
/*
SPDX-FileCopyrightText: 2021 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#include "wayland/clientbuffer.h"
#include "wayland/linuxdmabufv1clientbuffer.h"
#include "wayland/shmclientbuffer.h"
namespace KWaylandServer
{
ClientBuffer *ClientBuffer::get(wl_resource *resource)
{
if (auto buffer = LinuxDmaBufV1ClientBuffer::get(resource)) {
return buffer;
}
if (auto buffer = ShmClientBuffer::get(resource)) {
return buffer;
}
return nullptr;
}
} // namespace KWaylandServer

@ -1,32 +0,0 @@
/*
SPDX-FileCopyrightText: 2021 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#pragma once
#include "core/graphicsbuffer.h"
struct wl_resource;
namespace KWaylandServer
{
/**
* The ClientBuffer class represents a client buffer.
*
* While the ClientBuffer is referenced, it won't be destroyed. Note that the client can
* still destroy the wl_buffer object while the ClientBuffer is referenced by the compositor.
* You can use the isDestroyed() function to check whether the wl_buffer object has been
* destroyed.
*/
class KWIN_EXPORT ClientBuffer : public KWin::GraphicsBuffer
{
Q_OBJECT
public:
static ClientBuffer *get(wl_resource *resource);
};
} // namespace KWaylandServer

@ -6,6 +6,7 @@
*/
#include "display.h"
#include "display_p.h"
#include "linuxdmabufv1clientbuffer.h"
#include "output_interface.h"
#include "shmclientbuffer.h"
#include "utils/common.h"
@ -215,4 +216,15 @@ ClientConnection *Display::createClient(int fd)
return getConnection(c);
}
KWin::GraphicsBuffer *Display::bufferForResource(wl_resource *resource)
{
if (auto buffer = LinuxDmaBufV1ClientBuffer::get(resource)) {
return buffer;
} else if (auto buffer = ShmClientBuffer::get(resource)) {
return buffer;
} else {
return nullptr;
}
}
} // namespace KWaylandServer

@ -16,6 +16,11 @@
struct wl_client;
struct wl_display;
namespace KWin
{
class GraphicsBuffer;
}
namespace KWaylandServer
{
/**
@ -32,7 +37,6 @@ namespace KWaylandServer
* @see Display
*/
class ClientBuffer;
class ClientConnection;
class DisplayPrivate;
class OutputInterface;
@ -125,6 +129,11 @@ public:
ClientConnection *getConnection(wl_client *client);
QVector<ClientConnection *> connections() const;
/**
* Returns the graphics buffer for the given @a resource, or @c null if there's no buffer.
*/
static KWin::GraphicsBuffer *bufferForResource(wl_resource *resource);
private Q_SLOTS:
void flush();

@ -21,7 +21,7 @@ class DrmClientBufferIntegrationPrivate;
* protocol.
*
* It provides the minimum amount of information to Xwayland so it can run. No
* ClientBuffers are provided by the DrmClientBufferIntegration. Xwayland is
* GraphicsBuffers are provided by the DrmClientBufferIntegration. Xwayland is
* expected to provide us linux dmabuf client buffers instead.
*
* Once the wl_drm protocol is no longer mandatory in Xwayland, this stub can be

@ -8,7 +8,7 @@
*/
#pragma once
#include "clientbuffer.h"
#include "core/graphicsbuffer.h"
#include <QHash>
#include <QSet>
@ -34,7 +34,7 @@ class LinuxDmaBufV1FeedbackPrivate;
* The LinuxDmaBufV1ClientBuffer can be used even after the underlying wl_buffer object
* is destroyed by the client.
*/
class KWIN_EXPORT LinuxDmaBufV1ClientBuffer : public ClientBuffer
class KWIN_EXPORT LinuxDmaBufV1ClientBuffer : public KWin::GraphicsBuffer
{
Q_OBJECT

@ -4,7 +4,7 @@
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#include "shadow_interface.h"
#include "clientbuffer.h"
#include "core/graphicsbuffer.h"
#include "display.h"
#include "surface_interface_p.h"
@ -97,14 +97,14 @@ public:
BottomLeftBuffer = 1 << 7,
Offset = 1 << 8,
};
QPointer<ClientBuffer> left;
QPointer<ClientBuffer> topLeft;
QPointer<ClientBuffer> top;
QPointer<ClientBuffer> topRight;
QPointer<ClientBuffer> right;
QPointer<ClientBuffer> bottomRight;
QPointer<ClientBuffer> bottom;
QPointer<ClientBuffer> bottomLeft;
QPointer<KWin::GraphicsBuffer> left;
QPointer<KWin::GraphicsBuffer> topLeft;
QPointer<KWin::GraphicsBuffer> top;
QPointer<KWin::GraphicsBuffer> topRight;
QPointer<KWin::GraphicsBuffer> right;
QPointer<KWin::GraphicsBuffer> bottomRight;
QPointer<KWin::GraphicsBuffer> bottom;
QPointer<KWin::GraphicsBuffer> bottomLeft;
QMarginsF offset;
Flags flags = Flags::None;
};
@ -165,7 +165,7 @@ void ShadowInterfacePrivate::org_kde_kwin_shadow_commit(Resource *resource)
void ShadowInterfacePrivate::attach(ShadowInterfacePrivate::State::Flags flag, wl_resource *buffer)
{
ClientBuffer *b = ClientBuffer::get(buffer);
KWin::GraphicsBuffer *b = Display::bufferForResource(buffer);
switch (flag) {
case State::LeftBuffer:
pending.left = b;
@ -309,10 +309,10 @@ QMarginsF ShadowInterface::offset() const
return d->current.offset;
}
#define BUFFER(__PART__) \
ClientBuffer *ShadowInterface::__PART__() const \
{ \
return d->current.__PART__; \
#define BUFFER(__PART__) \
KWin::GraphicsBuffer *ShadowInterface::__PART__() const \
{ \
return d->current.__PART__; \
}
BUFFER(left)

@ -13,9 +13,13 @@
struct wl_resource;
namespace KWin
{
class GraphicsBuffer;
}
namespace KWaylandServer
{
class ClientBuffer;
class Display;
class ShadowManagerInterfacePrivate;
class ShadowInterfacePrivate;
@ -38,14 +42,14 @@ class KWIN_EXPORT ShadowInterface : public QObject
public:
~ShadowInterface() override;
ClientBuffer *left() const;
ClientBuffer *topLeft() const;
ClientBuffer *top() const;
ClientBuffer *topRight() const;
ClientBuffer *right() const;
ClientBuffer *bottomRight() const;
ClientBuffer *bottom() const;
ClientBuffer *bottomLeft() const;
KWin::GraphicsBuffer *left() const;
KWin::GraphicsBuffer *topLeft() const;
KWin::GraphicsBuffer *top() const;
KWin::GraphicsBuffer *topRight() const;
KWin::GraphicsBuffer *right() const;
KWin::GraphicsBuffer *bottomRight() const;
KWin::GraphicsBuffer *bottom() const;
KWin::GraphicsBuffer *bottomLeft() const;
QMarginsF offset() const;

@ -6,7 +6,9 @@
#pragma once
#include "clientbuffer.h"
#include "core/graphicsbuffer.h"
struct wl_resource;
namespace KWaylandServer
{
@ -20,7 +22,7 @@ class ShmClientBufferPrivate;
* The buffer's data can be accessed using the data() function. Note that it is not allowed
* to access data of several shared memory buffers simultaneously.
*/
class KWIN_EXPORT ShmClientBuffer : public ClientBuffer
class KWIN_EXPORT ShmClientBuffer : public KWin::GraphicsBuffer
{
Q_OBJECT

@ -5,7 +5,6 @@
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#include "surface_interface.h"
#include "clientbuffer.h"
#include "clientconnection.h"
#include "compositor_interface.h"
#include "contenttype_v1_interface.h"
@ -270,7 +269,7 @@ void SurfaceInterfacePrivate::surface_attach(Resource *resource, struct ::wl_res
pending.bufferDamage = QRegion();
return;
}
pending.buffer = ClientBuffer::get(buffer);
pending.buffer = Display::bufferForResource(buffer);
}
void SurfaceInterfacePrivate::surface_damage(Resource *, int32_t x, int32_t y, int32_t width, int32_t height)
@ -808,7 +807,7 @@ KWin::Output::Transform SurfaceInterface::bufferTransform() const
return d->current.bufferTransform;
}
ClientBuffer *SurfaceInterface::buffer() const
KWin::GraphicsBuffer *SurfaceInterface::buffer() const
{
return d->bufferRef;
}

@ -14,10 +14,14 @@
#include <QPointer>
#include <QRegion>
namespace KWin
{
class GraphicsBuffer;
}
namespace KWaylandServer
{
class BlurInterface;
class ClientBuffer;
class ConfinedPointerV1Interface;
class ContrastInterface;
class CompositorInterface;
@ -45,13 +49,13 @@ enum class PresentationHint {
* This should make interacting from the server easier, it only needs to monitor the SurfaceInterface
* and does not need to track each specific interface.
*
* The SurfaceInterface takes care of reference/unreferencing the ClientBuffer attached to it.
* As long as a ClientBuffer is attached, the released signal won't be sent. If the ClientBuffer
* The SurfaceInterface takes care of reference/unreferencing the GraphicsBuffer attached to it.
* As long as a GraphicsBuffer is attached, the released signal won't be sent. If the GraphicsBuffer
* is no longer needed by the SurfaceInterface, it will get unreferenced and might be automatically
* deleted (if it's no longer referenced).
*
* @see CompositorInterface
* @see ClientBuffer
* @see GraphicsBuffer
* @see SubSurfaceInterface
* @see BlurInterface
* @see ContrastInterface
@ -177,9 +181,9 @@ public:
*/
KWin::Output::Transform bufferTransform() const;
/**
* @returns the current ClientBuffer, might be @c nullptr.
* @returns the current GraphicsBuffer, might be @c nullptr.
*/
ClientBuffer *buffer() const;
KWin::GraphicsBuffer *buffer() const;
QPoint offset() const;
/**
* Returns the current size of the surface, in surface coordinates.
@ -238,9 +242,9 @@ public:
/**
* Whether the SurfaceInterface is currently considered to be mapped.
* A SurfaceInterface is mapped if it has a non-null ClientBuffer attached.
* A SurfaceInterface is mapped if it has a non-null GraphicsBuffer attached.
* If the SurfaceInterface references a SubSurfaceInterface it is only considered
* mapped if it has a ClientBuffer attached and the parent SurfaceInterface is mapped.
* mapped if it has a GraphicsBuffer attached and the parent SurfaceInterface is mapped.
*
* @returns Whether the SurfaceInterface is currently mapped
*/
@ -374,7 +378,7 @@ Q_SIGNALS:
/**
* Emitted whenever the SurfaceInterface got damaged.
* The signal is only emitted during the commit of state.
* A damage means that a new ClientBuffer got attached.
* A damage means that a new GraphicsBuffer got attached.
*
* @see buffer
* @see damage

@ -47,7 +47,7 @@ struct SurfaceState
KWin::Output::Transform bufferTransform = KWin::Output::Transform::Normal;
wl_list frameCallbacks;
QPoint offset = QPoint();
QPointer<ClientBuffer> buffer;
QPointer<KWin::GraphicsBuffer> buffer;
QPointer<ShadowInterface> shadow;
QPointer<BlurInterface> blur;
QPointer<ContrastInterface> contrast;
@ -125,7 +125,7 @@ public:
QRegion inputRegion;
QRegion opaqueRegion;
ClientBuffer *bufferRef = nullptr;
KWin::GraphicsBuffer *bufferRef = nullptr;
bool mapped = false;
bool hasCacheState = false;
qreal scaleOverride = 1.;

@ -8,7 +8,6 @@
#include "waylandwindow.h"
#include "scene/windowitem.h"
#include "wayland/clientbuffer.h"
#include "wayland/clientconnection.h"
#include "wayland/display.h"
#include "wayland/surface_interface.h"

Loading…
Cancel
Save