Changeset View
Changeset View
Standalone View
Standalone View
platformsupport/scenes/opengl/linux_dmabuf.h
- This file was added.
1 | /******************************************************************** | ||||
---|---|---|---|---|---|
2 | KWin - the KDE window manager | ||||
3 | This file is part of the KDE project. | ||||
4 | | ||||
5 | Copyright © 2019 Roman Gilg <subdiff@gmail.com> | ||||
6 | Copyright © 2018 Fredrik Höglund <fredrik@kde.org> | ||||
7 | | ||||
8 | 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 | ||||
10 | the Free Software Foundation; either version 2 of the License, or | ||||
11 | (at your option) any later version. | ||||
12 | | ||||
13 | This program is distributed in the hope that it will be useful, | ||||
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
16 | GNU General Public License for more details. | ||||
17 | | ||||
18 | 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/>. | ||||
20 | *********************************************************************/ | ||||
21 | #pragma once | ||||
22 | | ||||
23 | #include "abstract_egl_backend.h" | ||||
24 | | ||||
25 | #include <KWayland/Server/linuxdmabuf_v1_interface.h> | ||||
26 | | ||||
27 | #include <QVector> | ||||
28 | | ||||
29 | namespace KWin | ||||
30 | { | ||||
31 | class LinuxDmabuf; | ||||
32 | | ||||
33 | class DmabufBuffer : public KWayland::Server::LinuxDmabufUnstableV1Buffer | ||||
34 | { | ||||
35 | public: | ||||
36 | using Plane = KWayland::Server::LinuxDmabufUnstableV1Interface::Plane; | ||||
37 | using Flags = KWayland::Server::LinuxDmabufUnstableV1Interface::Flags; | ||||
38 | | ||||
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, | ||||
52 | uint32_t format, | ||||
53 | const QSize &size, | ||||
54 | Flags flags, | ||||
55 | LinuxDmabuf *interfaceImpl); | ||||
56 | | ||||
57 | ~DmabufBuffer() override; | ||||
58 | | ||||
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; } | ||||
65 | | ||||
66 | private: | ||||
67 | QVector<EGLImage> m_images; | ||||
68 | QVector<Plane> m_planes; | ||||
69 | Flags m_flags; | ||||
70 | LinuxDmabuf *m_interfaceImpl; | ||||
71 | ImportType m_importType; | ||||
72 | }; | ||||
73 | | ||||
74 | class LinuxDmabuf : public KWayland::Server::LinuxDmabufUnstableV1Interface::Impl | ||||
75 | { | ||||
76 | public: | ||||
77 | using Plane = KWayland::Server::LinuxDmabufUnstableV1Interface::Plane; | ||||
78 | using Flags = KWayland::Server::LinuxDmabufUnstableV1Interface::Flags; | ||||
79 | | ||||
80 | static LinuxDmabuf* factory(AbstractEglBackend *backend); | ||||
81 | | ||||
82 | explicit LinuxDmabuf(AbstractEglBackend *backend); | ||||
83 | ~LinuxDmabuf(); | ||||
84 | | ||||
85 | KWayland::Server::LinuxDmabufUnstableV1Buffer *importBuffer(const QVector<Plane> &planes, | ||||
86 | uint32_t format, | ||||
87 | const QSize &size, | ||||
88 | Flags flags) override; | ||||
89 | | ||||
90 | private: | ||||
91 | EGLImage createImage(const QVector<Plane> &planes, | ||||
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 | }; | ||||
110 | | ||||
111 | } |