Changeset View
Changeset View
Standalone View
Standalone View
plugins/platforms/wayland/egl_wayland_backend.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) 2013 Martin Gräßlin <mgraesslin@kde.org> | 5 | Copyright 2013 Martin Gräßlin <mgraesslin@kde.org> | ||
zzag: Unrelated change. | |||||
6 | Copyright 2019 Roman Gilg <subdiff@gmail.com> | ||||
6 | 7 | | |||
zzag: Shouldn't they be in chronological order? | |||||
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 | ||
Show All 10 Lines | |||||
25 | 26 | | |||
26 | class QTemporaryFile; | 27 | class QTemporaryFile; | ||
27 | struct wl_buffer; | 28 | struct wl_buffer; | ||
28 | struct wl_shm; | 29 | struct wl_shm; | ||
29 | 30 | | |||
30 | namespace KWin | 31 | namespace KWin | ||
31 | { | 32 | { | ||
32 | 33 | | |||
33 | namespace Wayland { | 34 | namespace Wayland | ||
35 | { | ||||
34 | class WaylandBackend; | 36 | class WaylandBackend; | ||
35 | } | 37 | class WaylandOutput; | ||
38 | class EglWaylandBackend; | ||||
39 | | ||||
40 | class EglWaylandOutput : public QObject | ||||
41 | { | ||||
42 | Q_OBJECT | ||||
43 | public: | ||||
44 | EglWaylandOutput(WaylandOutput *output, QObject *parent = nullptr); | ||||
45 | ~EglWaylandOutput() = default; | ||||
46 | | ||||
47 | bool init(EglWaylandBackend *backend); | ||||
48 | void updateSize(const QSize &size); | ||||
49 | | ||||
50 | private: | ||||
51 | WaylandOutput *m_waylandOutput; | ||||
52 | wl_egl_window *m_overlay = nullptr; | ||||
53 | EGLSurface m_eglSurface = EGL_NO_SURFACE; | ||||
54 | int m_bufferAge = 0; | ||||
55 | /** | ||||
56 | * @brief The damage history for the past 10 frames. | ||||
57 | */ | ||||
58 | QVector<QRegion> m_damageHistory; | ||||
59 | | ||||
60 | friend class EglWaylandBackend; | ||||
61 | }; | ||||
36 | 62 | | |||
37 | /** | 63 | /** | ||
38 | * @brief OpenGL Backend using Egl on a Wayland surface. | 64 | * @brief OpenGL Backend using Egl on a Wayland surface. | ||
39 | * | 65 | * | ||
40 | * This Backend is the basis for a session compositor running on top of a Wayland system compositor. | 66 | * This Backend is the basis for a session compositor running on top of a Wayland system compositor. | ||
41 | * It creates a Surface as large as the screen and maps it as a fullscreen shell surface on the | 67 | * It creates a Surface as large as the screen and maps it as a fullscreen shell surface on the | ||
42 | * system compositor. The OpenGL context is created on the Wayland surface, so for rendering X11 is | 68 | * system compositor. The OpenGL context is created on the Wayland surface, so for rendering X11 is | ||
43 | * not involved. | 69 | * not involved. | ||
44 | * | 70 | * | ||
45 | * Also in repainting the backend is currently still rather limited. Only supported mode is fullscreen | 71 | * Also in repainting the backend is currently still rather limited. Only supported mode is fullscreen | ||
46 | * repaints, which is obviously not optimal. Best solution is probably to go for buffer_age extension | 72 | * repaints, which is obviously not optimal. Best solution is probably to go for buffer_age extension | ||
47 | * and make it the only available solution next to fullscreen repaints. | 73 | * and make it the only available solution next to fullscreen repaints. | ||
48 | **/ | 74 | **/ | ||
49 | class EglWaylandBackend : public AbstractEglBackend | 75 | class EglWaylandBackend : public AbstractEglBackend | ||
50 | { | 76 | { | ||
51 | Q_OBJECT | 77 | Q_OBJECT | ||
52 | public: | 78 | public: | ||
53 | EglWaylandBackend(Wayland::WaylandBackend *b); | 79 | EglWaylandBackend(WaylandBackend *b); | ||
54 | virtual ~EglWaylandBackend(); | 80 | virtual ~EglWaylandBackend(); | ||
55 | virtual void screenGeometryChanged(const QSize &size); | 81 | void screenGeometryChanged(const QSize &size) override; | ||
56 | virtual SceneOpenGLTexturePrivate *createBackendTexture(SceneOpenGLTexture *texture) override; | 82 | SceneOpenGLTexturePrivate *createBackendTexture(SceneOpenGLTexture *texture) override; | ||
57 | virtual QRegion prepareRenderingFrame(); | 83 | QRegion prepareRenderingFrame() override; | ||
58 | virtual void endRenderingFrame(const QRegion &renderedRegion, const QRegion &damagedRegion); | 84 | QRegion prepareRenderingForScreen(int screenId) override; | ||
85 | void endRenderingFrame(const QRegion &renderedRegion, const QRegion &damagedRegion) override; | ||||
86 | void endRenderingFrameForScreen(int screenId, const QRegion &damage, const QRegion &damagedRegion) override; | ||||
59 | virtual bool usesOverlayWindow() const override; | 87 | virtual bool usesOverlayWindow() const override; | ||
88 | bool perScreenRendering() const override; | ||||
60 | void init() override; | 89 | void init() override; | ||
61 | 90 | | |||
62 | protected: | 91 | bool havePlatformBase() const { | ||
63 | virtual void present(); | 92 | return m_havePlatformBase; | ||
64 | 93 | } | |||
65 | private Q_SLOTS: | | |||
66 | void overlaySizeChanged(const QSize &size); | | |||
67 | 94 | | |||
68 | private: | 95 | private: | ||
69 | bool initializeEgl(); | 96 | bool initializeEgl(); | ||
70 | bool initBufferConfigs(); | 97 | bool initBufferConfigs(); | ||
71 | bool initRenderingContext(); | 98 | bool initRenderingContext(); | ||
72 | bool makeContextCurrent(); | 99 | | ||
73 | int m_bufferAge; | 100 | bool createEglWaylandOutput(WaylandOutput *output); | ||
74 | Wayland::WaylandBackend *m_wayland; | 101 | | ||
75 | wl_egl_window *m_overlay; | 102 | void cleanupSurfaces() override; | ||
103 | void cleanupOutput(EglWaylandOutput *output); | ||||
104 | | ||||
105 | bool makeContextCurrent(EglWaylandOutput *output); | ||||
106 | void present() override; | ||||
107 | void presentOnSurface(EglWaylandOutput *output); | ||||
108 | | ||||
109 | WaylandBackend *m_backend; | ||||
110 | QVector<EglWaylandOutput*> m_outputs; | ||||
76 | bool m_havePlatformBase; | 111 | bool m_havePlatformBase; | ||
77 | friend class EglWaylandTexture; | 112 | friend class EglWaylandTexture; | ||
78 | }; | 113 | }; | ||
79 | 114 | | |||
80 | /** | 115 | /** | ||
81 | * @brief Texture using an EGLImageKHR. | 116 | * @brief Texture using an EGLImageKHR. | ||
82 | **/ | 117 | **/ | ||
83 | class EglWaylandTexture : public AbstractEglTexture | 118 | class EglWaylandTexture : public AbstractEglTexture | ||
84 | { | 119 | { | ||
85 | public: | 120 | public: | ||
86 | virtual ~EglWaylandTexture(); | 121 | virtual ~EglWaylandTexture(); | ||
87 | 122 | | |||
88 | private: | 123 | private: | ||
89 | friend class EglWaylandBackend; | 124 | friend class EglWaylandBackend; | ||
90 | EglWaylandTexture(SceneOpenGLTexture *texture, EglWaylandBackend *backend); | 125 | EglWaylandTexture(SceneOpenGLTexture *texture, EglWaylandBackend *backend); | ||
91 | }; | 126 | }; | ||
92 | 127 | | |||
93 | } // namespace | 128 | } | ||
129 | } | ||||
94 | 130 | | |||
95 | #endif // KWIN_EGL_ON_X_BACKEND_H | 131 | #endif |
Unrelated change.