Changeset View
Changeset View
Standalone View
Standalone View
platformsupport/scenes/opengl/abstract_egl_backend.h
Show All 17 Lines | |||||
18 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 18 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
19 | *********************************************************************/ | 19 | *********************************************************************/ | ||
20 | #ifndef KWIN_ABSTRACT_EGL_BACKEND_H | 20 | #ifndef KWIN_ABSTRACT_EGL_BACKEND_H | ||
21 | #define KWIN_ABSTRACT_EGL_BACKEND_H | 21 | #define KWIN_ABSTRACT_EGL_BACKEND_H | ||
22 | #include "backend.h" | 22 | #include "backend.h" | ||
23 | #include "texture.h" | 23 | #include "texture.h" | ||
24 | 24 | | |||
25 | #include <QObject> | 25 | #include <QObject> | ||
26 | #include <QSet> | ||||
26 | #include <epoxy/egl.h> | 27 | #include <epoxy/egl.h> | ||
27 | #include <fixx11h.h> | 28 | #include <fixx11h.h> | ||
28 | 29 | | |||
29 | class QOpenGLFramebufferObject; | 30 | class QOpenGLFramebufferObject; | ||
30 | 31 | | |||
31 | namespace KWayland | 32 | namespace KWayland | ||
32 | { | 33 | { | ||
33 | namespace Server | 34 | namespace Server | ||
34 | { | 35 | { | ||
35 | class BufferInterface; | 36 | class BufferInterface; | ||
36 | } | 37 | } | ||
37 | } | 38 | } | ||
38 | 39 | | |||
39 | namespace KWin | 40 | namespace KWin | ||
40 | { | 41 | { | ||
41 | 42 | | |||
43 | class EglDmabufBuffer; | ||||
44 | | ||||
42 | class KWIN_EXPORT AbstractEglBackend : public QObject, public OpenGLBackend | 45 | class KWIN_EXPORT AbstractEglBackend : public QObject, public OpenGLBackend | ||
43 | { | 46 | { | ||
44 | Q_OBJECT | 47 | Q_OBJECT | ||
45 | public: | 48 | public: | ||
46 | virtual ~AbstractEglBackend(); | 49 | virtual ~AbstractEglBackend(); | ||
47 | bool makeCurrent() override; | 50 | bool makeCurrent() override; | ||
48 | void doneCurrent() override; | 51 | void doneCurrent() override; | ||
49 | 52 | | |||
50 | EGLDisplay eglDisplay() const { | 53 | EGLDisplay eglDisplay() const { | ||
51 | return m_display; | 54 | return m_display; | ||
52 | } | 55 | } | ||
53 | EGLContext context() const { | 56 | EGLContext context() const { | ||
54 | return m_context; | 57 | return m_context; | ||
55 | } | 58 | } | ||
56 | EGLSurface surface() const { | 59 | EGLSurface surface() const { | ||
57 | return m_surface; | 60 | return m_surface; | ||
58 | } | 61 | } | ||
59 | EGLConfig config() const { | 62 | EGLConfig config() const { | ||
60 | return m_config; | 63 | return m_config; | ||
61 | } | 64 | } | ||
62 | 65 | | |||
66 | void removeDmabufBuffer(EglDmabufBuffer *buffer); | ||||
67 | | ||||
68 | QVector<uint32_t> supportedDrmFormats() override; | ||||
69 | QVector<uint64_t> supportedDrmModifiers(uint32_t format) override; | ||||
70 | KWayland::Server::LinuxDmabuf::Buffer *importDmabufBuffer(const QVector<KWayland::Server::LinuxDmabuf::Plane> &planes, | ||||
71 | uint32_t format, | ||||
72 | const QSize &size, | ||||
73 | KWayland::Server::LinuxDmabuf::Flags flags) override; | ||||
74 | | ||||
63 | protected: | 75 | protected: | ||
64 | AbstractEglBackend(); | 76 | AbstractEglBackend(); | ||
65 | void setEglDisplay(const EGLDisplay &display); | 77 | void setEglDisplay(const EGLDisplay &display); | ||
66 | void setSurface(const EGLSurface &surface); | 78 | void setSurface(const EGLSurface &surface); | ||
67 | void setConfig(const EGLConfig &config); | 79 | void setConfig(const EGLConfig &config); | ||
68 | void cleanup(); | 80 | void cleanup(); | ||
69 | virtual void cleanupSurfaces(); | 81 | virtual void cleanupSurfaces(); | ||
70 | bool initEglAPI(); | 82 | bool initEglAPI(); | ||
Show All 9 Lines | |||||
80 | private: | 92 | private: | ||
81 | void unbindWaylandDisplay(); | 93 | void unbindWaylandDisplay(); | ||
82 | 94 | | |||
83 | EGLDisplay m_display = EGL_NO_DISPLAY; | 95 | EGLDisplay m_display = EGL_NO_DISPLAY; | ||
84 | EGLSurface m_surface = EGL_NO_SURFACE; | 96 | EGLSurface m_surface = EGL_NO_SURFACE; | ||
85 | EGLContext m_context = EGL_NO_CONTEXT; | 97 | EGLContext m_context = EGL_NO_CONTEXT; | ||
86 | EGLConfig m_config = nullptr; | 98 | EGLConfig m_config = nullptr; | ||
87 | QList<QByteArray> m_clientExtensions; | 99 | QList<QByteArray> m_clientExtensions; | ||
100 | QSet<EglDmabufBuffer *> m_dmabufBuffers; | ||||
romangg: Why QLinkedList? It should be no better than QList for the removeOne call. For this better use… | |||||
I believe the use of QList is discouraged in new code, but you are right about QSet being a better choice in this case. fredrik: I believe the use of QList is discouraged in new code, but you are right about QSet being a… | |||||
101 | bool m_haveDmabufImport = false; | ||||
88 | }; | 102 | }; | ||
89 | 103 | | |||
90 | class KWIN_EXPORT AbstractEglTexture : public SceneOpenGLTexturePrivate | 104 | class KWIN_EXPORT AbstractEglTexture : public SceneOpenGLTexturePrivate | ||
91 | { | 105 | { | ||
92 | public: | 106 | public: | ||
93 | virtual ~AbstractEglTexture(); | 107 | virtual ~AbstractEglTexture(); | ||
94 | bool loadTexture(WindowPixmap *pixmap) override; | 108 | bool loadTexture(WindowPixmap *pixmap) override; | ||
95 | void updateTexture(WindowPixmap *pixmap) override; | 109 | void updateTexture(WindowPixmap *pixmap) override; | ||
Show All 9 Lines | 112 | protected: | |||
105 | } | 119 | } | ||
106 | SceneOpenGLTexture *texture() const { | 120 | SceneOpenGLTexture *texture() const { | ||
107 | return q; | 121 | return q; | ||
108 | } | 122 | } | ||
109 | 123 | | |||
110 | private: | 124 | private: | ||
111 | bool loadShmTexture(const QPointer<KWayland::Server::BufferInterface> &buffer); | 125 | bool loadShmTexture(const QPointer<KWayland::Server::BufferInterface> &buffer); | ||
112 | bool loadEglTexture(const QPointer<KWayland::Server::BufferInterface> &buffer); | 126 | bool loadEglTexture(const QPointer<KWayland::Server::BufferInterface> &buffer); | ||
127 | bool loadDmabufTexture(const QPointer< KWayland::Server::BufferInterface > &buffer); | ||||
113 | EGLImageKHR attach(const QPointer<KWayland::Server::BufferInterface> &buffer); | 128 | EGLImageKHR attach(const QPointer<KWayland::Server::BufferInterface> &buffer); | ||
114 | bool updateFromFBO(const QSharedPointer<QOpenGLFramebufferObject> &fbo); | 129 | bool updateFromFBO(const QSharedPointer<QOpenGLFramebufferObject> &fbo); | ||
115 | SceneOpenGLTexture *q; | 130 | SceneOpenGLTexture *q; | ||
116 | AbstractEglBackend *m_backend; | 131 | AbstractEglBackend *m_backend; | ||
117 | EGLImageKHR m_image; | 132 | EGLImageKHR m_image; | ||
118 | }; | 133 | }; | ||
119 | 134 | | |||
135 | class EglDmabufBuffer : public KWayland::Server::LinuxDmabuf::Buffer | ||||
romangg: Why is it necessary to export? | |||||
I guess it isn't. I was thinking at the time that someone might want to use this class in a class derived from AbstractEglBackend or AbstractEglTexture. fredrik: I guess it isn't. I was thinking at the time that someone might want to use this class in a… | |||||
136 | { | ||||
137 | public: | ||||
138 | using Plane = KWayland::Server::LinuxDmabuf::Plane; | ||||
139 | using Flags = KWayland::Server::LinuxDmabuf::Flags; | ||||
140 | | ||||
141 | EglDmabufBuffer(EGLImage image, | ||||
142 | const QVector<Plane> &planes, | ||||
143 | uint32_t format, | ||||
144 | const QSize &size, | ||||
145 | Flags flags, | ||||
146 | AbstractEglBackend *backend); | ||||
147 | ~EglDmabufBuffer() override; | ||||
148 | | ||||
149 | EGLImage image() const { return m_image; } | ||||
150 | Flags flags() const { return m_flags; } | ||||
151 | const QVector<Plane> &planes() const { return m_planes; } | ||||
152 | | ||||
153 | void destroyImage(); | ||||
154 | | ||||
155 | private: | ||||
156 | AbstractEglBackend *m_backend; | ||||
157 | EGLImage m_image; | ||||
158 | QVector<Plane> m_planes; | ||||
159 | Flags m_flags; | ||||
160 | }; | ||||
161 | | ||||
120 | } | 162 | } | ||
121 | 163 | | |||
122 | #endif | 164 | #endif |
Why QLinkedList? It should be no better than QList for the removeOne call. For this better use QSet.