Changeset View
Changeset View
Standalone View
Standalone View
plugins/platforms/drm/drm_buffer_gbm.h
- This file was added.
1 | /******************************************************************** | ||||
---|---|---|---|---|---|
2 | KWin - the KDE window manager | ||||
3 | This file is part of the KDE project. | ||||
4 | | ||||
5 | Copyright 2017 Roman Gilg <subdiff@gmail.com> | ||||
6 | Copyright 2015 Martin Gräßlin <mgraesslin@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 | #ifndef KWIN_DRM_BUFFER_GBM_H | ||||
22 | #define KWIN_DRM_BUFFER_GBM_H | ||||
23 | | ||||
24 | #include "drm_buffer.h" | ||||
25 | | ||||
26 | struct gbm_bo; | ||||
27 | struct gbm_surface; | ||||
28 | | ||||
29 | namespace KWayland | ||||
30 | { | ||||
31 | namespace Server | ||||
32 | { | ||||
33 | class BufferInterface; | ||||
34 | } | ||||
35 | } | ||||
36 | | ||||
37 | namespace KWin | ||||
38 | { | ||||
39 | | ||||
40 | class DrmBackend; | ||||
41 | | ||||
42 | class DrmSurfaceBuffer : public DrmBuffer | ||||
43 | { | ||||
44 | public: | ||||
45 | DrmSurfaceBuffer(DrmBackend *backend, gbm_surface *surface); | ||||
46 | ~DrmSurfaceBuffer(); | ||||
47 | | ||||
48 | bool needsModeChange(DrmBuffer *b) const override { | ||||
49 | if (DrmSurfaceBuffer *sb = dynamic_cast<DrmSurfaceBuffer*>(b)) { | ||||
50 | return hasBo() != sb->hasBo(); | ||||
51 | } else { | ||||
52 | return true; | ||||
53 | } | ||||
54 | } | ||||
55 | | ||||
56 | bool hasBo() const { | ||||
57 | return m_bo != nullptr; | ||||
58 | } | ||||
59 | void retire() override; | ||||
60 | | ||||
61 | private: | ||||
62 | gbm_surface *m_surface = nullptr; | ||||
63 | gbm_bo *m_bo = nullptr; | ||||
64 | }; | ||||
65 | | ||||
66 | class DrmImportBuffer : public QObject, public DrmBuffer | ||||
67 | { | ||||
68 | Q_OBJECT | ||||
69 | public: | ||||
70 | DrmImportBuffer(DrmBackend *backend, KWayland::Server::BufferInterface *buffer); | ||||
71 | ~DrmImportBuffer(); | ||||
72 | | ||||
73 | bool hasBo() const { | ||||
74 | return m_bo != nullptr; | ||||
75 | } | ||||
76 | QPointer<KWayland::Server::BufferInterface> bi() { | ||||
77 | return m_bi; | ||||
78 | } | ||||
79 | | ||||
80 | private: | ||||
81 | QPointer<KWayland::Server::BufferInterface> m_bi; | ||||
82 | gbm_bo *m_bo = nullptr; | ||||
83 | }; | ||||
84 | | ||||
85 | } | ||||
86 | | ||||
87 | #endif | ||||
88 | |