diff --git a/src/wayland/linuxdmabufv1clientbuffer.cpp b/src/wayland/linuxdmabufv1clientbuffer.cpp index 2539b046bd..d0795dc8aa 100644 --- a/src/wayland/linuxdmabufv1clientbuffer.cpp +++ b/src/wayland/linuxdmabufv1clientbuffer.cpp @@ -307,17 +307,17 @@ void LinuxDmaBufV1ClientBufferIntegration::setRendererInterface(RendererInterfac d->rendererInterface = rendererInterface; } -void LinuxDmaBufV1ClientBufferIntegration::setSupportedFormatsWithModifiers(dev_t mainDevice, const QHash> &set) +void LinuxDmaBufV1ClientBufferIntegration::setSupportedFormatsWithModifiers(const QVector &tranches) { - if (d->supportedModifiers != set || d->mainDevice != mainDevice) { + if (LinuxDmaBufV1FeedbackPrivate::get(d->defaultFeedback.data())->m_tranches != tranches) { + QHash> set; + for (const auto &tranche : tranches) { + set.insert(tranche.formatTable); + } d->supportedModifiers = set; - d->mainDevice = mainDevice; + d->mainDevice = tranches.first().device; d->table.reset(new LinuxDmaBufV1FormatTable(set)); - LinuxDmaBufV1Feedback::Tranche tranche; - tranche.device = mainDevice; - tranche.flags = {}; - tranche.formatTable = set; - d->defaultFeedback->setTranches({tranche}); + d->defaultFeedback->setTranches(tranches); } } diff --git a/src/wayland/linuxdmabufv1clientbuffer.h b/src/wayland/linuxdmabufv1clientbuffer.h index dbfba08857..cd368da818 100644 --- a/src/wayland/linuxdmabufv1clientbuffer.h +++ b/src/wayland/linuxdmabufv1clientbuffer.h @@ -59,6 +59,36 @@ private: friend class LinuxDmaBufParamsV1; }; +class KWAYLANDSERVER_EXPORT LinuxDmaBufV1Feedback : public QObject +{ + Q_OBJECT +public: + ~LinuxDmaBufV1Feedback() override; + + enum class TrancheFlag : uint32_t { + Scanout = 1, + }; + Q_DECLARE_FLAGS(TrancheFlags, TrancheFlag) + + struct Tranche { + dev_t device; + TrancheFlags flags; + QHash> formatTable; + }; + /** + * Sets the list of tranches for this feedback object, with lower indices + * indicating a higher priority / a more optimal configuration. + * The main device does not need to be included + */ + void setTranches(const QVector &tranches); + +private: + LinuxDmaBufV1Feedback(LinuxDmaBufV1ClientBufferIntegrationPrivate *integration); + friend class LinuxDmaBufV1ClientBufferIntegrationPrivate; + friend class LinuxDmaBufV1FeedbackPrivate; + QScopedPointer d; +}; + /** * The LinuxDmaBufV1ClientBufferIntegration class provides support for linux dma-buf buffers. */ @@ -104,41 +134,11 @@ public: */ void setRendererInterface(RendererInterface *rendererInterface); - void setSupportedFormatsWithModifiers(dev_t mainDevice, const QHash> &set); + void setSupportedFormatsWithModifiers(const QVector &tranches); private: friend class LinuxDmaBufV1ClientBufferIntegrationPrivate; QScopedPointer d; }; -class KWAYLANDSERVER_EXPORT LinuxDmaBufV1Feedback : public QObject -{ - Q_OBJECT -public: - ~LinuxDmaBufV1Feedback() override; - - enum class TrancheFlag : uint32_t { - Scanout = 1, - }; - Q_DECLARE_FLAGS(TrancheFlags, TrancheFlag) - - struct Tranche { - dev_t device; - TrancheFlags flags; - QHash> formatTable; - }; - /** - * Sets the list of tranches for this feedback object, with lower indices - * indicating a higher priority / a more optimal configuration. - * The main device does not need to be included - */ - void setTranches(const QVector &tranches); - -private: - LinuxDmaBufV1Feedback(LinuxDmaBufV1ClientBufferIntegrationPrivate *integration); - friend class LinuxDmaBufV1ClientBufferIntegrationPrivate; - friend class LinuxDmaBufV1FeedbackPrivate; - QScopedPointer d; -}; - } // namespace KWaylandServer