Changeset View
Changeset View
Standalone View
Standalone View
plugins/platforms/x11/standalone/glxbackend.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_GLX_BACKEND_H | 20 | #ifndef KWIN_GLX_BACKEND_H | ||
21 | #define KWIN_GLX_BACKEND_H | 21 | #define KWIN_GLX_BACKEND_H | ||
22 | #include "backend.h" | 22 | #include "backend.h" | ||
23 | #include "texture.h" | 23 | #include "texture.h" | ||
24 | #include "swap_profiler.h" | | |||
25 | #include "x11eventfilter.h" | 24 | #include "x11eventfilter.h" | ||
26 | 25 | | |||
27 | #include <xcb/glx.h> | 26 | #include <xcb/glx.h> | ||
28 | #include <epoxy/glx.h> | 27 | #include <epoxy/glx.h> | ||
29 | #include <fixx11h.h> | 28 | #include <fixx11h.h> | ||
30 | #include <memory> | 29 | #include <memory> | ||
31 | 30 | | |||
32 | namespace KWin | 31 | namespace KWin | ||
33 | { | 32 | { | ||
34 | 33 | | |||
35 | // GLX_MESA_swap_interval | | |||
36 | using glXSwapIntervalMESA_func = int (*)(unsigned int interval); | | |||
37 | extern glXSwapIntervalMESA_func glXSwapIntervalMESA; | | |||
38 | | ||||
39 | class FBConfigInfo | 34 | class FBConfigInfo | ||
40 | { | 35 | { | ||
41 | public: | 36 | public: | ||
42 | GLXFBConfig fbconfig; | 37 | GLXFBConfig fbconfig; | ||
43 | int bind_texture_format; | 38 | int bind_texture_format; | ||
44 | int texture_targets; | 39 | int texture_targets; | ||
45 | int y_inverted; | 40 | int y_inverted; | ||
46 | int mipmap; | 41 | int mipmap; | ||
47 | }; | 42 | }; | ||
48 | 43 | | |||
49 | 44 | | |||
50 | // ------------------------------------------------------------------ | | |||
51 | | ||||
52 | | ||||
53 | class SwapEventFilter : public X11EventFilter | 45 | class SwapEventFilter : public X11EventFilter | ||
54 | { | 46 | { | ||
55 | public: | 47 | public: | ||
56 | SwapEventFilter(xcb_drawable_t drawable, xcb_glx_drawable_t glxDrawable); | 48 | SwapEventFilter(xcb_drawable_t drawable, xcb_glx_drawable_t glxDrawable); | ||
57 | bool event(xcb_generic_event_t *event) override; | 49 | bool event(xcb_generic_event_t *event) override; | ||
58 | 50 | | |||
59 | private: | 51 | private: | ||
60 | xcb_drawable_t m_drawable; | 52 | xcb_drawable_t m_drawable; | ||
Show All 12 Lines | 62 | public: | |||
73 | void screenGeometryChanged(const QSize &size) override; | 65 | void screenGeometryChanged(const QSize &size) override; | ||
74 | SceneOpenGLTexturePrivate *createBackendTexture(SceneOpenGLTexture *texture) override; | 66 | SceneOpenGLTexturePrivate *createBackendTexture(SceneOpenGLTexture *texture) override; | ||
75 | QRegion prepareRenderingFrame() override; | 67 | QRegion prepareRenderingFrame() override; | ||
76 | void endRenderingFrame(const QRegion &damage, const QRegion &damagedRegion) override; | 68 | void endRenderingFrame(const QRegion &damage, const QRegion &damagedRegion) override; | ||
77 | bool makeCurrent() override; | 69 | bool makeCurrent() override; | ||
78 | void doneCurrent() override; | 70 | void doneCurrent() override; | ||
79 | OverlayWindow* overlayWindow() const override; | 71 | OverlayWindow* overlayWindow() const override; | ||
80 | bool usesOverlayWindow() const override; | 72 | bool usesOverlayWindow() const override; | ||
73 | bool hasSwapEvent() const override; | ||||
81 | void init() override; | 74 | void init() override; | ||
82 | 75 | | |||
83 | protected: | 76 | protected: | ||
84 | void present() override; | 77 | void present() override; | ||
85 | 78 | | |||
86 | private: | 79 | private: | ||
87 | bool initBuffer(); | | |||
88 | bool checkVersion(); | 80 | bool checkVersion(); | ||
81 | | ||||
82 | bool initBuffer(); | ||||
89 | void initExtensions(); | 83 | void initExtensions(); | ||
90 | void waitSync(); | | |||
91 | bool initRenderingContext(); | 84 | bool initRenderingContext(); | ||
92 | bool initFbConfig(); | 85 | bool initFbConfig(); | ||
93 | void initVisualDepthHashTable(); | 86 | void initVisualDepthHashTable(); | ||
94 | void setSwapInterval(int interval); | 87 | | ||
88 | void setVsync(bool enable); | ||||
89 | void swap(); | ||||
90 | void copy(); | ||||
91 | | ||||
95 | Display *display() const { | 92 | Display *display() const { | ||
96 | return m_x11Display; | 93 | return m_x11Display; | ||
97 | } | 94 | } | ||
98 | 95 | | |||
99 | int visualDepth(xcb_visualid_t visual) const; | 96 | int visualDepth(xcb_visualid_t visual) const; | ||
100 | FBConfigInfo *infoForVisual(xcb_visualid_t visual); | 97 | FBConfigInfo *infoForVisual(xcb_visualid_t visual); | ||
101 | 98 | | |||
102 | /** | 99 | /** | ||
103 | * @brief The OverlayWindow used by this Backend. | 100 | * @brief The OverlayWindow used by this Backend. | ||
104 | */ | 101 | */ | ||
105 | OverlayWindow *m_overlayWindow; | 102 | OverlayWindow *m_overlayWindow; | ||
106 | Window window; | 103 | Window window; | ||
107 | GLXFBConfig fbconfig; | 104 | GLXFBConfig fbconfig; | ||
108 | GLXWindow glxWindow; | 105 | GLXWindow glxWindow; | ||
109 | GLXContext ctx; | 106 | GLXContext ctx; | ||
110 | QHash<xcb_visualid_t, FBConfigInfo *> m_fbconfigHash; | 107 | QHash<xcb_visualid_t, FBConfigInfo *> m_fbconfigHash; | ||
111 | QHash<xcb_visualid_t, int> m_visualDepthHash; | 108 | QHash<xcb_visualid_t, int> m_visualDepthHash; | ||
112 | std::unique_ptr<SwapEventFilter> m_swapEventFilter; | 109 | std::unique_ptr<SwapEventFilter> m_swapEventFilter; | ||
113 | int m_bufferAge; | 110 | int m_bufferAge; | ||
111 | | ||||
112 | bool m_haveOMLSyncControl = false; | ||||
114 | bool m_haveMESACopySubBuffer = false; | 113 | bool m_haveMESACopySubBuffer = false; | ||
115 | bool m_haveMESASwapControl = false; | | |||
116 | bool m_haveEXTSwapControl = false; | | |||
117 | bool m_haveSGISwapControl = false; | | |||
118 | bool m_haveINTELSwapEvent = false; | 114 | bool m_haveINTELSwapEvent = false; | ||
119 | bool haveSwapInterval = false; | 115 | | ||
120 | bool haveWaitSync = false; | | |||
121 | Display *m_x11Display; | 116 | Display *m_x11Display; | ||
122 | SwapProfiler m_swapProfiler; | | |||
123 | friend class GlxTexture; | 117 | friend class GlxTexture; | ||
124 | }; | 118 | }; | ||
125 | 119 | | |||
126 | /** | 120 | /** | ||
127 | * @brief Texture using an GLXPixmap. | 121 | * @brief Texture using an GLXPixmap. | ||
128 | */ | 122 | */ | ||
129 | class GlxTexture : public SceneOpenGLTexturePrivate | 123 | class GlxTexture : public SceneOpenGLTexturePrivate | ||
130 | { | 124 | { | ||
Show All 20 Lines |