2020-08-02 22:22:19 +00:00
|
|
|
/*
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
2012-08-26 15:14:23 +00:00
|
|
|
|
2020-08-02 22:22:19 +00:00
|
|
|
SPDX-FileCopyrightText: 2012 Martin Gräßlin <mgraesslin@kde.org>
|
2012-08-26 15:14:23 +00:00
|
|
|
|
2020-08-02 22:22:19 +00:00
|
|
|
SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
*/
|
2012-08-26 15:14:23 +00:00
|
|
|
#ifndef KWIN_GLX_BACKEND_H
|
|
|
|
#define KWIN_GLX_BACKEND_H
|
2017-09-08 20:30:18 +00:00
|
|
|
#include "backend.h"
|
|
|
|
#include "texture.h"
|
2014-08-07 12:16:35 +00:00
|
|
|
#include "x11eventfilter.h"
|
|
|
|
|
2015-01-08 06:12:20 +00:00
|
|
|
#include <xcb/glx.h>
|
2015-10-30 10:50:31 +00:00
|
|
|
#include <epoxy/glx.h>
|
2017-09-08 20:30:18 +00:00
|
|
|
#include <fixx11h.h>
|
2014-08-07 12:16:35 +00:00
|
|
|
#include <memory>
|
2012-08-26 15:14:23 +00:00
|
|
|
|
|
|
|
namespace KWin
|
|
|
|
{
|
|
|
|
|
2016-11-10 15:51:39 +00:00
|
|
|
// GLX_MESA_swap_interval
|
|
|
|
using glXSwapIntervalMESA_func = int (*)(unsigned int interval);
|
|
|
|
extern glXSwapIntervalMESA_func glXSwapIntervalMESA;
|
|
|
|
|
2012-08-26 15:14:23 +00:00
|
|
|
class FBConfigInfo
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
GLXFBConfig fbconfig;
|
|
|
|
int bind_texture_format;
|
|
|
|
int texture_targets;
|
|
|
|
int y_inverted;
|
|
|
|
int mipmap;
|
|
|
|
};
|
|
|
|
|
2014-08-07 12:16:35 +00:00
|
|
|
|
|
|
|
// ------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
class SwapEventFilter : public X11EventFilter
|
|
|
|
{
|
|
|
|
public:
|
2015-01-08 06:12:20 +00:00
|
|
|
SwapEventFilter(xcb_drawable_t drawable, xcb_glx_drawable_t glxDrawable);
|
2014-08-07 12:16:35 +00:00
|
|
|
bool event(xcb_generic_event_t *event) override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
xcb_drawable_t m_drawable;
|
2015-01-08 06:12:20 +00:00
|
|
|
xcb_glx_drawable_t m_glxDrawable;
|
2014-08-07 12:16:35 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2012-08-26 15:14:23 +00:00
|
|
|
/**
|
|
|
|
* @brief OpenGL Backend using GLX over an X overlay window.
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2012-08-26 15:14:23 +00:00
|
|
|
class GlxBackend : public OpenGLBackend
|
|
|
|
{
|
|
|
|
public:
|
2016-11-11 08:59:46 +00:00
|
|
|
GlxBackend(Display *display);
|
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
|
|
|
~GlxBackend() override;
|
|
|
|
void screenGeometryChanged(const QSize &size) override;
|
|
|
|
SceneOpenGLTexturePrivate *createBackendTexture(SceneOpenGLTexture *texture) override;
|
2020-11-09 14:31:26 +00:00
|
|
|
QRegion beginFrame(int screenId) override;
|
|
|
|
void endFrame(int screenId, const QRegion &damage, const QRegion &damagedRegion) 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 makeCurrent() override;
|
|
|
|
void doneCurrent() 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
|
|
|
|
|
|
|
private:
|
2020-11-18 13:14:36 +00:00
|
|
|
void present(const QRegion &damage);
|
2012-08-26 15:14:23 +00:00
|
|
|
bool initBuffer();
|
2016-11-10 14:07:15 +00:00
|
|
|
bool checkVersion();
|
2016-11-10 14:56:36 +00:00
|
|
|
void initExtensions();
|
2012-08-26 15:14:23 +00:00
|
|
|
bool initRenderingContext();
|
2013-03-11 15:16:05 +00:00
|
|
|
bool initFbConfig();
|
2014-09-03 16:43:45 +00:00
|
|
|
void initVisualDepthHashTable();
|
2020-01-09 17:18:22 +00:00
|
|
|
void setSwapInterval(int interval);
|
2016-11-11 08:59:46 +00:00
|
|
|
Display *display() const {
|
|
|
|
return m_x11Display;
|
|
|
|
}
|
2012-08-26 15:14:23 +00:00
|
|
|
|
2014-09-03 16:43:45 +00:00
|
|
|
int visualDepth(xcb_visualid_t visual) const;
|
2014-04-13 18:47:58 +00:00
|
|
|
FBConfigInfo *infoForVisual(xcb_visualid_t visual);
|
|
|
|
|
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;
|
2013-03-11 15:27:24 +00:00
|
|
|
Window window;
|
2013-03-11 15:05:47 +00:00
|
|
|
GLXFBConfig fbconfig;
|
2013-03-11 15:27:24 +00:00
|
|
|
GLXWindow glxWindow;
|
2013-03-11 15:05:47 +00:00
|
|
|
GLXContext ctx;
|
2014-04-13 18:47:58 +00:00
|
|
|
QHash<xcb_visualid_t, FBConfigInfo *> m_fbconfigHash;
|
2014-09-03 16:43:45 +00:00
|
|
|
QHash<xcb_visualid_t, int> m_visualDepthHash;
|
2014-08-07 12:16:35 +00:00
|
|
|
std::unique_ptr<SwapEventFilter> m_swapEventFilter;
|
2013-11-21 09:44:06 +00:00
|
|
|
int m_bufferAge;
|
2015-01-12 07:54:25 +00:00
|
|
|
bool m_haveMESACopySubBuffer = false;
|
|
|
|
bool m_haveMESASwapControl = false;
|
|
|
|
bool m_haveEXTSwapControl = false;
|
2020-01-09 17:18:25 +00:00
|
|
|
bool m_haveSGISwapControl = false;
|
2020-01-09 17:06:12 +00:00
|
|
|
bool m_haveINTELSwapEvent = false;
|
2016-11-11 08:59:46 +00:00
|
|
|
Display *m_x11Display;
|
2012-08-26 15:14:23 +00:00
|
|
|
friend class GlxTexture;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Texture using an GLXPixmap.
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2017-09-08 20:30:18 +00:00
|
|
|
class GlxTexture : public SceneOpenGLTexturePrivate
|
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
|
|
|
~GlxTexture() override;
|
|
|
|
void onDamage() override;
|
|
|
|
bool loadTexture(WindowPixmap *pixmap) override;
|
|
|
|
OpenGLBackend *backend() override;
|
2012-08-26 15:14:23 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
friend class GlxBackend;
|
2017-09-08 20:30:18 +00:00
|
|
|
GlxTexture(SceneOpenGLTexture *texture, GlxBackend *backend);
|
2015-02-11 10:00:12 +00:00
|
|
|
bool loadTexture(xcb_pixmap_t pix, const QSize &size, xcb_visualid_t visual);
|
2016-11-11 08:59:46 +00:00
|
|
|
Display *display() const {
|
|
|
|
return m_backend->m_x11Display;
|
|
|
|
}
|
2017-09-08 20:30:18 +00:00
|
|
|
SceneOpenGLTexture *q;
|
2012-08-26 15:14:23 +00:00
|
|
|
GlxBackend *m_backend;
|
|
|
|
GLXPixmap m_glxpixmap; // the glx pixmap the texture is bound to
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
#endif // KWIN_GLX_BACKEND_H
|