2012-08-26 15:14:23 +00:00
|
|
|
/********************************************************************
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
|
|
|
|
|
|
|
Copyright (C) 2012 Martin Gräßlin <mgraesslin@kde.org>
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*********************************************************************/
|
|
|
|
#ifndef KWIN_EGL_ON_X_BACKEND_H
|
|
|
|
#define KWIN_EGL_ON_X_BACKEND_H
|
2015-03-19 13:46:39 +00:00
|
|
|
#include "abstract_egl_backend.h"
|
2012-08-26 15:14:23 +00:00
|
|
|
#include "scene_opengl.h"
|
|
|
|
|
|
|
|
namespace KWin
|
|
|
|
{
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief OpenGL Backend using Egl windowing system over an X overlay window.
|
|
|
|
**/
|
2015-05-05 15:58:09 +00:00
|
|
|
class KWIN_EXPORT EglOnXBackend : public AbstractEglBackend
|
2012-08-26 15:14:23 +00:00
|
|
|
{
|
|
|
|
public:
|
2016-11-11 08:59:46 +00:00
|
|
|
EglOnXBackend(Display *display);
|
2015-05-05 13:35:12 +00:00
|
|
|
explicit EglOnXBackend(xcb_connection_t *connection, Display *display, xcb_window_t rootWindow, int screenNumber, xcb_window_t renderingWindow);
|
2012-08-26 15:14:23 +00:00
|
|
|
virtual ~EglOnXBackend();
|
|
|
|
virtual void screenGeometryChanged(const QSize &size);
|
|
|
|
virtual SceneOpenGL::TexturePrivate *createBackendTexture(SceneOpenGL::Texture *texture);
|
2013-11-21 09:39:29 +00:00
|
|
|
virtual QRegion prepareRenderingFrame();
|
2014-01-07 08:28:59 +00:00
|
|
|
virtual void endRenderingFrame(const QRegion &damage, const QRegion &damagedRegion);
|
2013-06-19 10:26:34 +00:00
|
|
|
virtual OverlayWindow* overlayWindow() override;
|
|
|
|
virtual bool usesOverlayWindow() const override;
|
2015-11-25 12:09:28 +00:00
|
|
|
void init() override;
|
2012-08-26 15:14:23 +00:00
|
|
|
|
2016-06-14 07:01:42 +00:00
|
|
|
bool isX11TextureFromPixmapSupported() const {
|
|
|
|
return m_x11TextureFromPixmapSupported;
|
|
|
|
}
|
|
|
|
|
2012-08-26 15:14:23 +00:00
|
|
|
protected:
|
2012-10-07 11:43:31 +00:00
|
|
|
virtual void present();
|
2015-11-25 12:32:36 +00:00
|
|
|
void presentSurface(EGLSurface surface, const QRegion &damage, const QRect &screenGeometry);
|
|
|
|
virtual bool createSurfaces();
|
|
|
|
EGLSurface createSurface(xcb_window_t window);
|
|
|
|
void setHavePlatformBase(bool have) {
|
|
|
|
m_havePlatformBase = have;
|
|
|
|
}
|
|
|
|
bool havePlatformBase() const {
|
|
|
|
return m_havePlatformBase;
|
|
|
|
}
|
|
|
|
bool makeContextCurrent(const EGLSurface &surface);
|
2012-08-26 15:14:23 +00:00
|
|
|
|
2016-06-14 07:01:42 +00:00
|
|
|
void setX11TextureFromPixmapSupported(bool set) {
|
|
|
|
m_x11TextureFromPixmapSupported = set;
|
|
|
|
}
|
|
|
|
|
2012-08-26 15:14:23 +00:00
|
|
|
private:
|
|
|
|
bool initBufferConfigs();
|
|
|
|
bool initRenderingContext();
|
2013-06-19 10:26:34 +00:00
|
|
|
/**
|
|
|
|
* @brief The OverlayWindow used by this Backend.
|
|
|
|
**/
|
|
|
|
OverlayWindow *m_overlayWindow;
|
2012-08-26 15:14:23 +00:00
|
|
|
int surfaceHasSubPost;
|
2013-11-21 09:44:06 +00:00
|
|
|
int m_bufferAge;
|
2015-03-19 10:26:53 +00:00
|
|
|
bool m_usesOverlayWindow;
|
|
|
|
xcb_connection_t *m_connection;
|
|
|
|
Display *m_x11Display;
|
|
|
|
xcb_window_t m_rootWindow;
|
|
|
|
int m_x11ScreenNumber;
|
2015-05-05 13:35:12 +00:00
|
|
|
xcb_window_t m_renderingWindow = XCB_WINDOW_NONE;
|
2015-11-25 12:32:36 +00:00
|
|
|
bool m_havePlatformBase = false;
|
2016-06-14 07:01:42 +00:00
|
|
|
bool m_x11TextureFromPixmapSupported = true;
|
2012-08-26 15:14:23 +00:00
|
|
|
friend class EglTexture;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Texture using an EGLImageKHR.
|
|
|
|
**/
|
2015-03-19 13:46:39 +00:00
|
|
|
class EglTexture : public AbstractEglTexture
|
2012-08-26 15:14:23 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual ~EglTexture();
|
|
|
|
virtual void onDamage();
|
2016-06-14 07:01:42 +00:00
|
|
|
bool loadTexture(WindowPixmap *pixmap) override;
|
2012-08-26 15:14:23 +00:00
|
|
|
|
|
|
|
private:
|
2016-06-14 07:01:42 +00:00
|
|
|
bool loadTexture(xcb_pixmap_t pix, const QSize &size);
|
2012-08-26 15:14:23 +00:00
|
|
|
friend class EglOnXBackend;
|
|
|
|
EglTexture(SceneOpenGL::Texture *texture, EglOnXBackend *backend);
|
2016-06-14 07:01:42 +00:00
|
|
|
EglOnXBackend *m_backend;
|
2012-08-26 15:14:23 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
#endif // KWIN_EGL_ON_X_BACKEND_H
|