Commit 9d916fa6 authored by Vlad Zahorodnii's avatar Vlad Zahorodnii
Browse files

wayland: Use shared DmaBufAttributes type

parent 7ecdbad4
Pipeline #190321 passed with stage
in 12 minutes
......@@ -58,7 +58,7 @@ void DmabufFeedback::scanoutFailed(KWaylandServer::SurfaceInterface *surface, co
if (const auto &feedback = m_surface->dmabufFeedbackV1()) {
const auto buffer = qobject_cast<KWaylandServer::LinuxDmaBufV1ClientBuffer *>(surface->buffer());
Q_ASSERT(buffer);
const KWaylandServer::LinuxDmaBufAttributes dmabufAttrs = buffer->attributes();
const DmaBufAttributes dmabufAttrs = buffer->attributes();
if (!m_attemptedFormats[dmabufAttrs.format].contains(dmabufAttrs.modifier)) {
m_attemptedFormats[dmabufAttrs.format] << dmabufAttrs.modifier;
QVector<KWaylandServer::LinuxDmaBufV1Feedback::Tranche> scanoutTranches;
......
/*
SPDX-FileCopyrightText: 2022 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#pragma once
#include <cstdint>
namespace KWin
{
struct DmaBufAttributes
{
int planeCount = 0;
int width = 0;
int height = 0;
uint32_t format = 0;
uint64_t modifier = 0;
int fd[4] = {-1, -1, -1, -1};
int offset[4] = {0, 0, 0, 0};
int pitch[4] = {0, 0, 0, 0};
};
} // namespace KWin
......@@ -5,8 +5,11 @@
*/
#pragma once
#include "kwin_export.h"
#include "dmabufattributes.h"
#include <memory>
namespace KWin
......@@ -14,19 +17,6 @@ namespace KWin
class GLFramebuffer;
class GLTexture;
struct DmaBufAttributes
{
int planeCount = 0;
int width = 0;
int height = 0;
uint32_t format = 0;
uint64_t modifier = 0;
int fd[4] = {-1, -1, -1, -1};
int offset[4] = {0, 0, 0, 0};
int pitch[4] = {0, 0, 0, 0};
};
class KWIN_EXPORT DmaBufTexture
{
public:
......
......@@ -13,8 +13,7 @@
namespace KWin
{
LinuxDmaBufV1ClientBuffer::LinuxDmaBufV1ClientBuffer(const KWaylandServer::LinuxDmaBufAttributes &attrs,
quint32 flags)
LinuxDmaBufV1ClientBuffer::LinuxDmaBufV1ClientBuffer(const DmaBufAttributes &attrs, quint32 flags)
: KWaylandServer::LinuxDmaBufV1ClientBuffer(attrs, flags)
{
waylandServer()->addLinuxDmabufBuffer(this);
......@@ -38,8 +37,7 @@ LinuxDmaBufV1RendererInterface::~LinuxDmaBufV1RendererInterface()
waylandServer()->linuxDmabuf()->setRendererInterface(nullptr);
}
KWaylandServer::LinuxDmaBufV1ClientBuffer *LinuxDmaBufV1RendererInterface::importBuffer(const KWaylandServer::LinuxDmaBufAttributes &attrs,
quint32 flags)
KWaylandServer::LinuxDmaBufV1ClientBuffer *LinuxDmaBufV1RendererInterface::importBuffer(const DmaBufAttributes &attrs, quint32 flags)
{
Q_UNUSED(attrs)
Q_UNUSED(flags)
......
......@@ -18,8 +18,7 @@ namespace KWin
class KWIN_EXPORT LinuxDmaBufV1ClientBuffer : public KWaylandServer::LinuxDmaBufV1ClientBuffer
{
public:
LinuxDmaBufV1ClientBuffer(const KWaylandServer::LinuxDmaBufAttributes &attrs,
quint32 flags);
LinuxDmaBufV1ClientBuffer(const DmaBufAttributes &attrs, quint32 flags);
~LinuxDmaBufV1ClientBuffer() override;
};
......@@ -29,8 +28,7 @@ public:
explicit LinuxDmaBufV1RendererInterface();
~LinuxDmaBufV1RendererInterface() override;
KWaylandServer::LinuxDmaBufV1ClientBuffer *importBuffer(const KWaylandServer::LinuxDmaBufAttributes &attrs,
quint32 flags) override;
KWaylandServer::LinuxDmaBufV1ClientBuffer *importBuffer(const DmaBufAttributes &attrs, quint32 flags) override;
protected:
void setSupportedFormatsAndModifiers(const QVector<KWaylandServer::LinuxDmaBufV1Feedback::Tranche> &tranches);
......
......@@ -91,7 +91,7 @@ YuvFormat yuvFormats[] = {
2}}}};
EglDmabufBuffer::EglDmabufBuffer(EGLImage image,
const KWaylandServer::LinuxDmaBufAttributes &attrs,
const DmaBufAttributes &attrs,
quint32 flags,
EglDmabuf *interfaceImpl)
: EglDmabufBuffer(attrs, flags, interfaceImpl)
......@@ -100,7 +100,7 @@ EglDmabufBuffer::EglDmabufBuffer(EGLImage image,
addImage(image);
}
EglDmabufBuffer::EglDmabufBuffer(const KWaylandServer::LinuxDmaBufAttributes &attrs,
EglDmabufBuffer::EglDmabufBuffer(const DmaBufAttributes &attrs,
quint32 flags,
EglDmabuf *interfaceImpl)
: LinuxDmaBufV1ClientBuffer(attrs, flags)
......@@ -132,7 +132,7 @@ void EglDmabufBuffer::removeImages()
m_images.clear();
}
EGLImage EglDmabuf::createImage(const KWaylandServer::LinuxDmaBufAttributes &attrs)
EGLImage EglDmabuf::createImage(const DmaBufAttributes &attrs)
{
const bool hasModifiers = eglQueryDmaBufModifiersEXT != nullptr && attrs.modifier != DRM_FORMAT_MOD_INVALID;
......@@ -206,8 +206,7 @@ EGLImage EglDmabuf::createImage(const KWaylandServer::LinuxDmaBufAttributes &att
return image;
}
KWaylandServer::LinuxDmaBufV1ClientBuffer *EglDmabuf::importBuffer(const KWaylandServer::LinuxDmaBufAttributes &attrs,
quint32 flags)
KWaylandServer::LinuxDmaBufV1ClientBuffer *EglDmabuf::importBuffer(const DmaBufAttributes &attrs, quint32 flags)
{
Q_ASSERT(attrs.planeCount > 0);
......@@ -224,8 +223,7 @@ KWaylandServer::LinuxDmaBufV1ClientBuffer *EglDmabuf::importBuffer(const KWaylan
return nullptr;
}
KWaylandServer::LinuxDmaBufV1ClientBuffer *EglDmabuf::yuvImport(const KWaylandServer::LinuxDmaBufAttributes &attrs,
quint32 flags)
KWaylandServer::LinuxDmaBufV1ClientBuffer *EglDmabuf::yuvImport(const DmaBufAttributes &attrs, quint32 flags)
{
YuvFormat yuvFormat;
for (YuvFormat f : yuvFormats) {
......@@ -245,7 +243,7 @@ KWaylandServer::LinuxDmaBufV1ClientBuffer *EglDmabuf::yuvImport(const KWaylandSe
for (int i = 0; i < yuvFormat.outputPlanes; i++) {
const int planeIndex = yuvFormat.planes[i].planeIndex;
const KWaylandServer::LinuxDmaBufAttributes planeAttrs {
const DmaBufAttributes planeAttrs {
.planeCount = 1,
.width = attrs.width / yuvFormat.planes[i].widthDivisor,
.height = attrs.height / yuvFormat.planes[i].heightDivisor,
......
......@@ -28,11 +28,11 @@ public:
};
EglDmabufBuffer(EGLImage image,
const KWaylandServer::LinuxDmaBufAttributes &attrs,
const DmaBufAttributes &attrs,
quint32 flags,
EglDmabuf *interfaceImpl);
EglDmabufBuffer(const KWaylandServer::LinuxDmaBufAttributes &attrs,
EglDmabufBuffer(const DmaBufAttributes &attrs,
quint32 flags,
EglDmabuf *interfaceImpl);
......@@ -61,8 +61,7 @@ public:
explicit EglDmabuf(AbstractEglBackend *backend);
~EglDmabuf() override;
KWaylandServer::LinuxDmaBufV1ClientBuffer *importBuffer(const KWaylandServer::LinuxDmaBufAttributes &attrs,
quint32 flags) override;
KWaylandServer::LinuxDmaBufV1ClientBuffer *importBuffer(const DmaBufAttributes &attrs, quint32 flags) override;
QVector<KWaylandServer::LinuxDmaBufV1Feedback::Tranche> tranches() const
{
......@@ -70,10 +69,9 @@ public:
}
private:
EGLImage createImage(const KWaylandServer::LinuxDmaBufAttributes &attrs);
EGLImage createImage(const DmaBufAttributes &attrs);
KWaylandServer::LinuxDmaBufV1ClientBuffer *yuvImport(const KWaylandServer::LinuxDmaBufAttributes &attrs,
quint32 flags);
KWaylandServer::LinuxDmaBufV1ClientBuffer *yuvImport(const DmaBufAttributes &attrs, quint32 flags);
void setSupportedFormatsAndModifiers();
......
......@@ -166,7 +166,7 @@ void LinuxDmaBufParamsV1::zwp_linux_buffer_params_v1_create(Resource *resource,
return;
}
m_attrs = LinuxDmaBufAttributes{}; // the ownership of file descriptors has been moved to the buffer
m_attrs = KWin::DmaBufAttributes{}; // the ownership of file descriptors has been moved to the buffer
wl_resource *bufferResource = wl_resource_create(resource->client(), &wl_buffer_interface, 1, 0);
if (!bufferResource) {
......@@ -210,7 +210,7 @@ void LinuxDmaBufParamsV1::zwp_linux_buffer_params_v1_create_immed(Resource *reso
return;
}
m_attrs = LinuxDmaBufAttributes{}; // the ownership of file descriptors has been moved to the buffer
m_attrs = KWin::DmaBufAttributes{}; // the ownership of file descriptors has been moved to the buffer
wl_resource *bufferResource = wl_resource_create(resource->client(), &wl_buffer_interface, 1, buffer_id);
if (!bufferResource) {
......@@ -366,7 +366,7 @@ void LinuxDmaBufV1ClientBufferPrivate::buffer_destroy(Resource *resource)
wl_resource_destroy(resource->handle);
}
LinuxDmaBufV1ClientBuffer::LinuxDmaBufV1ClientBuffer(const LinuxDmaBufAttributes &attrs, quint32 flags)
LinuxDmaBufV1ClientBuffer::LinuxDmaBufV1ClientBuffer(const KWin::DmaBufAttributes &attrs, quint32 flags)
: ClientBuffer(*new LinuxDmaBufV1ClientBufferPrivate)
{
Q_D(LinuxDmaBufV1ClientBuffer);
......@@ -405,7 +405,7 @@ quint32 LinuxDmaBufV1ClientBuffer::flags() const
return d->flags;
}
LinuxDmaBufAttributes LinuxDmaBufV1ClientBuffer::attributes() const
KWin::DmaBufAttributes LinuxDmaBufV1ClientBuffer::attributes() const
{
Q_D(const LinuxDmaBufV1ClientBuffer);
return d->attrs;
......
......@@ -11,6 +11,8 @@
#include "clientbuffer.h"
#include "clientbufferintegration.h"
#include "dmabufattributes.h"
#include <QHash>
#include <QSet>
#include <sys/types.h>
......@@ -21,19 +23,6 @@ class LinuxDmaBufV1ClientBufferPrivate;
class LinuxDmaBufV1ClientBufferIntegrationPrivate;
class LinuxDmaBufV1FeedbackPrivate;
struct LinuxDmaBufAttributes
{
int planeCount = 0;
int width = 0;
int height = 0;
uint32_t format = 0;
uint64_t modifier = 0;
int fd[4] = {-1, -1, -1, -1};
int offset[4] = {0, 0, 0, 0};
int pitch[4] = {0, 0, 0, 0};
};
/**
* The LinuxDmaBufV1ClientBuffer class represents a linux dma-buf client buffer.
*
......@@ -46,12 +35,12 @@ class KWIN_EXPORT LinuxDmaBufV1ClientBuffer : public ClientBuffer
Q_DECLARE_PRIVATE(LinuxDmaBufV1ClientBuffer)
public:
LinuxDmaBufV1ClientBuffer(const LinuxDmaBufAttributes &attrs, quint32 flags);
LinuxDmaBufV1ClientBuffer(const KWin::DmaBufAttributes &attrs, quint32 flags);
~LinuxDmaBufV1ClientBuffer() override;
quint32 format() const;
quint32 flags() const;
LinuxDmaBufAttributes attributes() const;
KWin::DmaBufAttributes attributes() const;
QSize size() const override;
bool hasAlphaChannel() const override;
......@@ -126,7 +115,7 @@ public:
*
* @return The imported buffer on success, and nullptr otherwise.
*/
virtual LinuxDmaBufV1ClientBuffer *importBuffer(const LinuxDmaBufAttributes &attrs, quint32 flags) = 0;
virtual LinuxDmaBufV1ClientBuffer *importBuffer(const KWin::DmaBufAttributes &attrs, quint32 flags) = 0;
};
RendererInterface *rendererInterface() const;
......
......@@ -50,7 +50,7 @@ protected:
class LinuxDmaBufV1ClientBufferPrivate : public ClientBufferPrivate, public QtWaylandServer::wl_buffer
{
public:
LinuxDmaBufAttributes attrs;
KWin::DmaBufAttributes attrs;
quint32 flags;
bool hasAlphaChannel = false;
......@@ -82,7 +82,7 @@ private:
bool test(Resource *resource, uint32_t width, uint32_t height);
LinuxDmaBufV1ClientBufferIntegration *m_integration;
LinuxDmaBufAttributes m_attrs;
KWin::DmaBufAttributes m_attrs;
bool m_isUsed = false;
};
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment