1 | /******************************************************************** |
2 | KWin - the KDE window manager |
3 | This file is part of the KDE project. |
4 | |
5 | Copyright (C) 2012 Martin Gräßlin <mgraesslin@kde.org> |
6 | |
7 | 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 | the Free Software Foundation; either version 2 of the License, or |
10 | (at your option) any later version. |
11 | |
12 | This program is distributed in the hope that it will be useful, |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | GNU General Public License for more details. |
16 | |
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/>. |
19 | *********************************************************************/ |
20 | #ifndef KWIN_GLX_BACKEND_H |
21 | #define KWIN_GLX_BACKEND_H |
22 | #include "scene_opengl.h" |
23 | |
24 | namespace KWin |
25 | { |
26 | |
27 | class FBConfigInfo |
28 | { |
29 | public: |
30 | GLXFBConfig fbconfig; |
31 | int bind_texture_format; |
32 | int texture_targets; |
33 | int y_inverted; |
34 | int mipmap; |
35 | }; |
36 | |
37 | /** |
38 | * @brief OpenGL Backend using GLX over an X overlay window. |
39 | **/ |
40 | class GlxBackend : public OpenGLBackend |
41 | { |
42 | public: |
43 | GlxBackend(); |
44 | virtual ~GlxBackend(); |
45 | virtual void screenGeometryChanged(const QSize &size); |
46 | virtual SceneOpenGL::TexturePrivate *createBackendTexture(SceneOpenGL::Texture *texture); |
47 | virtual QRegion prepareRenderingFrame(); |
48 | virtual void endRenderingFrame(const QRegion &renderedRegion, const QRegion &damagedRegion); |
49 | |
50 | protected: |
51 | virtual void present(); |
52 | |
53 | private: |
54 | void init(); |
55 | bool initBuffer(); |
56 | bool initDrawableConfigs(); |
57 | void waitSync(); |
58 | bool initRenderingContext(); |
59 | bool initFbConfig(); |
60 | void setSwapInterval(int interval); |
61 | |
62 | Window window; |
63 | FBConfigInfo fbcdrawableinfo[ 32 + 1 ]; |
64 | GLXFBConfig fbconfig; |
65 | GLXWindow glxWindow; |
66 | GLXContext ctx; |
67 | int m_bufferAge; |
68 | bool haveSwapInterval, haveWaitSync; |
69 | friend class GlxTexture; |
70 | }; |
71 | |
72 | /** |
73 | * @brief Texture using an GLXPixmap. |
74 | **/ |
75 | class GlxTexture : public SceneOpenGL::TexturePrivate |
76 | { |
77 | public: |
78 | virtual ~GlxTexture(); |
79 | virtual void onDamage(); |
80 | virtual void findTarget(); |
81 | virtual bool loadTexture(const Pixmap& pix, const QSize& size, int depth); |
82 | virtual OpenGLBackend *backend(); |
83 | |
84 | private: |
85 | friend class GlxBackend; |
86 | GlxTexture(SceneOpenGL::Texture *texture, GlxBackend *backend); |
87 | SceneOpenGL::Texture *q; |
88 | GlxBackend *m_backend; |
89 | GLXPixmap m_glxpixmap; // the glx pixmap the texture is bound to |
90 | }; |
91 | |
92 | } // namespace |
93 | #endif // KWIN_GLX_BACKEND_H |
94 | |