1/********************************************************************
2 KWin - the KDE window manager
3 This file is part of the KDE project.
4
5Copyright (C) 2012 Martin Gräßlin <mgraesslin@kde.org>
6
7This program is free software; you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published by
9the Free Software Foundation; either version 2 of the License, or
10(at your option) any later version.
11
12This program is distributed in the hope that it will be useful,
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along 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
24namespace KWin
25{
26
27/**
28 * @brief OpenGL Backend using Egl windowing system over an X overlay window.
29 **/
30class EglOnXBackend : public OpenGLBackend
31{
32public:
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
40protected:
41 virtual void present();
42
43private:
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 **/
59class EglTexture : public SceneOpenGL::TexturePrivate
60{
61public:
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
68private:
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