2017-09-08 20:30:18 +00:00
|
|
|
/********************************************************************
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
|
|
|
|
|
|
|
Copyright (C) 2006 Lubos Lunak <l.lunak@kde.org>
|
|
|
|
Copyright (C) 2009, 2010, 2011 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_SCENE_OPENGL_H
|
|
|
|
#define KWIN_SCENE_OPENGL_H
|
|
|
|
|
|
|
|
#include "scene.h"
|
|
|
|
#include "shadow.h"
|
|
|
|
|
|
|
|
#include "kwinglutils.h"
|
|
|
|
|
|
|
|
#include "decorations/decorationrenderer.h"
|
|
|
|
#include "platformsupport/scenes/opengl/backend.h"
|
|
|
|
|
|
|
|
namespace KWin
|
|
|
|
{
|
|
|
|
class LanczosFilter;
|
|
|
|
class OpenGLBackend;
|
|
|
|
class SyncManager;
|
|
|
|
class SyncObject;
|
|
|
|
|
|
|
|
class KWIN_EXPORT SceneOpenGL
|
|
|
|
: public Scene
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
class EffectFrame;
|
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
|
|
|
~SceneOpenGL() override;
|
|
|
|
bool initFailed() const override;
|
|
|
|
bool hasPendingFlush() const override;
|
2020-03-13 16:41:56 +00:00
|
|
|
qint64 paint(const QRegion &damage, const QList<Toplevel *> &windows) 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
|
|
|
Scene::EffectFrame *createEffectFrame(EffectFrameImpl *frame) override;
|
|
|
|
Shadow *createShadow(Toplevel *toplevel) override;
|
|
|
|
void screenGeometryChanged(const QSize &size) 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;
|
2020-01-09 17:06:14 +00:00
|
|
|
bool blocksForRetrace() const override;
|
2020-01-09 17:18:22 +00:00
|
|
|
bool syncsToVBlank() 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 makeOpenGLContextCurrent() override;
|
|
|
|
void doneOpenGLContextCurrent() override;
|
2017-09-08 20:30:18 +00:00
|
|
|
Decoration::Renderer *createDecorationRenderer(Decoration::DecoratedClientImpl *impl) 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
|
|
|
void triggerFence() override;
|
2017-09-08 20:30:18 +00:00
|
|
|
virtual QMatrix4x4 projectionMatrix() const = 0;
|
|
|
|
bool animationsSupported() const override;
|
|
|
|
|
|
|
|
void insertWait();
|
|
|
|
|
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 idle() override;
|
2017-09-08 20:30:18 +00:00
|
|
|
|
|
|
|
bool debug() const { return m_debug; }
|
|
|
|
void initDebugOutput();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Factory method to create a backend specific texture.
|
|
|
|
*
|
|
|
|
* @return :SceneOpenGL::Texture*
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2017-09-08 20:30:18 +00:00
|
|
|
SceneOpenGLTexture *createTexture();
|
|
|
|
|
|
|
|
OpenGLBackend *backend() const {
|
|
|
|
return m_backend;
|
|
|
|
}
|
|
|
|
|
|
|
|
QVector<QByteArray> openGLPlatformInterfaceExtensions() const override;
|
|
|
|
|
|
|
|
static SceneOpenGL *createScene(QObject *parent);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
SceneOpenGL(OpenGLBackend *backend, QObject *parent = nullptr);
|
2020-03-13 16:41:56 +00:00
|
|
|
void paintBackground(const QRegion ®ion) 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
|
|
|
void extendPaintRegion(QRegion ®ion, bool opaqueFullscreen) override;
|
2017-09-08 20:30:18 +00:00
|
|
|
QMatrix4x4 transformation(int mask, const ScreenPaintData &data) const;
|
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 paintDesktop(int desktop, int mask, const QRegion ®ion, ScreenPaintData &data) override;
|
[libkwineffects] Introduce API to easily show a QtQuick scene in an effect
Summary:
EffectQuickView/Scene is a convenient class to render a QtQuick
scenegraph into an effect.
Current methods (such as present windows) involve creating an underlying
platform window which is expensive, causes a headache to filter out
again in the rest of the code, and only works as an overlay.
The new class exposes things more natively to an effect where we don't
mess with real windows, we can perform the painting anywhere in the view
and we don't have issues with hiding/closing.
QtQuick has both software and hardware accelerated modes, and kwin also
has 3 render backends. Every combination is supported.
* When used in OpenGL mode for both, we render into an FBO export the
texture ID then it's up to the effect to render that into a scene.
* When using software QtQuick rendering we blit into an image, upload
that into a KWinGLTexture which serves as an abstraction layer and
render that into the scene.
* When using GL for QtQuick and XRender/QPainter in kwin everything is
rendered into the internal FBO, blit and exported as an image.
* When using software rendering for both an image gets passed directly.
Mouse and keyboard events can be forwarded, only if the effect
intercepts them.
The class is meant to be generic enough that we can remove all the
QtQuick code from Aurorae.
The intention is also to replace EffectFrameImpl using this backend and
we can kill all of the EffectFrame code throughout the scenes.
The close button in present windows will also be ported to this,
simplifiying that code base.
Classes that handle the rendering and handling QML are intentionally
split so that in the future we can have a declarative effects API create
overlays from within the same context. Similar to how one can
instantiate windows from a typical QML scene.
Notes:
I don't like how I pass the kwin GL context from the backends into the
effect, but I need something that works with the library separation. It
also currently has wayland problem if I create a QOpenGLContext before
the QPA is set up with a scene - but I don't have anything better?
I know for the EffectFrame we need an API to push things through the
effects stack to handle blur/invert etc. Will deal with that when we
port the EffectFrame.
Test Plan: Used in an effect
Reviewers: #kwin, zzag
Reviewed By: #kwin, zzag
Subscribers: zzag, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D24215
2019-09-27 15:06:37 +00:00
|
|
|
void paintEffectQuickView(EffectQuickView *w) override;
|
2017-09-08 20:30:18 +00:00
|
|
|
|
|
|
|
void handleGraphicsReset(GLenum status);
|
|
|
|
|
|
|
|
virtual void doPaintBackground(const QVector<float> &vertices) = 0;
|
|
|
|
virtual void updateProjectionMatrix() = 0;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
bool init_ok;
|
|
|
|
private:
|
|
|
|
bool viewportLimitsMatched(const QSize &size) const;
|
|
|
|
private:
|
|
|
|
bool m_debug;
|
|
|
|
OpenGLBackend *m_backend;
|
|
|
|
SyncManager *m_syncManager;
|
|
|
|
SyncObject *m_currentFence;
|
|
|
|
};
|
|
|
|
|
|
|
|
class SceneOpenGL2 : public SceneOpenGL
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
explicit SceneOpenGL2(OpenGLBackend *backend, QObject *parent = nullptr);
|
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
|
|
|
~SceneOpenGL2() override;
|
|
|
|
CompositingType compositingType() const override {
|
2017-09-08 20:30:18 +00:00
|
|
|
return OpenGL2Compositing;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool supported(OpenGLBackend *backend);
|
|
|
|
|
|
|
|
QMatrix4x4 projectionMatrix() const override { return m_projectionMatrix; }
|
|
|
|
QMatrix4x4 screenProjectionMatrix() const override { return m_screenProjectionMatrix; }
|
|
|
|
|
|
|
|
protected:
|
2020-03-13 16:41:56 +00:00
|
|
|
void paintSimpleScreen(int mask, const QRegion ®ion) override;
|
|
|
|
void paintGenericScreen(int mask, const ScreenPaintData &data) 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
|
|
|
void doPaintBackground(const QVector< float >& vertices) override;
|
|
|
|
Scene::Window *createWindow(Toplevel *t) override;
|
2020-03-13 16:41:56 +00:00
|
|
|
void finalDrawWindow(EffectWindowImpl* w, int mask, const QRegion ®ion, WindowPaintData& data) 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
|
|
|
void updateProjectionMatrix() override;
|
2017-09-08 20:30:18 +00:00
|
|
|
void paintCursor() override;
|
|
|
|
|
|
|
|
private:
|
2020-03-13 16:41:56 +00:00
|
|
|
void performPaintWindow(EffectWindowImpl* w, int mask, const QRegion ®ion, WindowPaintData& data);
|
2017-09-08 20:30:18 +00:00
|
|
|
QMatrix4x4 createProjectionMatrix() const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
LanczosFilter *m_lanczosFilter;
|
|
|
|
QScopedPointer<GLTexture> m_cursorTexture;
|
|
|
|
QMatrix4x4 m_projectionMatrix;
|
|
|
|
QMatrix4x4 m_screenProjectionMatrix;
|
|
|
|
GLuint vao;
|
|
|
|
};
|
|
|
|
|
2018-01-23 19:27:16 +00:00
|
|
|
class OpenGLWindowPixmap;
|
|
|
|
|
2020-01-15 21:18:28 +00:00
|
|
|
class OpenGLWindow final : public Scene::Window
|
2017-09-08 20:30:18 +00:00
|
|
|
{
|
2020-06-10 06:13:35 +00:00
|
|
|
Q_OBJECT
|
|
|
|
|
2017-09-08 20:30:18 +00:00
|
|
|
public:
|
2020-04-21 10:22:41 +00:00
|
|
|
enum Leaf { ShadowLeaf, DecorationLeaf, ContentLeaf, PreviousContentLeaf };
|
2017-09-08 20:30:18 +00:00
|
|
|
|
2020-04-21 10:22:41 +00:00
|
|
|
struct RenderNode
|
2017-09-08 20:30:18 +00:00
|
|
|
{
|
2020-04-21 10:22:41 +00:00
|
|
|
RenderNode()
|
|
|
|
: texture(nullptr)
|
|
|
|
, firstVertex(0)
|
|
|
|
, vertexCount(0)
|
|
|
|
, opacity(1.0)
|
|
|
|
, hasAlpha(false)
|
|
|
|
, coordinateType(UnnormalizedCoordinates)
|
2017-09-08 20:30:18 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
GLTexture *texture;
|
2020-04-21 10:22:41 +00:00
|
|
|
WindowQuadList quads;
|
2017-09-08 20:30:18 +00:00
|
|
|
int firstVertex;
|
|
|
|
int vertexCount;
|
|
|
|
float opacity;
|
|
|
|
bool hasAlpha;
|
|
|
|
TextureCoordinateType coordinateType;
|
2020-04-21 10:22:41 +00:00
|
|
|
Leaf leafType;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct RenderContext
|
|
|
|
{
|
|
|
|
QVector<RenderNode> renderNodes;
|
|
|
|
int shadowOffset = 0;
|
|
|
|
int decorationOffset = 0;
|
|
|
|
int contentOffset = 0;
|
|
|
|
int previousContentOffset = 0;
|
|
|
|
int quadCount = 0;
|
2017-09-08 20:30:18 +00:00
|
|
|
};
|
|
|
|
|
2020-01-15 21:18:28 +00:00
|
|
|
OpenGLWindow(Toplevel *toplevel, SceneOpenGL *scene);
|
|
|
|
~OpenGLWindow() override;
|
2017-09-08 20:30:18 +00:00
|
|
|
|
2020-01-15 21:18:28 +00:00
|
|
|
WindowPixmap *createWindowPixmap() override;
|
2020-03-13 16:41:56 +00:00
|
|
|
void performPaint(int mask, const QRegion ®ion, const WindowPaintData &data) override;
|
2020-01-15 21:18:28 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
QMatrix4x4 transformation(int mask, const WindowPaintData &data) const;
|
|
|
|
GLTexture *getDecorationTexture() const;
|
2017-09-08 20:30:18 +00:00
|
|
|
QMatrix4x4 modelViewProjectionMatrix(int mask, const WindowPaintData &data) const;
|
|
|
|
QVector4D modulate(float opacity, float brightness) const;
|
|
|
|
void setBlendEnabled(bool enabled);
|
2020-04-21 10:22:41 +00:00
|
|
|
void initializeRenderContext(RenderContext &context, const WindowPaintData &data);
|
2020-01-15 21:18:28 +00:00
|
|
|
bool beginRenderWindow(int mask, const QRegion ®ion, WindowPaintData &data);
|
|
|
|
void endRenderWindow();
|
|
|
|
bool bindTexture();
|
2017-09-08 20:30:18 +00:00
|
|
|
|
2020-01-15 21:18:28 +00:00
|
|
|
SceneOpenGL *m_scene;
|
|
|
|
bool m_hardwareClipping = false;
|
|
|
|
bool m_blendingEnabled = false;
|
2017-09-08 20:30:18 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class OpenGLWindowPixmap : public WindowPixmap
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
explicit OpenGLWindowPixmap(Scene::Window *window, SceneOpenGL *scene);
|
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
|
|
|
~OpenGLWindowPixmap() override;
|
2017-09-08 20:30:18 +00:00
|
|
|
SceneOpenGLTexture *texture() const;
|
|
|
|
bool bind();
|
|
|
|
bool isValid() const override;
|
|
|
|
protected:
|
2020-04-29 15:18:41 +00:00
|
|
|
WindowPixmap *createChild(const QPointer<KWaylandServer::SubSurfaceInterface> &subSurface) override;
|
2017-09-08 20:30:18 +00:00
|
|
|
private:
|
2020-04-29 15:18:41 +00:00
|
|
|
explicit OpenGLWindowPixmap(const QPointer<KWaylandServer::SubSurfaceInterface> &subSurface, WindowPixmap *parent, SceneOpenGL *scene);
|
2017-09-08 20:30:18 +00:00
|
|
|
QScopedPointer<SceneOpenGLTexture> m_texture;
|
|
|
|
SceneOpenGL *m_scene;
|
|
|
|
};
|
|
|
|
|
|
|
|
class SceneOpenGL::EffectFrame
|
|
|
|
: public Scene::EffectFrame
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
EffectFrame(EffectFrameImpl* frame, SceneOpenGL *scene);
|
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
|
|
|
~EffectFrame() override;
|
2017-09-08 20:30:18 +00:00
|
|
|
|
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 free() override;
|
|
|
|
void freeIconFrame() override;
|
|
|
|
void freeTextFrame() override;
|
|
|
|
void freeSelection() override;
|
2017-09-08 20:30:18 +00:00
|
|
|
|
2020-03-13 16:41:56 +00:00
|
|
|
void render(const QRegion ®ion, double opacity, double frameOpacity) override;
|
2017-09-08 20:30:18 +00:00
|
|
|
|
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 crossFadeIcon() override;
|
|
|
|
void crossFadeText() override;
|
2017-09-08 20:30:18 +00:00
|
|
|
|
|
|
|
static void cleanup();
|
|
|
|
|
|
|
|
private:
|
|
|
|
void updateTexture();
|
|
|
|
void updateTextTexture();
|
|
|
|
|
|
|
|
GLTexture *m_texture;
|
|
|
|
GLTexture *m_textTexture;
|
|
|
|
GLTexture *m_oldTextTexture;
|
|
|
|
QPixmap *m_textPixmap; // need to keep the pixmap around to workaround some driver problems
|
|
|
|
GLTexture *m_iconTexture;
|
|
|
|
GLTexture *m_oldIconTexture;
|
|
|
|
GLTexture *m_selectionTexture;
|
|
|
|
GLVertexBuffer *m_unstyledVBO;
|
|
|
|
SceneOpenGL *m_scene;
|
|
|
|
|
|
|
|
static GLTexture* m_unstyledTexture;
|
|
|
|
static QPixmap* m_unstyledPixmap; // need to keep the pixmap around to workaround some driver problems
|
|
|
|
static void updateUnstyledTexture(); // Update OpenGL unstyled frame texture
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @short OpenGL implementation of Shadow.
|
|
|
|
*
|
|
|
|
* This class extends Shadow by the Elements required for OpenGL rendering.
|
|
|
|
* @author Martin Gräßlin <mgraesslin@kde.org>
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2017-09-08 20:30:18 +00:00
|
|
|
class SceneOpenGLShadow
|
|
|
|
: public Shadow
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
explicit SceneOpenGLShadow(Toplevel *toplevel);
|
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
|
|
|
~SceneOpenGLShadow() override;
|
2017-09-08 20:30:18 +00:00
|
|
|
|
|
|
|
GLTexture *shadowTexture() {
|
|
|
|
return m_texture.data();
|
|
|
|
}
|
|
|
|
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 buildQuads() override;
|
|
|
|
bool prepareBackend() override;
|
2017-09-08 20:30:18 +00:00
|
|
|
private:
|
|
|
|
QSharedPointer<GLTexture> m_texture;
|
|
|
|
};
|
|
|
|
|
|
|
|
class SceneOpenGLDecorationRenderer : public Decoration::Renderer
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
enum class DecorationPart : int {
|
|
|
|
Left,
|
|
|
|
Top,
|
|
|
|
Right,
|
|
|
|
Bottom,
|
|
|
|
Count
|
|
|
|
};
|
|
|
|
explicit SceneOpenGLDecorationRenderer(Decoration::DecoratedClientImpl *client);
|
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
|
|
|
~SceneOpenGLDecorationRenderer() override;
|
2017-09-08 20:30:18 +00:00
|
|
|
|
|
|
|
void render() override;
|
|
|
|
void reparent(Deleted *deleted) override;
|
|
|
|
|
|
|
|
GLTexture *texture() {
|
|
|
|
return m_texture.data();
|
|
|
|
}
|
|
|
|
GLTexture *texture() const {
|
|
|
|
return m_texture.data();
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
void resizeTexture();
|
|
|
|
QScopedPointer<GLTexture> m_texture;
|
|
|
|
};
|
|
|
|
|
|
|
|
inline bool SceneOpenGL::hasPendingFlush() const
|
|
|
|
{
|
|
|
|
return m_backend->hasPendingFlush();
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool SceneOpenGL::usesOverlayWindow() const
|
|
|
|
{
|
|
|
|
return m_backend->usesOverlayWindow();
|
|
|
|
}
|
|
|
|
|
|
|
|
inline SceneOpenGLTexture* OpenGLWindowPixmap::texture() const
|
|
|
|
{
|
|
|
|
return m_texture.data();
|
|
|
|
}
|
|
|
|
|
|
|
|
class KWIN_EXPORT OpenGLFactory : public SceneFactory
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
Q_INTERFACES(KWin::SceneFactory)
|
|
|
|
Q_PLUGIN_METADATA(IID "org.kde.kwin.Scene" FILE "opengl.json")
|
|
|
|
|
|
|
|
public:
|
|
|
|
explicit OpenGLFactory(QObject *parent = nullptr);
|
|
|
|
~OpenGLFactory() override;
|
|
|
|
|
|
|
|
Scene *create(QObject *parent = nullptr) const override;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
#endif
|