backends: Remove concrete graphics buffer types

This commit is contained in:
Vlad Zahorodnii 2023-06-05 14:54:55 +03:00
parent ea639ad170
commit 0a7bfcf1a3
16 changed files with 46 additions and 52 deletions

View file

@ -21,7 +21,7 @@
namespace KWin
{
VirtualEglLayerBuffer::VirtualEglLayerBuffer(GbmGraphicsBuffer *buffer, VirtualEglBackend *backend)
VirtualEglLayerBuffer::VirtualEglLayerBuffer(GraphicsBuffer *buffer, VirtualEglBackend *backend)
: m_graphicsBuffer(buffer)
{
m_texture = backend->importDmaBufAsTexture(*buffer->dmabufAttributes());
@ -35,7 +35,7 @@ VirtualEglLayerBuffer::~VirtualEglLayerBuffer()
m_graphicsBuffer->drop();
}
GbmGraphicsBuffer *VirtualEglLayerBuffer::graphicsBuffer() const
GraphicsBuffer *VirtualEglLayerBuffer::graphicsBuffer() const
{
return m_graphicsBuffer;
}
@ -71,7 +71,7 @@ std::shared_ptr<VirtualEglLayerBuffer> VirtualEglSwapchain::acquire()
}
}
GbmGraphicsBuffer *graphicsBuffer = m_allocator->allocate(GraphicsBufferOptions{
GraphicsBuffer *graphicsBuffer = m_allocator->allocate(GraphicsBufferOptions{
.size = m_size,
.format = m_format,
});

View file

@ -15,8 +15,7 @@
namespace KWin
{
class GbmGraphicsBuffer;
class GbmGraphicsBufferAllocator;
class GraphicsBufferAllocator;
class VirtualBackend;
class GLFramebuffer;
class GLTexture;
@ -25,15 +24,15 @@ class VirtualEglBackend;
class VirtualEglLayerBuffer
{
public:
VirtualEglLayerBuffer(GbmGraphicsBuffer *buffer, VirtualEglBackend *backend);
VirtualEglLayerBuffer(GraphicsBuffer *buffer, VirtualEglBackend *backend);
~VirtualEglLayerBuffer();
GbmGraphicsBuffer *graphicsBuffer() const;
GraphicsBuffer *graphicsBuffer() const;
GLFramebuffer *framebuffer() const;
std::shared_ptr<GLTexture> texture() const;
private:
GbmGraphicsBuffer *m_graphicsBuffer;
GraphicsBuffer *m_graphicsBuffer;
std::unique_ptr<GLFramebuffer> m_framebuffer;
std::shared_ptr<GLTexture> m_texture;
};
@ -51,7 +50,7 @@ private:
VirtualEglBackend *m_backend;
QSize m_size;
uint32_t m_format;
std::unique_ptr<GbmGraphicsBufferAllocator> m_allocator;
std::unique_ptr<GraphicsBufferAllocator> m_allocator;
QVector<std::shared_ptr<VirtualEglLayerBuffer>> m_buffers;
};

View file

@ -33,7 +33,7 @@ static QImage::Format drmFormatToQImageFormat(uint32_t drmFormat)
}
}
VirtualQPainterBufferSlot::VirtualQPainterBufferSlot(ShmGraphicsBuffer *graphicsBuffer)
VirtualQPainterBufferSlot::VirtualQPainterBufferSlot(GraphicsBuffer *graphicsBuffer)
: graphicsBuffer(graphicsBuffer)
{
const ShmAttributes *attributes = graphicsBuffer->shmAttributes();
@ -77,7 +77,7 @@ std::shared_ptr<VirtualQPainterBufferSlot> VirtualQPainterSwapchain::acquire()
}
}
ShmGraphicsBuffer *buffer = m_allocator->allocate(GraphicsBufferOptions{
GraphicsBuffer *buffer = m_allocator->allocate(GraphicsBufferOptions{
.size = m_size,
.format = m_format,
.software = true,

View file

@ -19,17 +19,16 @@
namespace KWin
{
class ShmGraphicsBuffer;
class ShmGraphicsBufferAllocator;
class GraphicsBufferAllocator;
class VirtualBackend;
class VirtualQPainterBufferSlot
{
public:
VirtualQPainterBufferSlot(ShmGraphicsBuffer *graphicsBuffer);
VirtualQPainterBufferSlot(GraphicsBuffer *graphicsBuffer);
~VirtualQPainterBufferSlot();
ShmGraphicsBuffer *graphicsBuffer;
GraphicsBuffer *graphicsBuffer;
QImage image;
void *data = nullptr;
int size;
@ -45,7 +44,7 @@ public:
std::shared_ptr<VirtualQPainterBufferSlot> acquire();
private:
std::unique_ptr<ShmGraphicsBufferAllocator> m_allocator;
std::unique_ptr<GraphicsBufferAllocator> m_allocator;
QSize m_size;
uint32_t m_format;
std::vector<std::shared_ptr<VirtualQPainterBufferSlot>> m_slots;

View file

@ -30,7 +30,7 @@ namespace KWin
namespace Wayland
{
WaylandEglLayerBuffer::WaylandEglLayerBuffer(GbmGraphicsBuffer *buffer, WaylandEglBackend *backend)
WaylandEglLayerBuffer::WaylandEglLayerBuffer(GraphicsBuffer *buffer, WaylandEglBackend *backend)
: m_graphicsBuffer(buffer)
{
m_texture = backend->importDmaBufAsTexture(*buffer->dmabufAttributes());
@ -44,7 +44,7 @@ WaylandEglLayerBuffer::~WaylandEglLayerBuffer()
m_graphicsBuffer->drop();
}
GbmGraphicsBuffer *WaylandEglLayerBuffer::graphicsBuffer() const
GraphicsBuffer *WaylandEglLayerBuffer::graphicsBuffer() const
{
return m_graphicsBuffer;
}
@ -90,7 +90,7 @@ std::shared_ptr<WaylandEglLayerBuffer> WaylandEglLayerSwapchain::acquire()
}
}
GbmGraphicsBuffer *graphicsBuffer = m_allocator->allocate(GraphicsBufferOptions{
GraphicsBuffer *graphicsBuffer = m_allocator->allocate(GraphicsBufferOptions{
.size = m_size,
.format = m_format,
.modifiers = m_modifiers,

View file

@ -18,8 +18,7 @@
namespace KWin
{
class GLFramebuffer;
class GbmGraphicsBuffer;
class GbmGraphicsBufferAllocator;
class GraphicsBufferAllocator;
namespace Wayland
{
@ -30,16 +29,16 @@ class WaylandEglBackend;
class WaylandEglLayerBuffer
{
public:
WaylandEglLayerBuffer(GbmGraphicsBuffer *buffer, WaylandEglBackend *backend);
WaylandEglLayerBuffer(GraphicsBuffer *buffer, WaylandEglBackend *backend);
~WaylandEglLayerBuffer();
GbmGraphicsBuffer *graphicsBuffer() const;
GraphicsBuffer *graphicsBuffer() const;
GLFramebuffer *framebuffer() const;
std::shared_ptr<GLTexture> texture() const;
int age() const;
private:
GbmGraphicsBuffer *m_graphicsBuffer;
GraphicsBuffer *m_graphicsBuffer;
std::unique_ptr<GLFramebuffer> m_framebuffer;
std::shared_ptr<GLTexture> m_texture;
int m_age = 0;
@ -62,7 +61,7 @@ private:
QSize m_size;
uint32_t m_format;
QVector<uint64_t> m_modifiers;
std::unique_ptr<GbmGraphicsBufferAllocator> m_allocator;
std::unique_ptr<GraphicsBufferAllocator> m_allocator;
QVector<std::shared_ptr<WaylandEglLayerBuffer>> m_buffers;
};

View file

@ -37,7 +37,7 @@ static QImage::Format drmFormatToQImageFormat(uint32_t drmFormat)
}
}
WaylandQPainterBufferSlot::WaylandQPainterBufferSlot(ShmGraphicsBuffer *graphicsBuffer)
WaylandQPainterBufferSlot::WaylandQPainterBufferSlot(GraphicsBuffer *graphicsBuffer)
: graphicsBuffer(graphicsBuffer)
{
const ShmAttributes *attributes = graphicsBuffer->shmAttributes();
@ -81,7 +81,7 @@ std::shared_ptr<WaylandQPainterBufferSlot> WaylandQPainterSwapchain::acquire()
}
}
ShmGraphicsBuffer *buffer = m_allocator->allocate(GraphicsBufferOptions{
GraphicsBuffer *buffer = m_allocator->allocate(GraphicsBufferOptions{
.size = m_size,
.format = m_format,
.software = true,

View file

@ -19,8 +19,7 @@
namespace KWin
{
class Output;
class ShmGraphicsBuffer;
class ShmGraphicsBufferAllocator;
class GraphicsBufferAllocator;
namespace Wayland
{
@ -32,10 +31,10 @@ class WaylandQPainterBackend;
class WaylandQPainterBufferSlot
{
public:
WaylandQPainterBufferSlot(ShmGraphicsBuffer *graphicsBuffer);
WaylandQPainterBufferSlot(GraphicsBuffer *graphicsBuffer);
~WaylandQPainterBufferSlot();
ShmGraphicsBuffer *graphicsBuffer;
GraphicsBuffer *graphicsBuffer;
QImage image;
void *data = nullptr;
int size;
@ -53,7 +52,7 @@ public:
void release(std::shared_ptr<WaylandQPainterBufferSlot> buffer);
private:
std::unique_ptr<ShmGraphicsBufferAllocator> m_allocator;
std::unique_ptr<GraphicsBufferAllocator> m_allocator;
QSize m_size;
uint32_t m_format;
std::vector<std::shared_ptr<WaylandQPainterBufferSlot>> m_slots;

View file

@ -19,7 +19,7 @@
namespace KWin
{
X11WindowedEglLayerBuffer::X11WindowedEglLayerBuffer(GbmGraphicsBuffer *graphicsBuffer, X11WindowedEglBackend *backend)
X11WindowedEglLayerBuffer::X11WindowedEglLayerBuffer(GraphicsBuffer *graphicsBuffer, X11WindowedEglBackend *backend)
: m_graphicsBuffer(graphicsBuffer)
{
m_texture = backend->importDmaBufAsTexture(*graphicsBuffer->dmabufAttributes());
@ -79,7 +79,7 @@ std::shared_ptr<X11WindowedEglLayerBuffer> X11WindowedEglLayerSwapchain::acquire
}
}
GbmGraphicsBuffer *graphicsBuffer = m_allocator->allocate(GraphicsBufferOptions{
GraphicsBuffer *graphicsBuffer = m_allocator->allocate(GraphicsBufferOptions{
.size = m_size,
.format = m_format,
.modifiers = m_modifiers,

View file

@ -15,8 +15,7 @@
namespace KWin
{
class GbmGraphicsBuffer;
class GbmGraphicsBufferAllocator;
class GraphicsBufferAllocator;
class X11WindowedBackend;
class X11WindowedOutput;
class X11WindowedEglBackend;
@ -24,7 +23,7 @@ class X11WindowedEglBackend;
class X11WindowedEglLayerBuffer
{
public:
X11WindowedEglLayerBuffer(GbmGraphicsBuffer *graphicsBuffers, X11WindowedEglBackend *backend);
X11WindowedEglLayerBuffer(GraphicsBuffer *graphicsBuffers, X11WindowedEglBackend *backend);
~X11WindowedEglLayerBuffer();
GraphicsBuffer *graphicsBuffer() const;
@ -33,7 +32,7 @@ public:
int age() const;
private:
GbmGraphicsBuffer *m_graphicsBuffer;
GraphicsBuffer *m_graphicsBuffer;
std::unique_ptr<GLFramebuffer> m_framebuffer;
std::shared_ptr<GLTexture> m_texture;
int m_age = 0;
@ -53,7 +52,7 @@ public:
private:
X11WindowedEglBackend *m_backend;
std::unique_ptr<GbmGraphicsBufferAllocator> m_allocator;
std::unique_ptr<GraphicsBufferAllocator> m_allocator;
QSize m_size;
uint32_t m_format;
QVector<uint64_t> m_modifiers;

View file

@ -34,7 +34,7 @@ static QImage::Format drmFormatToQImageFormat(uint32_t drmFormat)
}
}
X11WindowedQPainterLayerBuffer::X11WindowedQPainterLayerBuffer(ShmGraphicsBuffer *buffer)
X11WindowedQPainterLayerBuffer::X11WindowedQPainterLayerBuffer(GraphicsBuffer *buffer)
: m_graphicsBuffer(buffer)
{
const ShmAttributes *attributes = buffer->shmAttributes();
@ -58,7 +58,7 @@ X11WindowedQPainterLayerBuffer::~X11WindowedQPainterLayerBuffer()
m_graphicsBuffer->drop();
}
ShmGraphicsBuffer *X11WindowedQPainterLayerBuffer::graphicsBuffer() const
GraphicsBuffer *X11WindowedQPainterLayerBuffer::graphicsBuffer() const
{
return m_graphicsBuffer;
}
@ -88,7 +88,7 @@ std::shared_ptr<X11WindowedQPainterLayerBuffer> X11WindowedQPainterLayerSwapchai
}
}
ShmGraphicsBuffer *graphicsBuffer = m_allocator->allocate(GraphicsBufferOptions{
GraphicsBuffer *graphicsBuffer = m_allocator->allocate(GraphicsBufferOptions{
.size = m_size,
.format = m_format,
.software = true,

View file

@ -20,22 +20,21 @@
namespace KWin
{
class ShmGraphicsBuffer;
class ShmGraphicsBufferAllocator;
class GraphicsBufferAllocator;
class X11WindowedBackend;
class X11WindowedOutput;
class X11WindowedQPainterLayerBuffer
{
public:
X11WindowedQPainterLayerBuffer(ShmGraphicsBuffer *buffer);
X11WindowedQPainterLayerBuffer(GraphicsBuffer *buffer);
~X11WindowedQPainterLayerBuffer();
ShmGraphicsBuffer *graphicsBuffer() const;
GraphicsBuffer *graphicsBuffer() const;
QImage *view() const;
private:
ShmGraphicsBuffer *m_graphicsBuffer;
GraphicsBuffer *m_graphicsBuffer;
void *m_data = nullptr;
int m_size = 0;
std::unique_ptr<QImage> m_view;
@ -53,7 +52,7 @@ public:
private:
QSize m_size;
uint32_t m_format;
std::unique_ptr<ShmGraphicsBufferAllocator> m_allocator;
std::unique_ptr<GraphicsBufferAllocator> m_allocator;
QVector<std::shared_ptr<X11WindowedQPainterLayerBuffer>> m_buffers;
};

View file

@ -22,7 +22,7 @@ GbmGraphicsBufferAllocator::~GbmGraphicsBufferAllocator()
{
}
GbmGraphicsBuffer *GbmGraphicsBufferAllocator::allocate(const GraphicsBufferOptions &options)
GraphicsBuffer *GbmGraphicsBufferAllocator::allocate(const GraphicsBufferOptions &options)
{
if (options.software) {
gbm_bo *bo = gbm_bo_create(m_gbmDevice,

View file

@ -45,7 +45,7 @@ public:
explicit GbmGraphicsBufferAllocator(gbm_device *device);
~GbmGraphicsBufferAllocator() override;
GbmGraphicsBuffer *allocate(const GraphicsBufferOptions &options) override;
GraphicsBuffer *allocate(const GraphicsBufferOptions &options) override;
private:
gbm_device *m_gbmDevice;

View file

@ -36,7 +36,7 @@ const ShmAttributes *ShmGraphicsBuffer::shmAttributes() const
return &m_attributes;
}
ShmGraphicsBuffer *ShmGraphicsBufferAllocator::allocate(const GraphicsBufferOptions &options)
GraphicsBuffer *ShmGraphicsBufferAllocator::allocate(const GraphicsBufferOptions &options)
{
if (!options.software) {
return nullptr;

View file

@ -32,7 +32,7 @@ private:
class KWIN_EXPORT ShmGraphicsBufferAllocator : public GraphicsBufferAllocator
{
public:
ShmGraphicsBuffer *allocate(const GraphicsBufferOptions &options) override;
GraphicsBuffer *allocate(const GraphicsBufferOptions &options) override;
};
} // namespace KWin