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"
|
2017-09-08 20:30:18 +00:00
|
|
|
|
|
|
|
#include <xcb/xcb.h>
|
2012-08-26 15:14:23 +00:00
|
|
|
|
|
|
|
namespace KWin
|
|
|
|
{
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief OpenGL Backend using Egl windowing system over an X overlay window.
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
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);
|
Run clang-tidy with modernize-use-override check
Summary:
Currently code base of kwin can be viewed as two pieces. One is very
ancient, and the other one is more modern, which uses new C++ features.
The main problem with the ancient code is that it was written before
C++11 era. So, no override or final keywords, lambdas, etc.
Quite recently, KDE compiler settings were changed to show a warning if
a virtual method has missing override keyword. As you might have already
guessed, this fired back at us because of that ancient code. We had
about 500 new compiler warnings.
A "solution" was proposed to that problem - disable -Wno-suggest-override
and the other similar warning for clang. It's hard to call a solution
because those warnings are disabled not only for the old code, but also
for new. This is not what we want!
The main argument for not actually fixing the problem was that git
history will be screwed as well because of human factor. While good git
history is a very important thing, we should not go crazy about it and
block every change that somehow alters git history. git blame allows to
specify starting revision for a reason.
The other argument (human factor) can be easily solved by using tools
such as clang-tidy. clang-tidy is a clang-based linter for C++. It can
be used for various things, e.g. fixing coding style(e.g. add missing
braces to if statements, readability-braces-around-statements check),
or in our case add missing override keywords.
Test Plan: Compiles.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: davidedmundson, apol, romangg, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D22371
2019-07-22 16:52:26 +00:00
|
|
|
~EglOnXBackend() override;
|
|
|
|
void screenGeometryChanged(const QSize &size) override;
|
|
|
|
SceneOpenGLTexturePrivate *createBackendTexture(SceneOpenGLTexture *texture) override;
|
|
|
|
QRegion prepareRenderingFrame() override;
|
|
|
|
void endRenderingFrame(const QRegion &damage, const QRegion &damagedRegion) override;
|
2019-08-07 17:33:20 +00:00
|
|
|
OverlayWindow* overlayWindow() const override;
|
Run clang-tidy with modernize-use-override check
Summary:
Currently code base of kwin can be viewed as two pieces. One is very
ancient, and the other one is more modern, which uses new C++ features.
The main problem with the ancient code is that it was written before
C++11 era. So, no override or final keywords, lambdas, etc.
Quite recently, KDE compiler settings were changed to show a warning if
a virtual method has missing override keyword. As you might have already
guessed, this fired back at us because of that ancient code. We had
about 500 new compiler warnings.
A "solution" was proposed to that problem - disable -Wno-suggest-override
and the other similar warning for clang. It's hard to call a solution
because those warnings are disabled not only for the old code, but also
for new. This is not what we want!
The main argument for not actually fixing the problem was that git
history will be screwed as well because of human factor. While good git
history is a very important thing, we should not go crazy about it and
block every change that somehow alters git history. git blame allows to
specify starting revision for a reason.
The other argument (human factor) can be easily solved by using tools
such as clang-tidy. clang-tidy is a clang-based linter for C++. It can
be used for various things, e.g. fixing coding style(e.g. add missing
braces to if statements, readability-braces-around-statements check),
or in our case add missing override keywords.
Test Plan: Compiles.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: davidedmundson, apol, romangg, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D22371
2019-07-22 16:52:26 +00:00
|
|
|
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:
|
Run clang-tidy with modernize-use-override check
Summary:
Currently code base of kwin can be viewed as two pieces. One is very
ancient, and the other one is more modern, which uses new C++ features.
The main problem with the ancient code is that it was written before
C++11 era. So, no override or final keywords, lambdas, etc.
Quite recently, KDE compiler settings were changed to show a warning if
a virtual method has missing override keyword. As you might have already
guessed, this fired back at us because of that ancient code. We had
about 500 new compiler warnings.
A "solution" was proposed to that problem - disable -Wno-suggest-override
and the other similar warning for clang. It's hard to call a solution
because those warnings are disabled not only for the old code, but also
for new. This is not what we want!
The main argument for not actually fixing the problem was that git
history will be screwed as well because of human factor. While good git
history is a very important thing, we should not go crazy about it and
block every change that somehow alters git history. git blame allows to
specify starting revision for a reason.
The other argument (human factor) can be easily solved by using tools
such as clang-tidy. clang-tidy is a clang-based linter for C++. It can
be used for various things, e.g. fixing coding style(e.g. add missing
braces to if statements, readability-braces-around-statements check),
or in our case add missing override keywords.
Test Plan: Compiles.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: davidedmundson, apol, romangg, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D22371
2019-07-22 16:52:26 +00:00
|
|
|
void present() override;
|
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.
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2013-06-19 10:26:34 +00:00
|
|
|
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.
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2015-03-19 13:46:39 +00:00
|
|
|
class EglTexture : public AbstractEglTexture
|
2012-08-26 15:14:23 +00:00
|
|
|
{
|
|
|
|
public:
|
Run clang-tidy with modernize-use-override check
Summary:
Currently code base of kwin can be viewed as two pieces. One is very
ancient, and the other one is more modern, which uses new C++ features.
The main problem with the ancient code is that it was written before
C++11 era. So, no override or final keywords, lambdas, etc.
Quite recently, KDE compiler settings were changed to show a warning if
a virtual method has missing override keyword. As you might have already
guessed, this fired back at us because of that ancient code. We had
about 500 new compiler warnings.
A "solution" was proposed to that problem - disable -Wno-suggest-override
and the other similar warning for clang. It's hard to call a solution
because those warnings are disabled not only for the old code, but also
for new. This is not what we want!
The main argument for not actually fixing the problem was that git
history will be screwed as well because of human factor. While good git
history is a very important thing, we should not go crazy about it and
block every change that somehow alters git history. git blame allows to
specify starting revision for a reason.
The other argument (human factor) can be easily solved by using tools
such as clang-tidy. clang-tidy is a clang-based linter for C++. It can
be used for various things, e.g. fixing coding style(e.g. add missing
braces to if statements, readability-braces-around-statements check),
or in our case add missing override keywords.
Test Plan: Compiles.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: davidedmundson, apol, romangg, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D22371
2019-07-22 16:52:26 +00:00
|
|
|
~EglTexture() override;
|
|
|
|
void onDamage() override;
|
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;
|
2017-09-08 20:30:18 +00:00
|
|
|
EglTexture(SceneOpenGLTexture *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
|