KWaylandServer

linuxdmabufv1clientbuffer.h
1 /*
2  SPDX-FileCopyrightText: 2018 Fredrik Höglund <[email protected]>
3  SPDX-FileCopyrightText: 2019 Roman Gilg <[email protected]>
4  SPDX-FileCopyrightText: 2021 Vlad Zahorodnii <[email protected]>
5 
6  SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
7 */
8 #pragma once
9 
10 #include "clientbuffer.h"
11 #include "clientbufferintegration.h"
12 
13 #include <QHash>
14 #include <QSet>
15 
16 namespace KWaylandServer
17 {
18 class LinuxDmaBufV1ClientBufferPrivate;
19 class LinuxDmaBufV1ClientBufferIntegrationPrivate;
20 
21 /**
22  * The LinuxDmaBufV1Plane type represents a plane in a client buffer.
23  */
25  int fd = -1; ///< The dmabuf file descriptor
26  quint32 offset = 0; ///< The offset from the start of buffer
27  quint32 stride = 0; ///< The distance from the start of a row to the next row in bytes
28  quint64 modifier = 0; ///< The layout modifier
29 };
30 
31 /**
32  * The LinuxDmaBufV1ClientBuffer class represents a linux dma-buf client buffer.
33  *
34  * The LinuxDmaBufV1ClientBuffer can be used even after the underlying wl_buffer object
35  * is destroyed by the client.
36  */
37 class KWAYLANDSERVER_EXPORT LinuxDmaBufV1ClientBuffer : public ClientBuffer
38 {
39  Q_OBJECT
40  Q_DECLARE_PRIVATE(LinuxDmaBufV1ClientBuffer)
41 
42 public:
43  LinuxDmaBufV1ClientBuffer(const QSize &size, quint32 format, quint32 flags, const QVector<LinuxDmaBufV1Plane> &planes);
44  ~LinuxDmaBufV1ClientBuffer() override;
45 
46  quint32 format() const;
47  quint32 flags() const;
48  QVector<LinuxDmaBufV1Plane> planes() const;
49 
50  QSize size() const override;
51  bool hasAlphaChannel() const override;
52  Origin origin() const override;
53 
54 private:
55  void initialize(wl_resource *resource);
56  friend class LinuxDmaBufParamsV1;
57 };
58 
59 /**
60  * The LinuxDmaBufV1ClientBufferIntegration class provides support for linux dma-buf buffers.
61  */
62 class KWAYLANDSERVER_EXPORT LinuxDmaBufV1ClientBufferIntegration : public ClientBufferIntegration
63 {
64  Q_OBJECT
65 
66 public:
69 
70  /**
71  * The Iface class provides an interface from the LinuxDmabufInterface into the compositor
72  */
74  {
75  public:
76  virtual ~RendererInterface() = default;
77 
78  /**
79  * Imports a linux-dmabuf buffer into the compositor.
80  *
81  * The parent LinuxDmabufUnstableV1Interface class takes ownership of returned
82  * buffer objects.
83  *
84  * In return the returned buffer takes ownership of the file descriptor for each
85  * plane.
86  *
87  * Note that it is the responsibility of the caller to close the file descriptors
88  * when the import fails.
89  *
90  * @return The imported buffer on success, and nullptr otherwise.
91  */
92  virtual LinuxDmaBufV1ClientBuffer *importBuffer(const QVector<LinuxDmaBufV1Plane> &planes, quint32 format, const QSize &size, quint32 flags) = 0;
93  };
94 
95  RendererInterface *rendererInterface() const;
96 
97  /**
98  * Sets the compositor implementation for the dmabuf interface.
99  *
100  * The ownership is not transferred by this call.
101  */
102  void setRendererInterface(RendererInterface *rendererInterface);
103 
104  void setSupportedFormatsWithModifiers(const QHash<uint32_t, QSet<uint64_t>> &set);
105 
106 private:
108 };
109 
110 } // namespace KWaylandServer
Class holding the Wayland server display loop.
Definition: display.h:47
The Iface class provides an interface from the LinuxDmabufInterface into the compositor.
quint32 offset
The offset from the start of buffer.
Origin
This enum type is used to specify the corner where the origin is.
Definition: clientbuffer.h:41
The LinuxDmaBufV1ClientBufferIntegration class provides support for linux dma-buf buffers...
The LinuxDmaBufV1Plane type represents a plane in a client buffer.
int fd
The dmabuf file descriptor.
quint32 stride
The distance from the start of a row to the next row in bytes.
The ClientBuffer class represents a client buffer.
Definition: clientbuffer.h:29
The LinuxDmaBufV1ClientBuffer class represents a linux dma-buf client buffer.
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Sat Oct 23 2021 23:08:27 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.