Changeset View
Changeset View
Standalone View
Standalone View
linux_dmabuf.h
- This file was copied from platformsupport/scenes/opengl/linux_dmabuf.h.
1 | /******************************************************************** | 1 | /******************************************************************** | ||
---|---|---|---|---|---|
2 | KWin - the KDE window manager | 2 | KWin - the KDE window manager | ||
3 | This file is part of the KDE project. | 3 | This file is part of the KDE project. | ||
4 | 4 | | |||
5 | Copyright © 2019 Roman Gilg <subdiff@gmail.com> | 5 | Copyright © 2019 Roman Gilg <subdiff@gmail.com> | ||
6 | Copyright © 2018 Fredrik Höglund <fredrik@kde.org> | | |||
7 | 6 | | |||
8 | This program is free software; you can redistribute it and/or modify | 7 | This program is free software; you can redistribute it and/or modify | ||
9 | it under the terms of the GNU General Public License as published by | 8 | it under the terms of the GNU General Public License as published by | ||
10 | the Free Software Foundation; either version 2 of the License, or | 9 | the Free Software Foundation; either version 2 of the License, or | ||
11 | (at your option) any later version. | 10 | (at your option) any later version. | ||
12 | 11 | | |||
13 | This program is distributed in the hope that it will be useful, | 12 | This program is distributed in the hope that it will be useful, | ||
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
16 | GNU General Public License for more details. | 15 | GNU General Public License for more details. | ||
17 | 16 | | |||
18 | You should have received a copy of the GNU General Public License | 17 | You should have received a copy of the GNU General Public License | ||
19 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 18 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
20 | *********************************************************************/ | 19 | *********************************************************************/ | ||
21 | #pragma once | 20 | #pragma once | ||
22 | 21 | | |||
23 | #include "abstract_egl_backend.h" | 22 | #include <kwin_export.h> | ||
24 | 23 | | |||
25 | #include <KWayland/Server/linuxdmabuf_v1_interface.h> | 24 | #include <KWayland/Server/linuxdmabuf_v1_interface.h> | ||
26 | 25 | | |||
27 | #include <QVector> | 26 | #include <QVector> | ||
28 | 27 | | |||
29 | namespace KWin | 28 | namespace KWin | ||
30 | { | 29 | { | ||
31 | class LinuxDmabuf; | | |||
32 | 30 | | |||
33 | class DmabufBuffer : public KWayland::Server::LinuxDmabufUnstableV1Buffer | 31 | class KWIN_EXPORT DmabufBuffer : public KWayland::Server::LinuxDmabufUnstableV1Buffer | ||
34 | { | 32 | { | ||
35 | public: | 33 | public: | ||
36 | using Plane = KWayland::Server::LinuxDmabufUnstableV1Interface::Plane; | 34 | using Plane = KWayland::Server::LinuxDmabufUnstableV1Interface::Plane; | ||
37 | using Flags = KWayland::Server::LinuxDmabufUnstableV1Interface::Flags; | 35 | using Flags = KWayland::Server::LinuxDmabufUnstableV1Interface::Flags; | ||
38 | 36 | | |||
39 | enum class ImportType { | | |||
40 | Direct, | | |||
41 | Conversion | | |||
42 | }; | | |||
43 | | ||||
44 | DmabufBuffer(EGLImage image, | | |||
45 | const QVector<Plane> &planes, | | |||
46 | uint32_t format, | | |||
47 | const QSize &size, | | |||
48 | Flags flags, | | |||
49 | LinuxDmabuf *interfaceImpl); | | |||
50 | | ||||
51 | DmabufBuffer(const QVector<Plane> &planes, | 37 | DmabufBuffer(const QVector<Plane> &planes, | ||
52 | uint32_t format, | 38 | uint32_t format, | ||
53 | const QSize &size, | 39 | const QSize &size, | ||
54 | Flags flags, | 40 | Flags flags); | ||
55 | LinuxDmabuf *interfaceImpl); | | |||
56 | 41 | | |||
57 | ~DmabufBuffer() override; | 42 | ~DmabufBuffer() override; | ||
58 | 43 | | |||
59 | void addImage(EGLImage image); | | |||
60 | void removeImages(); | | |||
61 | | ||||
62 | QVector<EGLImage> images() const { return m_images; } | | |||
63 | Flags flags() const { return m_flags; } | | |||
64 | const QVector<Plane> &planes() const { return m_planes; } | 44 | const QVector<Plane> &planes() const { return m_planes; } | ||
45 | uint32_t format() const { return m_format; } | ||||
46 | QSize size() const { return m_size; } | ||||
47 | Flags flags() const { return m_flags; } | ||||
65 | 48 | | |||
66 | private: | 49 | private: | ||
67 | QVector<EGLImage> m_images; | | |||
68 | QVector<Plane> m_planes; | 50 | QVector<Plane> m_planes; | ||
51 | uint32_t m_format; | ||||
52 | QSize m_size; | ||||
69 | Flags m_flags; | 53 | Flags m_flags; | ||
70 | LinuxDmabuf *m_interfaceImpl; | | |||
71 | ImportType m_importType; | | |||
72 | }; | 54 | }; | ||
73 | 55 | | |||
74 | class LinuxDmabuf : public KWayland::Server::LinuxDmabufUnstableV1Interface::Impl | 56 | class KWIN_EXPORT LinuxDmabuf : public KWayland::Server::LinuxDmabufUnstableV1Interface::Impl | ||
75 | { | 57 | { | ||
76 | public: | 58 | public: | ||
77 | using Plane = KWayland::Server::LinuxDmabufUnstableV1Interface::Plane; | 59 | using Plane = KWayland::Server::LinuxDmabufUnstableV1Interface::Plane; | ||
78 | using Flags = KWayland::Server::LinuxDmabufUnstableV1Interface::Flags; | 60 | using Flags = KWayland::Server::LinuxDmabufUnstableV1Interface::Flags; | ||
79 | 61 | | |||
80 | static LinuxDmabuf* factory(AbstractEglBackend *backend); | 62 | explicit LinuxDmabuf(); | ||
81 | | ||||
82 | explicit LinuxDmabuf(AbstractEglBackend *backend); | | |||
83 | ~LinuxDmabuf(); | 63 | ~LinuxDmabuf(); | ||
84 | 64 | | |||
85 | KWayland::Server::LinuxDmabufUnstableV1Buffer *importBuffer(const QVector<Plane> &planes, | 65 | KWayland::Server::LinuxDmabufUnstableV1Buffer *importBuffer(const QVector<Plane> &planes, | ||
86 | uint32_t format, | 66 | uint32_t format, | ||
87 | const QSize &size, | 67 | const QSize &size, | ||
88 | Flags flags) override; | 68 | Flags flags) override; | ||
89 | 69 | | |||
90 | private: | 70 | protected: | ||
91 | EGLImage createImage(const QVector<Plane> &planes, | 71 | void setSupportedFormatsAndModifiers(QHash<uint32_t, QSet<uint64_t> > &set); | ||
92 | uint32_t format, | | |||
93 | const QSize &size); | | |||
94 | | ||||
95 | | ||||
96 | KWayland::Server::LinuxDmabufUnstableV1Buffer *yuvImport(const QVector<Plane> &planes, | | |||
97 | uint32_t format, | | |||
98 | const QSize &size, | | |||
99 | Flags flags); | | |||
100 | | ||||
101 | void removeBuffer(DmabufBuffer *buffer); | | |||
102 | void setSupportedFormatsAndModifiers(); | | |||
103 | | ||||
104 | KWayland::Server::LinuxDmabufUnstableV1Interface *m_interface; | | |||
105 | QSet<DmabufBuffer*> m_buffers; | | |||
106 | AbstractEglBackend *m_backend; | | |||
107 | | ||||
108 | friend class DmabufBuffer; | | |||
109 | }; | 72 | }; | ||
110 | 73 | | |||
111 | } | 74 | } |