Changeset View
Changeset View
Standalone View
Standalone View
plugins/platforms/drm/drm_buffer_gbm.h
- This file was copied from plugins/platforms/drm/drm_object_crtc.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 (C) 2016 Roman Gilg <subdiff@gmail.com> | 5 | Copyright 2017 Roman Gilg <subdiff@gmail.com> | ||
6 | Copyright 2015 Martin Gräßlin <mgraesslin@kde.org> | ||||
6 | 7 | | |||
7 | This program is free software; you can redistribute it and/or modify | 8 | 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 | 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 | the Free Software Foundation; either version 2 of the License, or | ||
10 | (at your option) any later version. | 11 | (at your option) any later version. | ||
11 | 12 | | |||
12 | This program is distributed in the hope that it will be useful, | 13 | This program is distributed in the hope that it will be useful, | ||
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | GNU General Public License for more details. | 16 | GNU General Public License for more details. | ||
16 | 17 | | |||
17 | You should have received a copy of the GNU General Public License | 18 | 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 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
19 | *********************************************************************/ | 20 | *********************************************************************/ | ||
20 | #ifndef KWIN_DRM_OBJECT_CRTC_H | 21 | #ifndef KWIN_DRM_BUFFER_GBM_H | ||
21 | #define KWIN_DRM_OBJECT_CRTC_H | 22 | #define KWIN_DRM_BUFFER_GBM_H | ||
22 | 23 | | |||
23 | #include "drm_object.h" | 24 | #include "drm_buffer.h" | ||
25 | | ||||
26 | struct gbm_bo; | ||||
27 | struct gbm_surface; | ||||
24 | 28 | | |||
25 | namespace KWin | 29 | namespace KWin | ||
26 | { | 30 | { | ||
27 | 31 | | |||
28 | class DrmBackend; | 32 | class DrmBackend; | ||
29 | class DrmBuffer; | | |||
30 | 33 | | |||
31 | class DrmCrtc : public DrmObject | 34 | class DrmSurfaceBuffer : public DrmBuffer | ||
32 | { | 35 | { | ||
33 | public: | 36 | public: | ||
34 | DrmCrtc(uint32_t crtc_id, int fd, int resIndex); | 37 | DrmSurfaceBuffer(DrmBackend *backend, gbm_surface *surface); | ||
35 | 38 | ~DrmSurfaceBuffer(); | |||
36 | virtual ~DrmCrtc(); | | |||
37 | | ||||
38 | bool init(); | | |||
39 | | ||||
40 | enum class PropertyIndex { | | |||
41 | ModeId = 0, | | |||
42 | Active, | | |||
43 | Count | | |||
44 | }; | | |||
45 | | ||||
46 | bool initProps(); | | |||
47 | 39 | | |||
48 | int resIndex() const { | 40 | bool needsModeChange(DrmBuffer *b) const override { | ||
49 | return m_resIndex; | 41 | if (DrmSurfaceBuffer *sb = dynamic_cast<DrmSurfaceBuffer*>(b)) { | ||
42 | return hasBo() != sb->hasBo(); | ||||
43 | } else { | ||||
44 | return true; | ||||
50 | } | 45 | } | ||
51 | | ||||
52 | DrmBuffer *current() { | | |||
53 | return m_currentBuffer; | | |||
54 | } | | |||
55 | DrmBuffer *next() { | | |||
56 | return m_nextBuffer; | | |||
57 | } | | |||
58 | void setNext(DrmBuffer *buffer) { | | |||
59 | m_nextBuffer = buffer; | | |||
60 | } | 46 | } | ||
61 | 47 | | |||
62 | void flipBuffer(); | 48 | bool hasBo() const { | ||
63 | bool blank(); | 49 | return m_bo != nullptr; | ||
50 | } | ||||
51 | void releaseGbm() override; | ||||
64 | 52 | | |||
65 | private: | 53 | private: | ||
66 | DrmBackend *m_backend; | 54 | gbm_surface *m_surface = nullptr; | ||
67 | int m_resIndex; | 55 | gbm_bo *m_bo = nullptr; | ||
68 | | ||||
69 | DrmBuffer *m_currentBuffer = nullptr; | | |||
70 | DrmBuffer *m_nextBuffer = nullptr; | | |||
71 | DrmBuffer *m_blackBuffer = nullptr; | | |||
72 | }; | 56 | }; | ||
73 | 57 | | |||
74 | } | 58 | } | ||
75 | 59 | | |||
76 | #endif | 60 | #endif | ||
77 | 61 | |