Changeset View
Changeset View
Standalone View
Standalone View
plugins/platforms/drm/egl_gbm_backend.h
Show All 15 Lines | |||||
16 | 16 | | |||
17 | You should have received a copy of the GNU General Public License | 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/>. | 18 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
19 | *********************************************************************/ | 19 | *********************************************************************/ | ||
20 | #ifndef KWIN_EGL_GBM_BACKEND_H | 20 | #ifndef KWIN_EGL_GBM_BACKEND_H | ||
21 | #define KWIN_EGL_GBM_BACKEND_H | 21 | #define KWIN_EGL_GBM_BACKEND_H | ||
22 | #include "abstract_egl_backend.h" | 22 | #include "abstract_egl_backend.h" | ||
23 | #include "remoteaccess_manager.h" | 23 | #include "remoteaccess_manager.h" | ||
24 | #include <KWayland/Server/screencasting_interface.h> | ||||
24 | 25 | | |||
26 | #include <optional> | ||||
25 | #include <memory> | 27 | #include <memory> | ||
26 | 28 | | |||
27 | struct gbm_surface; | 29 | struct gbm_surface; | ||
30 | class ScreenCastStream; | ||||
28 | 31 | | |||
29 | namespace KWin | 32 | namespace KWin | ||
30 | { | 33 | { | ||
31 | class DrmBackend; | 34 | class DrmBackend; | ||
32 | class DrmBuffer; | 35 | class DrmBuffer; | ||
36 | class DrmSurfaceBuffer; | ||||
33 | class DrmOutput; | 37 | class DrmOutput; | ||
34 | class GbmSurface; | 38 | class GbmSurface; | ||
35 | 39 | | |||
36 | /** | 40 | /** | ||
37 | * @brief OpenGL Backend using Egl on a GBM surface. | 41 | * @brief OpenGL Backend using Egl on a GBM surface. | ||
38 | */ | 42 | */ | ||
39 | class EglGbmBackend : public AbstractEglBackend | 43 | class EglGbmBackend : public AbstractEglBackend | ||
40 | { | 44 | { | ||
41 | Q_OBJECT | 45 | Q_OBJECT | ||
42 | public: | 46 | public: | ||
43 | EglGbmBackend(DrmBackend *drmBackend); | 47 | EglGbmBackend(DrmBackend *drmBackend); | ||
44 | ~EglGbmBackend() override; | 48 | ~EglGbmBackend() override; | ||
45 | void screenGeometryChanged(const QSize &size) override; | 49 | void screenGeometryChanged(const QSize &size) override; | ||
46 | SceneOpenGLTexturePrivate *createBackendTexture(SceneOpenGLTexture *texture) override; | 50 | SceneOpenGLTexturePrivate *createBackendTexture(SceneOpenGLTexture *texture) override; | ||
47 | QRegion prepareRenderingFrame() override; | 51 | QRegion prepareRenderingFrame() override; | ||
48 | void endRenderingFrame(const QRegion &renderedRegion, const QRegion &damagedRegion) override; | 52 | void endRenderingFrame(const QRegion &renderedRegion, const QRegion &damagedRegion) override; | ||
49 | void endRenderingFrameForScreen(int screenId, const QRegion &damage, const QRegion &damagedRegion) override; | 53 | void endRenderingFrameForScreen(int screenId, const QRegion &damage, const QRegion &damagedRegion) override; | ||
50 | bool usesOverlayWindow() const override; | 54 | bool usesOverlayWindow() const override; | ||
51 | bool perScreenRendering() const override; | 55 | bool perScreenRendering() const override; | ||
52 | QRegion prepareRenderingForScreen(int screenId) override; | 56 | QRegion prepareRenderingForScreen(int screenId) override; | ||
53 | void init() override; | 57 | void init() override; | ||
54 | 58 | | |||
59 | Q_SIGNALS: | ||||
60 | void passBuffer(DrmOutput *output, DrmSurfaceBuffer* gbmbuf); | ||||
61 | | ||||
55 | protected: | 62 | protected: | ||
56 | void present() override; | 63 | void present() override; | ||
57 | void cleanupSurfaces() override; | 64 | void cleanupSurfaces() override; | ||
58 | 65 | | |||
59 | private: | 66 | private: | ||
60 | bool initializeEgl(); | 67 | bool initializeEgl(); | ||
61 | bool initBufferConfigs(); | 68 | bool initBufferConfigs(); | ||
62 | bool initRenderingContext(); | 69 | bool initRenderingContext(); | ||
63 | void initRemotePresent(); | 70 | void initRemotePresent(); | ||
64 | struct Output { | 71 | struct Output { | ||
65 | DrmOutput *output = nullptr; | 72 | DrmOutput *output = nullptr; | ||
66 | DrmBuffer *buffer = nullptr; | 73 | DrmBuffer *buffer = nullptr; | ||
67 | std::shared_ptr<GbmSurface> gbmSurface; | 74 | std::shared_ptr<GbmSurface> gbmSurface; | ||
68 | EGLSurface eglSurface = EGL_NO_SURFACE; | 75 | EGLSurface eglSurface = EGL_NO_SURFACE; | ||
69 | int bufferAge = 0; | 76 | int bufferAge = 0; | ||
70 | /** | 77 | /** | ||
71 | * @brief The damage history for the past 10 frames. | 78 | * @brief The damage history for the past 10 frames. | ||
72 | */ | 79 | */ | ||
73 | QList<QRegion> damageHistory; | 80 | QList<QRegion> damageHistory; | ||
81 | KWayland::Server::ScreencastingSource source; | ||||
74 | 82 | | |||
75 | struct { | 83 | struct { | ||
76 | GLuint framebuffer = 0; | 84 | GLuint framebuffer = 0; | ||
77 | GLuint texture = 0; | 85 | GLuint texture = 0; | ||
78 | std::shared_ptr<GLVertexBuffer> vbo; | 86 | std::shared_ptr<GLVertexBuffer> vbo; | ||
79 | } render; | 87 | } render; | ||
80 | }; | 88 | }; | ||
81 | 89 | | |||
Show All 14 Lines | |||||
96 | void presentOnOutput(Output &output); | 104 | void presentOnOutput(Output &output); | ||
97 | 105 | | |||
98 | void removeOutput(DrmOutput *drmOutput); | 106 | void removeOutput(DrmOutput *drmOutput); | ||
99 | void cleanupOutput(Output &output); | 107 | void cleanupOutput(Output &output); | ||
100 | void cleanupFramebuffer(Output &output); | 108 | void cleanupFramebuffer(Output &output); | ||
101 | 109 | | |||
102 | DrmBackend *m_backend; | 110 | DrmBackend *m_backend; | ||
103 | QVector<Output> m_outputs; | 111 | QVector<Output> m_outputs; | ||
112 | QVector<ScreenCastStream*> m_streams; | ||||
104 | QScopedPointer<RemoteAccessManager> m_remoteaccessManager; | 113 | QScopedPointer<RemoteAccessManager> m_remoteaccessManager; | ||
105 | friend class EglGbmTexture; | 114 | friend class EglGbmTexture; | ||
106 | }; | 115 | }; | ||
107 | 116 | | |||
108 | /** | 117 | /** | ||
109 | * @brief Texture using an EGLImageKHR. | 118 | * @brief Texture using an EGLImageKHR. | ||
110 | */ | 119 | */ | ||
111 | class EglGbmTexture : public AbstractEglTexture | 120 | class EglGbmTexture : public AbstractEglTexture | ||
Show All 12 Lines |