[scenes/opengl] Merge window classes
Summary: Legacy OpenGL 1 compositing backend had been dropped quite a while ago so some of OpenGL scene classes can be merged back. Test Plan: Compiles, windows are rendered as before. Reviewers: #kwin, davidedmundson Reviewed By: #kwin, davidedmundson Subscribers: davidedmundson, kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D26700
This commit is contained in:
parent
1565910c40
commit
b8368fdf6f
2 changed files with 42 additions and 77 deletions
|
@ -1026,9 +1026,7 @@ void SceneOpenGL2::doPaintBackground(const QVector< float >& vertices)
|
||||||
|
|
||||||
Scene::Window *SceneOpenGL2::createWindow(Toplevel *t)
|
Scene::Window *SceneOpenGL2::createWindow(Toplevel *t)
|
||||||
{
|
{
|
||||||
SceneOpenGL2Window *w = new SceneOpenGL2Window(t);
|
return new OpenGLWindow(t, this);
|
||||||
w->setScene(this);
|
|
||||||
return w;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SceneOpenGL2::finalDrawWindow(EffectWindowImpl* w, int mask, QRegion region, WindowPaintData& data)
|
void SceneOpenGL2::finalDrawWindow(EffectWindowImpl* w, int mask, QRegion region, WindowPaintData& data)
|
||||||
|
@ -1058,22 +1056,22 @@ void SceneOpenGL2::performPaintWindow(EffectWindowImpl* w, int mask, QRegion reg
|
||||||
}
|
}
|
||||||
|
|
||||||
//****************************************
|
//****************************************
|
||||||
// SceneOpenGL::Window
|
// OpenGLWindow
|
||||||
//****************************************
|
//****************************************
|
||||||
|
|
||||||
SceneOpenGL::Window::Window(Toplevel* c)
|
OpenGLWindow::OpenGLWindow(Toplevel *toplevel, SceneOpenGL *scene)
|
||||||
: Scene::Window(c)
|
: Scene::Window(toplevel)
|
||||||
, m_scene(nullptr)
|
, m_scene(scene)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneOpenGL::Window::~Window()
|
OpenGLWindow::~OpenGLWindow()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
static SceneOpenGLTexture *s_frameTexture = nullptr;
|
static SceneOpenGLTexture *s_frameTexture = nullptr;
|
||||||
// Bind the window pixmap to an OpenGL texture.
|
// Bind the window pixmap to an OpenGL texture.
|
||||||
bool SceneOpenGL::Window::bindTexture()
|
bool OpenGLWindow::bindTexture()
|
||||||
{
|
{
|
||||||
s_frameTexture = nullptr;
|
s_frameTexture = nullptr;
|
||||||
OpenGLWindowPixmap *pixmap = windowPixmap<OpenGLWindowPixmap>();
|
OpenGLWindowPixmap *pixmap = windowPixmap<OpenGLWindowPixmap>();
|
||||||
|
@ -1091,12 +1089,12 @@ bool SceneOpenGL::Window::bindTexture()
|
||||||
return pixmap->bind();
|
return pixmap->bind();
|
||||||
}
|
}
|
||||||
|
|
||||||
QMatrix4x4 SceneOpenGL::Window::transformation(int mask, const WindowPaintData &data) const
|
QMatrix4x4 OpenGLWindow::transformation(int mask, const WindowPaintData &data) const
|
||||||
{
|
{
|
||||||
QMatrix4x4 matrix;
|
QMatrix4x4 matrix;
|
||||||
matrix.translate(x(), y());
|
matrix.translate(x(), y());
|
||||||
|
|
||||||
if (!(mask & PAINT_WINDOW_TRANSFORMED))
|
if (!(mask & Scene::PAINT_WINDOW_TRANSFORMED))
|
||||||
return matrix;
|
return matrix;
|
||||||
|
|
||||||
matrix.translate(data.translation());
|
matrix.translate(data.translation());
|
||||||
|
@ -1115,12 +1113,12 @@ QMatrix4x4 SceneOpenGL::Window::transformation(int mask, const WindowPaintData &
|
||||||
return matrix;
|
return matrix;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SceneOpenGL::Window::beginRenderWindow(int mask, const QRegion ®ion, WindowPaintData &data)
|
bool OpenGLWindow::beginRenderWindow(int mask, const QRegion ®ion, WindowPaintData &data)
|
||||||
{
|
{
|
||||||
if (region.isEmpty())
|
if (region.isEmpty())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
m_hardwareClipping = region != infiniteRegion() && (mask & PAINT_WINDOW_TRANSFORMED) && !(mask & PAINT_SCREEN_TRANSFORMED);
|
m_hardwareClipping = region != infiniteRegion() && (mask & Scene::PAINT_WINDOW_TRANSFORMED) && !(mask & Scene::PAINT_SCREEN_TRANSFORMED);
|
||||||
if (region != infiniteRegion() && !m_hardwareClipping) {
|
if (region != infiniteRegion() && !m_hardwareClipping) {
|
||||||
WindowQuadList quads;
|
WindowQuadList quads;
|
||||||
quads.reserve(data.quads.count());
|
quads.reserve(data.quads.count());
|
||||||
|
@ -1159,16 +1157,16 @@ bool SceneOpenGL::Window::beginRenderWindow(int mask, const QRegion ®ion, Win
|
||||||
|
|
||||||
// Update the texture filter
|
// Update the texture filter
|
||||||
if (waylandServer()) {
|
if (waylandServer()) {
|
||||||
filter = ImageFilterGood;
|
filter = Scene::ImageFilterGood;
|
||||||
s_frameTexture->setFilter(GL_LINEAR);
|
s_frameTexture->setFilter(GL_LINEAR);
|
||||||
} else {
|
} else {
|
||||||
if (options->glSmoothScale() != 0 &&
|
if (options->glSmoothScale() != 0 &&
|
||||||
(mask & (PAINT_WINDOW_TRANSFORMED | PAINT_SCREEN_TRANSFORMED)))
|
(mask & (Scene::PAINT_WINDOW_TRANSFORMED | Scene::PAINT_SCREEN_TRANSFORMED)))
|
||||||
filter = ImageFilterGood;
|
filter = Scene::ImageFilterGood;
|
||||||
else
|
else
|
||||||
filter = ImageFilterFast;
|
filter = Scene::ImageFilterFast;
|
||||||
|
|
||||||
s_frameTexture->setFilter(filter == ImageFilterGood ? GL_LINEAR : GL_NEAREST);
|
s_frameTexture->setFilter(filter == Scene::ImageFilterGood ? GL_LINEAR : GL_NEAREST);
|
||||||
}
|
}
|
||||||
|
|
||||||
const GLVertexAttrib attribs[] = {
|
const GLVertexAttrib attribs[] = {
|
||||||
|
@ -1183,14 +1181,14 @@ bool SceneOpenGL::Window::beginRenderWindow(int mask, const QRegion ®ion, Win
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SceneOpenGL::Window::endRenderWindow()
|
void OpenGLWindow::endRenderWindow()
|
||||||
{
|
{
|
||||||
if (m_hardwareClipping) {
|
if (m_hardwareClipping) {
|
||||||
glDisable(GL_SCISSOR_TEST);
|
glDisable(GL_SCISSOR_TEST);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GLTexture *SceneOpenGL::Window::getDecorationTexture() const
|
GLTexture *OpenGLWindow::getDecorationTexture() const
|
||||||
{
|
{
|
||||||
if (AbstractClient *client = dynamic_cast<AbstractClient *>(toplevel)) {
|
if (AbstractClient *client = dynamic_cast<AbstractClient *>(toplevel)) {
|
||||||
if (client->noBorder()) {
|
if (client->noBorder()) {
|
||||||
|
@ -1216,25 +1214,12 @@ GLTexture *SceneOpenGL::Window::getDecorationTexture() const
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
WindowPixmap* SceneOpenGL::Window::createWindowPixmap()
|
WindowPixmap *OpenGLWindow::createWindowPixmap()
|
||||||
{
|
{
|
||||||
return new OpenGLWindowPixmap(this, m_scene);
|
return new OpenGLWindowPixmap(this, m_scene);
|
||||||
}
|
}
|
||||||
|
|
||||||
//***************************************
|
QVector4D OpenGLWindow::modulate(float opacity, float brightness) const
|
||||||
// SceneOpenGL2Window
|
|
||||||
//***************************************
|
|
||||||
SceneOpenGL2Window::SceneOpenGL2Window(Toplevel *c)
|
|
||||||
: SceneOpenGL::Window(c)
|
|
||||||
, m_blendingEnabled(false)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
SceneOpenGL2Window::~SceneOpenGL2Window()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
QVector4D SceneOpenGL2Window::modulate(float opacity, float brightness) const
|
|
||||||
{
|
{
|
||||||
const float a = opacity;
|
const float a = opacity;
|
||||||
const float rgb = opacity * brightness;
|
const float rgb = opacity * brightness;
|
||||||
|
@ -1242,7 +1227,7 @@ QVector4D SceneOpenGL2Window::modulate(float opacity, float brightness) const
|
||||||
return QVector4D(rgb, rgb, rgb, a);
|
return QVector4D(rgb, rgb, rgb, a);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SceneOpenGL2Window::setBlendEnabled(bool enabled)
|
void OpenGLWindow::setBlendEnabled(bool enabled)
|
||||||
{
|
{
|
||||||
if (enabled && !m_blendingEnabled)
|
if (enabled && !m_blendingEnabled)
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
|
@ -1252,7 +1237,7 @@ void SceneOpenGL2Window::setBlendEnabled(bool enabled)
|
||||||
m_blendingEnabled = enabled;
|
m_blendingEnabled = enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SceneOpenGL2Window::setupLeafNodes(LeafNode *nodes, const WindowQuadList *quads, const WindowPaintData &data)
|
void OpenGLWindow::setupLeafNodes(LeafNode *nodes, const WindowQuadList *quads, const WindowPaintData &data)
|
||||||
{
|
{
|
||||||
if (!quads[ShadowLeaf].isEmpty()) {
|
if (!quads[ShadowLeaf].isEmpty()) {
|
||||||
nodes[ShadowLeaf].texture = static_cast<SceneOpenGLShadow *>(m_shadow)->shadowTexture();
|
nodes[ShadowLeaf].texture = static_cast<SceneOpenGLShadow *>(m_shadow)->shadowTexture();
|
||||||
|
@ -1289,7 +1274,7 @@ void SceneOpenGL2Window::setupLeafNodes(LeafNode *nodes, const WindowQuadList *q
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QMatrix4x4 SceneOpenGL2Window::modelViewProjectionMatrix(int mask, const WindowPaintData &data) const
|
QMatrix4x4 OpenGLWindow::modelViewProjectionMatrix(int mask, const WindowPaintData &data) const
|
||||||
{
|
{
|
||||||
SceneOpenGL2 *scene = static_cast<SceneOpenGL2 *>(m_scene);
|
SceneOpenGL2 *scene = static_cast<SceneOpenGL2 *>(m_scene);
|
||||||
|
|
||||||
|
@ -1313,7 +1298,7 @@ QMatrix4x4 SceneOpenGL2Window::modelViewProjectionMatrix(int mask, const WindowP
|
||||||
return scene->projectionMatrix() * mvMatrix;
|
return scene->projectionMatrix() * mvMatrix;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SceneOpenGL2Window::renderSubSurface(GLShader *shader, const QMatrix4x4 &mvp, const QMatrix4x4 &windowMatrix, OpenGLWindowPixmap *pixmap, const QRegion ®ion, bool hardwareClipping)
|
void OpenGLWindow::renderSubSurface(GLShader *shader, const QMatrix4x4 &mvp, const QMatrix4x4 &windowMatrix, OpenGLWindowPixmap *pixmap, const QRegion ®ion, bool hardwareClipping)
|
||||||
{
|
{
|
||||||
QMatrix4x4 newWindowMatrix = windowMatrix;
|
QMatrix4x4 newWindowMatrix = windowMatrix;
|
||||||
newWindowMatrix.translate(pixmap->subSurface()->position().x(), pixmap->subSurface()->position().y());
|
newWindowMatrix.translate(pixmap->subSurface()->position().x(), pixmap->subSurface()->position().y());
|
||||||
|
@ -1342,7 +1327,7 @@ void SceneOpenGL2Window::renderSubSurface(GLShader *shader, const QMatrix4x4 &mv
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SceneOpenGL2Window::performPaint(int mask, QRegion region, WindowPaintData data)
|
void OpenGLWindow::performPaint(int mask, QRegion region, WindowPaintData data)
|
||||||
{
|
{
|
||||||
if (!beginRenderWindow(mask, region, data))
|
if (!beginRenderWindow(mask, region, data))
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -43,7 +43,6 @@ class KWIN_EXPORT SceneOpenGL
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
class EffectFrame;
|
class EffectFrame;
|
||||||
class Window;
|
|
||||||
~SceneOpenGL() override;
|
~SceneOpenGL() override;
|
||||||
bool initFailed() const override;
|
bool initFailed() const override;
|
||||||
bool hasPendingFlush() const override;
|
bool hasPendingFlush() const override;
|
||||||
|
@ -143,34 +142,9 @@ private:
|
||||||
GLuint vao;
|
GLuint vao;
|
||||||
};
|
};
|
||||||
|
|
||||||
class SceneOpenGL::Window
|
|
||||||
: public Scene::Window
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
~Window() override;
|
|
||||||
bool beginRenderWindow(int mask, const QRegion ®ion, WindowPaintData &data);
|
|
||||||
void performPaint(int mask, QRegion region, WindowPaintData data) override = 0;
|
|
||||||
void endRenderWindow();
|
|
||||||
bool bindTexture();
|
|
||||||
void setScene(SceneOpenGL *scene) {
|
|
||||||
m_scene = scene;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected:
|
|
||||||
WindowPixmap* createWindowPixmap() override;
|
|
||||||
Window(Toplevel* c);
|
|
||||||
|
|
||||||
QMatrix4x4 transformation(int mask, const WindowPaintData &data) const;
|
|
||||||
GLTexture *getDecorationTexture() const;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
SceneOpenGL *m_scene;
|
|
||||||
bool m_hardwareClipping;
|
|
||||||
};
|
|
||||||
|
|
||||||
class OpenGLWindowPixmap;
|
class OpenGLWindowPixmap;
|
||||||
|
|
||||||
class SceneOpenGL2Window : public SceneOpenGL::Window
|
class OpenGLWindow final : public Scene::Window
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum Leaf { ShadowLeaf = 0, DecorationLeaf, ContentLeaf, PreviousContentLeaf, LeafCount };
|
enum Leaf { ShadowLeaf = 0, DecorationLeaf, ContentLeaf, PreviousContentLeaf, LeafCount };
|
||||||
|
@ -195,22 +169,28 @@ public:
|
||||||
TextureCoordinateType coordinateType;
|
TextureCoordinateType coordinateType;
|
||||||
};
|
};
|
||||||
|
|
||||||
explicit SceneOpenGL2Window(Toplevel *c);
|
OpenGLWindow(Toplevel *toplevel, SceneOpenGL *scene);
|
||||||
~SceneOpenGL2Window() override;
|
~OpenGLWindow() override;
|
||||||
|
|
||||||
protected:
|
WindowPixmap *createWindowPixmap() override;
|
||||||
|
void performPaint(int mask, QRegion region, WindowPaintData data) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
QMatrix4x4 transformation(int mask, const WindowPaintData &data) const;
|
||||||
|
GLTexture *getDecorationTexture() const;
|
||||||
QMatrix4x4 modelViewProjectionMatrix(int mask, const WindowPaintData &data) const;
|
QMatrix4x4 modelViewProjectionMatrix(int mask, const WindowPaintData &data) const;
|
||||||
QVector4D modulate(float opacity, float brightness) const;
|
QVector4D modulate(float opacity, float brightness) const;
|
||||||
void setBlendEnabled(bool enabled);
|
void setBlendEnabled(bool enabled);
|
||||||
void setupLeafNodes(LeafNode *nodes, const WindowQuadList *quads, const WindowPaintData &data);
|
void setupLeafNodes(LeafNode *nodes, const WindowQuadList *quads, const WindowPaintData &data);
|
||||||
void performPaint(int mask, QRegion region, WindowPaintData data) override;
|
void renderSubSurface(GLShader *shader, const QMatrix4x4 &mvp, const QMatrix4x4 &windowMatrix,
|
||||||
|
OpenGLWindowPixmap *pixmap, const QRegion ®ion, bool hardwareClipping);
|
||||||
|
bool beginRenderWindow(int mask, const QRegion ®ion, WindowPaintData &data);
|
||||||
|
void endRenderWindow();
|
||||||
|
bool bindTexture();
|
||||||
|
|
||||||
private:
|
SceneOpenGL *m_scene;
|
||||||
void renderSubSurface(GLShader *shader, const QMatrix4x4 &mvp, const QMatrix4x4 &windowMatrix, OpenGLWindowPixmap *pixmap, const QRegion ®ion, bool hardwareClipping);
|
bool m_hardwareClipping = false;
|
||||||
/**
|
bool m_blendingEnabled = false;
|
||||||
* Whether prepareStates enabled blending and restore states should disable again.
|
|
||||||
*/
|
|
||||||
bool m_blendingEnabled;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class OpenGLWindowPixmap : public WindowPixmap
|
class OpenGLWindowPixmap : public WindowPixmap
|
||||||
|
|
Loading…
Reference in a new issue