Changeset View
Changeset View
Standalone View
Standalone View
linux_dmabuf.cpp
- 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 | | ||||
7 | This program is free software; you can redistribute it and/or modify | ||||
8 | it under the terms of the GNU General Public License as published by | ||||
9 | the Free Software Foundation; either version 2 of the License, or | ||||
10 | (at your option) any later version. | ||||
11 | | ||||
12 | This program is distributed in the hope that it will be useful, | ||||
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
15 | GNU General Public License for more details. | ||||
16 | | ||||
17 | You should have received a copy of the GNU General Public License | ||||
18 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||||
19 | *********************************************************************/ | ||||
20 | #include "linux_dmabuf.h" | ||||
21 | | ||||
22 | #include "wayland_server.h" | ||||
23 | | ||||
24 | #include <unistd.h> | ||||
25 | | ||||
26 | namespace KWin | ||||
27 | { | ||||
28 | | ||||
29 | DmabufBuffer::DmabufBuffer(const QVector<Plane> &planes, | ||||
30 | uint32_t format, | ||||
31 | const QSize &size, | ||||
32 | Flags flags) | ||||
33 | : KWayland::Server::LinuxDmabufUnstableV1Buffer(format, size) | ||||
34 | , m_planes(planes) | ||||
35 | , m_format(format) | ||||
36 | , m_size(size) | ||||
37 | , m_flags(flags) | ||||
38 | { | ||||
39 | waylandServer()->addLinuxDmabufBuffer(this); | ||||
40 | } | ||||
41 | | ||||
42 | DmabufBuffer::~DmabufBuffer() | ||||
43 | { | ||||
44 | // Close all open file descriptors | ||||
45 | for (int i = 0; i < m_planes.count(); i++) { | ||||
46 | if (m_planes[i].fd != -1) | ||||
47 | ::close(m_planes[i].fd); | ||||
48 | m_planes[i].fd = -1; | ||||
49 | } | ||||
50 | if (waylandServer()) { | ||||
51 | waylandServer()->removeLinuxDmabufBuffer(this); | ||||
52 | } | ||||
53 | } | ||||
54 | | ||||
55 | LinuxDmabuf::LinuxDmabuf() | ||||
56 | : KWayland::Server::LinuxDmabufUnstableV1Interface::Impl() | ||||
57 | { | ||||
58 | Q_ASSERT(waylandServer()); | ||||
59 | waylandServer()->linuxDmabuf()->setImpl(this); | ||||
60 | } | ||||
61 | | ||||
62 | LinuxDmabuf::~LinuxDmabuf() | ||||
63 | { | ||||
64 | waylandServer()->linuxDmabuf()->setImpl(nullptr); | ||||
65 | } | ||||
66 | | ||||
67 | using Plane = KWayland::Server::LinuxDmabufUnstableV1Interface::Plane; | ||||
68 | using Flags = KWayland::Server::LinuxDmabufUnstableV1Interface::Flags; | ||||
69 | | ||||
70 | KWayland::Server::LinuxDmabufUnstableV1Buffer* LinuxDmabuf::importBuffer(const QVector<Plane> &planes, | ||||
71 | uint32_t format, | ||||
72 | const QSize &size, | ||||
73 | Flags flags) | ||||
74 | { | ||||
75 | Q_UNUSED(planes) | ||||
76 | Q_UNUSED(format) | ||||
77 | Q_UNUSED(size) | ||||
78 | Q_UNUSED(flags) | ||||
79 | | ||||
80 | return nullptr; | ||||
81 | } | ||||
82 | | ||||
83 | void LinuxDmabuf::setSupportedFormatsAndModifiers(QHash<uint32_t, QSet<uint64_t> > &set) | ||||
84 | { | ||||
85 | waylandServer()->linuxDmabuf()->setSupportedFormatsWithModifiers(set); | ||||
86 | } | ||||
87 | | ||||
88 | } |