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 <KWayland/Server/linuxdmabuf_v1_interface.h> | ||||
24 | | ||||
25 | #include <QVector> | ||||
26 | | ||||
27 | #include "abstract_egl_backend.h" | ||||
28 | | ||||
29 | | ||||
30 | namespace KWin | ||||
31 | { | ||||
32 | class LinuxDmabuf; | ||||
33 | | ||||
34 | class DmabufBuffer : public KWayland::Server::LinuxDmabufUnstableV1Buffer | ||||
35 | { | ||||
36 | public: | ||||
37 | using Plane = KWayland::Server::LinuxDmabufUnstableV1Interface::Plane; | ||||
38 | using Flags = KWayland::Server::LinuxDmabufUnstableV1Interface::Flags; | ||||
39 | | ||||
40 | DmabufBuffer(EGLImage image, | ||||
41 | const QVector<Plane> &planes, | ||||
42 | uint32_t format, | ||||
43 | const QSize &size, | ||||
44 | Flags flags, | ||||
45 | LinuxDmabuf *interfaceImpl); | ||||
46 | ~DmabufBuffer() override; | ||||
47 | | ||||
48 | EGLImage image() const { return m_image; } | ||||
49 | Flags flags() const { return m_flags; } | ||||
50 | const QVector<Plane> &planes() const { return m_planes; } | ||||
51 | | ||||
52 | void destroyImage(); | ||||
53 | | ||||
54 | private: | ||||
55 | EGLImage m_image; | ||||
56 | QVector<Plane> m_planes; | ||||
57 | Flags m_flags; | ||||
58 | LinuxDmabuf *m_interfaceImpl; | ||||
59 | }; | ||||
60 | | ||||
61 | class LinuxDmabuf : public KWayland::Server::LinuxDmabufUnstableV1Interface::Impl | ||||
62 | { | ||||
63 | public: | ||||
64 | using Plane = KWayland::Server::LinuxDmabufUnstableV1Interface::Plane; | ||||
65 | using Flags = KWayland::Server::LinuxDmabufUnstableV1Interface::Flags; | ||||
66 | | ||||
67 | static LinuxDmabuf* factory(AbstractEglBackend *backend); | ||||
68 | | ||||
69 | explicit LinuxDmabuf(AbstractEglBackend *backend); | ||||
70 | ~LinuxDmabuf(); | ||||
71 | | ||||
72 | KWayland::Server::LinuxDmabufUnstableV1Buffer *importBuffer(const QVector<Plane> &planes, | ||||
73 | uint32_t format, | ||||
74 | const QSize &size, | ||||
75 | Flags flags) override; | ||||
76 | | ||||
77 | private: | ||||
78 | void removeBuffer(DmabufBuffer *buffer); | ||||
79 | void setSupportedFormatsAndModifiers(); | ||||
80 | | ||||
81 | KWayland::Server::LinuxDmabufUnstableV1Interface *m_interface; | ||||
82 | QSet<DmabufBuffer*> m_buffers; | ||||
83 | AbstractEglBackend *m_backend; | ||||
84 | | ||||
85 | friend class DmabufBuffer; | ||||
86 | }; | ||||
87 | | ||||
88 | } |