| 1 | /* |
| 2 | KWin - the KDE window manager |
| 3 | This file is part of the KDE project. |
| 4 | |
| 5 | SPDX-FileCopyrightText: 2012 Martin Gräßlin <[email protected]> |
| 6 | |
| 7 | SPDX-License-Identifier: GPL-2.0-or-later |
| 8 | */ |
| 9 | #pragma once |
| 10 | #include "core/outputlayer.h"cxx . . $ `<file>/src/core/outputlayer.h`/ |
| 11 | #include "options.h"cxx . . $ `<file>/src/options.h`/ |
| 12 | #include "platformsupport/scenes/opengl/openglbackend.h"cxx . . $ `<file>/src/platformsupport/scenes/opengl/openglbackend.h`/ |
| 13 | #include "platformsupport/scenes/opengl/openglsurfacetexture_x11.h"cxx . . $ `<file>/src/platformsupport/scenes/opengl/openglsurfacetexture_x11.h`/ |
| 14 | #include "utils/damagejournal.h"cxx . . $ `<file>/src/utils/damagejournal.h`/ |
| 15 | #include "x11eventfilter.h"cxx . . $ `<file>/src/x11eventfilter.h`/ |
| 16 | |
| 17 | #include <epoxy/glx.h> |
| 18 | #include <fixx11h.h> |
| 19 | #include <xcb/glx.h> |
| 20 | |
| 21 | #include "opengl/gltexture.h"cxx . . $ `<file>/src/opengl/gltexture.h`/ |
| 22 | #include "opengl/gltexture_p.h"cxx . . $ `<file>/src/opengl/gltexture_p.h`/ |
| 23 | |
| 24 | #include <QHash> |
| 25 | #include <memory> |
| 26 | |
| 27 | namespace KWincxx . . $ KWin/ |
| 28 | { |
| 29 | |
| 30 | class GlxPixmapTexturePrivatecxx . . $ KWin/GlxPixmapTexturePrivate#; |
| 31 | class VsyncMonitorcxx . . $ KWin/VsyncMonitor#; |
| 32 | class X11StandaloneBackendcxx . . $ KWin/X11StandaloneBackend#; |
| 33 | class GlxBackendcxx . . $ KWin/GlxBackend#; |
| 34 | class GLRenderTimeQuerycxx . . $ KWin/GLRenderTimeQuery#; |
| 35 | class GlxContextcxx . . $ KWin/GlxContext#; |
| 36 | |
| 37 | class FBConfigInfocxx . . $ KWin/FBConfigInfo# |
| 38 | { |
| 39 | public: |
| 40 | GLXFBConfig fbconfigcxx . . $ KWin/FBConfigInfo#fbconfig.; |
| 41 | int bind_texture_formatcxx . . $ KWin/FBConfigInfo#bind_texture_format.; |
| 42 | int texture_targetscxx . . $ KWin/FBConfigInfo#texture_targets.; |
| 43 | int y_invertedcxx . . $ KWin/FBConfigInfo#y_inverted.; |
| 44 | int mipmapcxx . . $ KWin/FBConfigInfo#mipmap.; |
| 45 | }; |
| 46 | |
| 47 | // ------------------------------------------------------------------ |
| 48 | |
| 49 | class SwapEventFiltercxx . . $ KWin/SwapEventFilter# : public X11EventFiltercxx . . $ KWin/X11EventFilter# |
| 50 | { |
| 51 | public: |
| 52 | SwapEventFiltercxx . . $ KWin/SwapEventFilter#SwapEventFilter(bb0c7e0660bfe08).(GlxBackendcxx . . $ KWin/GlxBackend# *backend, xcb_drawable_t drawable, xcb_glx_drawable_t glxDrawable); |
| 53 | bool eventcxx . . $ KWin/SwapEventFilter#event(d862675781bb8f75).(xcb_generic_event_t *event) override; |
| 54 | |
| 55 | private: |
| 56 | GlxBackendcxx . . $ KWin/GlxBackend# *m_backendcxx . . $ KWin/SwapEventFilter#m_backend.; |
| 57 | xcb_drawable_t m_drawablecxx . . $ KWin/SwapEventFilter#m_drawable.; |
| 58 | xcb_glx_drawable_t m_glxDrawablecxx . . $ KWin/SwapEventFilter#m_glxDrawable.; |
| 59 | }; |
| 60 | |
| 61 | class GlxLayercxx . . $ KWin/GlxLayer# : public OutputLayercxx . . $ KWin/OutputLayer# |
| 62 | { |
| 63 | public: |
| 64 | GlxLayercxx . . $ KWin/GlxLayer#GlxLayer(d2639ff0ba0b0896).(GlxBackendcxx . . $ KWin/GlxBackend# *backend); |
| 65 | |
| 66 | stdcxx . . $ std/::optionalcxx . . $ std/optional#<OutputLayerBeginFrameInfocxx . . $ KWin/OutputLayerBeginFrameInfo#> doBeginFramecxx . . $ KWin/GlxLayer#doBeginFrame(f34062ec2930e73d).() override; |
| 67 | bool doEndFramecxx . . $ KWin/GlxLayer#doEndFrame(7ec1336dbcaeed6b).(const QRegioncxx . . $ QRegion# &renderedRegion, const QRegioncxx . . $ QRegion# &damagedRegion, OutputFramecxx . . $ KWin/OutputFrame# *frame) override; |
| 68 | DrmDevicecxx . . $ KWin/DrmDevice# *scanoutDevicecxx . . $ KWin/GlxLayer#scanoutDevice(8efad915dbd6b761).() const override; |
| 69 | QHashcxx . . $ QHash#<uint32_tcxx . . $ uint32_t#, QListcxx . . $ QList#<uint64_tcxx . . $ uint64_t#>> supportedDrmFormatscxx . . $ KWin/GlxLayer#supportedDrmFormats(3259d3b1b5628cf5).() const override; |
| 70 | |
| 71 | private: |
| 72 | GlxBackendcxx . . $ KWin/GlxBackend# *const m_backendcxx . . $ KWin/GlxLayer#m_backend.; |
| 73 | }; |
| 74 | |
| 75 | /** |
| 76 | * @brief OpenGL Backend using GLX over an X overlay window. |
| 77 | */ |
| 78 | class GlxBackendcxx . . $ KWin/GlxBackend# : public OpenGLBackendcxx . . $ KWin/OpenGLBackend# |
| 79 | { |
| 80 | Q_OBJECTcxx . . $ QMetaObject#Call# |
| 81 | |
| 82 | public: |
| 83 | GlxBackendcxx . . $ KWin/GlxBackend#GlxBackend(9fb7d843b20731f9).(::Displaycxx . . $ Display# *display, X11StandaloneBackendcxx . . $ KWin/X11StandaloneBackend# *backend); |
| 84 | ~cxx . . $ KWin/GlxBackend#`~GlxBackend`(ced63f7c635d850d).GlxBackendcxx . . $ KWin/GlxBackend#() override; |
| 85 | stdcxx . . $ std/::unique_ptrcxx . . $ std/unique_ptr#<SurfaceTexturecxx . . $ KWin/SurfaceTexture#> createSurfaceTextureX11cxx . . $ KWin/GlxBackend#createSurfaceTextureX11(9d8167ee6d825944).(SurfacePixmapX11cxx . . $ KWin/SurfacePixmapX11# *pixmap) override; |
| 86 | OutputLayerBeginFrameInfocxx . . $ KWin/OutputLayerBeginFrameInfo# doBeginFramecxx . . $ KWin/GlxBackend#doBeginFrame(551221ec73e56c7c).(); |
| 87 | void endFramecxx . . $ KWin/GlxBackend#endFrame(e698f916c28e0141).(const QRegioncxx . . $ QRegion# &renderedRegion, const QRegioncxx . . $ QRegion# &damagedRegion, OutputFramecxx . . $ KWin/OutputFrame# *frame); |
| 88 | bool presentcxx . . $ KWin/GlxBackend#present(9b48bd70b46193a3).(Outputcxx . . $ KWin/Output# *output, const stdcxx . . $ std/::shared_ptrcxx . . $ std/shared_ptr#<OutputFramecxx . . $ KWin/OutputFrame#> &frame) override; |
| 89 | bool makeCurrentcxx . . $ KWin/GlxBackend#makeCurrent(c9857a73d68e59ba).() override; |
| 90 | void doneCurrentcxx . . $ KWin/GlxBackend#doneCurrent(49f6e7a06ebc5aa8).() override; |
| 91 | OpenGlContextcxx . . $ KWin/OpenGlContext# *openglContextcxx . . $ KWin/GlxBackend#openglContext(564e1736c3c4c019).() const override; |
| 92 | OverlayWindowcxx . . $ KWin/OverlayWindow# *overlayWindowcxx . . $ KWin/GlxBackend#overlayWindow(457de2fb03980396).() const override; |
| 93 | void initcxx . . $ KWin/GlxBackend#init(49f6e7a06ebc5aa8).() override; |
| 94 | OutputLayercxx . . $ KWin/OutputLayer# *primaryLayercxx . . $ KWin/GlxBackend#primaryLayer(d7c6312df472d4e8).(Outputcxx . . $ KWin/Output# *output) override; |
| 95 | |
| 96 | ::Displaycxx . . $ Display# *displaycxx . . $ KWin/GlxBackend#display(972173443a6a9a20).() const |
| 97 | { |
| 98 | return m_x11Displaycxx . . $ KWin/GlxBackend#m_x11Display.; |
| 99 | } |
| 100 | |
| 101 | void vblankcxx . . $ KWin/GlxBackend#vblank(66113eeeb0427e41).(stdcxx . . $ std/::chronocxx . . $ std/chrono/::nanosecondscxx . . $ std/chrono/nanoseconds# timestamp); |
| 102 | |
| 103 | private: |
| 104 | void presentcxx . . $ KWin/GlxBackend#present(bd1064c840c6b6e8).(const QRegioncxx . . $ QRegion# &damage); |
| 105 | bool initBuffercxx . . $ KWin/GlxBackend#initBuffer(c9857a73d68e59ba).(); |
| 106 | bool checkVersioncxx . . $ KWin/GlxBackend#checkVersion(c9857a73d68e59ba).(); |
| 107 | void initExtensionscxx . . $ KWin/GlxBackend#initExtensions(49f6e7a06ebc5aa8).(); |
| 108 | bool initFbConfigcxx . . $ KWin/GlxBackend#initFbConfig(c9857a73d68e59ba).(); |
| 109 | void initVisualDepthHashTablecxx . . $ KWin/GlxBackend#initVisualDepthHashTable(49f6e7a06ebc5aa8).(); |
| 110 | void setSwapIntervalcxx . . $ KWin/GlxBackend#setSwapInterval(d4f767463ce0a6b3).(int interval); |
| 111 | void screenGeometryChangedcxx . . $ KWin/GlxBackend#screenGeometryChanged(49f6e7a06ebc5aa8).(); |
| 112 | |
| 113 | int visualDepthcxx . . $ KWin/GlxBackend#visualDepth(b89e35493f65ea2b).(xcb_visualid_t visual) const; |
| 114 | const FBConfigInfocxx . . $ KWin/FBConfigInfo# &infoForVisualcxx . . $ KWin/GlxBackend#infoForVisual(4084a195346c4c7c).(xcb_visualid_t visual); |
| 115 | |
| 116 | /** |
| 117 | * @brief The OverlayWindow used by this Backend. |
| 118 | */ |
| 119 | stdcxx . . $ std/::unique_ptrcxx . . $ std/unique_ptr#<OverlayWindowcxx . . $ KWin/OverlayWindow#> m_overlayWindowcxx . . $ KWin/GlxBackend#m_overlayWindow.; |
| 120 | ::Windowcxx . . $ Window# windowcxx . . $ KWin/GlxBackend#window.; |
| 121 | GLXFBConfig fbconfigcxx . . $ KWin/GlxBackend#fbconfig.; |
| 122 | GLXWindow glxWindowcxx . . $ KWin/GlxBackend#glxWindow.; |
| 123 | xcb_colormap_t m_colormapcxx . . $ KWin/GlxBackend#m_colormap.; |
| 124 | stdcxx . . $ std/::shared_ptrcxx . . $ std/shared_ptr#<GlxContextcxx . . $ KWin/GlxContext#> m_contextcxx . . $ KWin/GlxBackend#m_context.; |
| 125 | QHashcxx . . $ QHash#<xcb_visualid_t, FBConfigInfocxx . . $ KWin/FBConfigInfo#> m_fbconfigHashcxx . . $ KWin/GlxBackend#m_fbconfigHash.; |
| 126 | QHashcxx . . $ QHash#<xcb_visualid_t, int> m_visualDepthHashcxx . . $ KWin/GlxBackend#m_visualDepthHash.; |
| 127 | stdcxx . . $ std/::unique_ptrcxx . . $ std/unique_ptr#<SwapEventFiltercxx . . $ KWin/SwapEventFilter#> m_swapEventFiltercxx . . $ KWin/GlxBackend#m_swapEventFilter.; |
| 128 | stdcxx . . $ std/::unique_ptrcxx . . $ std/unique_ptr#<GLFramebuffercxx . . $ KWin/GLFramebuffer#> m_fbocxx . . $ KWin/GlxBackend#m_fbo.; |
| 129 | DamageJournalcxx . . $ KWin/DamageJournal# m_damageJournalcxx . . $ KWin/GlxBackend#m_damageJournal.; |
| 130 | QRegioncxx . . $ QRegion# m_lastRenderedRegioncxx . . $ KWin/GlxBackend#m_lastRenderedRegion.; |
| 131 | int m_bufferAgecxx . . $ KWin/GlxBackend#m_bufferAge.; |
| 132 | bool m_haveMESACopySubBuffercxx . . $ KWin/GlxBackend#m_haveMESACopySubBuffer. = false; |
| 133 | bool m_haveMESASwapControlcxx . . $ KWin/GlxBackend#m_haveMESASwapControl. = false; |
| 134 | bool m_haveEXTSwapControlcxx . . $ KWin/GlxBackend#m_haveEXTSwapControl. = false; |
| 135 | bool m_haveSGISwapControlcxx . . $ KWin/GlxBackend#m_haveSGISwapControl. = false; |
| 136 | ::Displaycxx . . $ Display# *m_x11Displaycxx . . $ KWin/GlxBackend#m_x11Display.; |
| 137 | X11StandaloneBackendcxx . . $ KWin/X11StandaloneBackend# *m_backendcxx . . $ KWin/GlxBackend#m_backend.; |
| 138 | stdcxx . . $ std/::unique_ptrcxx . . $ std/unique_ptr#<VsyncMonitorcxx . . $ KWin/VsyncMonitor#> m_vsyncMonitorcxx . . $ KWin/GlxBackend#m_vsyncMonitor.; |
| 139 | stdcxx . . $ std/::unique_ptrcxx . . $ std/unique_ptr#<GlxLayercxx . . $ KWin/GlxLayer#> m_layercxx . . $ KWin/GlxBackend#m_layer.; |
| 140 | stdcxx . . $ std/::unique_ptrcxx . . $ std/unique_ptr#<GLRenderTimeQuerycxx . . $ KWin/GLRenderTimeQuery#> m_querycxx . . $ KWin/GlxBackend#m_query.; |
| 141 | Optionscxx . . $ KWin/Options#::GlSwapStrategycxx . . $ KWin/Options#GlSwapStrategy# m_swapStrategycxx . . $ KWin/GlxBackend#m_swapStrategy. = Optionscxx . . $ KWin/Options#::AutoSwapStrategycxx . . $ KWin/Options#AutoSwapStrategy.; |
| 142 | stdcxx . . $ std/::shared_ptrcxx . . $ std/shared_ptr#<OutputFramecxx . . $ KWin/OutputFrame#> m_framecxx . . $ KWin/GlxBackend#m_frame.; |
| 143 | friend class GlxPixmapTexturecxx . . $ KWin/GlxPixmapTexture#; |
| 144 | }; |
| 145 | |
| 146 | class GlxPixmapTexturecxx . . $ KWin/GlxPixmapTexture# final : public GLTexturecxx . . $ KWin/GLTexture# |
| 147 | { |
| 148 | public: |
| 149 | explicit GlxPixmapTexturecxx . . $ KWin/GlxPixmapTexture#GlxPixmapTexture(d2639ff0ba0b0896).(GlxBackendcxx . . $ KWin/GlxBackend# *backend); |
| 150 | ~cxx . . $ KWin/GlxPixmapTexture#`~GlxPixmapTexture`(49f6e7a06ebc5aa8).GlxPixmapTexturecxx . . $ KWin/GlxPixmapTexture#(); |
| 151 | |
| 152 | bool createcxx . . $ KWin/GlxPixmapTexture#create(b99d850dffc4ca8a).(SurfacePixmapX11cxx . . $ KWin/SurfacePixmapX11# *texture); |
| 153 | |
| 154 | private: |
| 155 | void onDamagecxx . . $ KWin/GlxPixmapTexture#onDamage(49f6e7a06ebc5aa8).() override; |
| 156 | |
| 157 | GlxBackendcxx . . $ KWin/GlxBackend# *const m_backendcxx . . $ KWin/GlxPixmapTexture#m_backend.; |
| 158 | GLXPixmap m_glxPixmapcxx . . $ KWin/GlxPixmapTexture#m_glxPixmap.; |
| 159 | }; |
| 160 | |
| 161 | class GlxSurfaceTextureX11cxx . . $ KWin/GlxSurfaceTextureX11# final : public OpenGLSurfaceTextureX11cxx . . $ KWin/OpenGLSurfaceTextureX11# |
| 162 | { |
| 163 | public: |
| 164 | GlxSurfaceTextureX11cxx . . $ KWin/GlxSurfaceTextureX11#GlxSurfaceTextureX11(98339d6ccc4f28eb).(GlxBackendcxx . . $ KWin/GlxBackend# *backend, SurfacePixmapX11cxx . . $ KWin/SurfacePixmapX11# *pixmap); |
| 165 | |
| 166 | bool createcxx . . $ KWin/GlxSurfaceTextureX11#create(c9857a73d68e59ba).() override; |
| 167 | void updatecxx . . $ KWin/GlxSurfaceTextureX11#update(bd1064c840c6b6e8).(const QRegioncxx . . $ QRegion# ®ion) override; |
| 168 | }; |
| 169 | |
| 170 | } // namespace |