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_EGL_ON_X_BACKEND_H |
21 | #define KWIN_EGL_ON_X_BACKEND_H |
22 | #include "scene_opengl.h" |
23 | |
24 | namespace KWin |
25 | { |
26 | |
27 | /** |
28 | * @brief OpenGL Backend using Egl windowing system over an X overlay window. |
29 | **/ |
30 | class EglOnXBackend : public OpenGLBackend |
31 | { |
32 | public: |
33 | EglOnXBackend(); |
34 | virtual ~EglOnXBackend(); |
35 | virtual void screenGeometryChanged(const QSize &size); |
36 | virtual SceneOpenGL::TexturePrivate *createBackendTexture(SceneOpenGL::Texture *texture); |
37 | virtual QRegion prepareRenderingFrame(); |
38 | virtual void endRenderingFrame(const QRegion &renderedRegion, const QRegion &damagedRegion); |
39 | |
40 | protected: |
41 | virtual void present(); |
42 | |
43 | private: |
44 | void init(); |
45 | bool initBufferConfigs(); |
46 | bool initRenderingContext(); |
47 | EGLDisplay dpy; |
48 | EGLConfig config; |
49 | EGLSurface surface; |
50 | EGLContext ctx; |
51 | int surfaceHasSubPost; |
52 | int m_bufferAge; |
53 | friend class EglTexture; |
54 | }; |
55 | |
56 | /** |
57 | * @brief Texture using an EGLImageKHR. |
58 | **/ |
59 | class EglTexture : public SceneOpenGL::TexturePrivate |
60 | { |
61 | public: |
62 | virtual ~EglTexture(); |
63 | virtual void onDamage(); |
64 | virtual void findTarget(); |
65 | virtual bool loadTexture(const Pixmap& pix, const QSize& size, int depth); |
66 | virtual OpenGLBackend *backend(); |
67 | |
68 | private: |
69 | friend class EglOnXBackend; |
70 | EglTexture(SceneOpenGL::Texture *texture, EglOnXBackend *backend); |
71 | SceneOpenGL::Texture *q; |
72 | EglOnXBackend *m_backend; |
73 | EGLImageKHR m_image; |
74 | }; |
75 | |
76 | } // namespace |
77 | |
78 | #endif // KWIN_EGL_ON_X_BACKEND_H |
79 |