From 7bac2dd425af5f428f011bcd5880fc2d80c2619f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20H=C3=B6glund?= Date: Sun, 17 Mar 2013 12:16:08 +0100 Subject: [PATCH] kwin: Add new convenience methods in SceneOpenGL Add a paintRedirector() and a getDecorationTextures() method. These will be used in an upcoming commit. --- scene_opengl.cpp | 53 +++++++++++++++++++++++++++++++++++------------- scene_opengl.h | 3 ++- 2 files changed, 41 insertions(+), 15 deletions(-) diff --git a/scene_opengl.cpp b/scene_opengl.cpp index 26af03f321..47ed1c3c9a 100644 --- a/scene_opengl.cpp +++ b/scene_opengl.cpp @@ -1146,14 +1146,48 @@ void SceneOpenGL::Window::performPaint(int mask, QRegion region, WindowPaintData endRenderWindow(data); } -template + +OpenGLPaintRedirector *SceneOpenGL::Window::paintRedirector() const +{ + if (toplevel->isClient()) { + Client *client = static_cast(toplevel); + if (client->noBorder()) + return 0; + + return static_cast(client->decorationPaintRedirector()); + } + + if (toplevel->isDeleted()) { + Deleted *deleted = static_cast(toplevel); + if (deleted->noBorder()) + return 0; + + return static_cast(deleted->decorationPaintRedirector()); + } + + return 0; +} + +bool SceneOpenGL::Window::getDecorationTextures(GLTexture **textures) const +{ + OpenGLPaintRedirector *redirector = paintRedirector(); + if (!redirector) + return false; + + redirector->ensurePixmapsPainted(); + + textures[0] = redirector->leftRightTexture(); + textures[1] = redirector->topBottomTexture(); + + redirector->markAsRepainted(); + return true; +} + void SceneOpenGL::Window::paintDecorations(const WindowPaintData &data, const QRegion ®ion) { - T* t = static_cast(toplevel); - OpenGLPaintRedirector *redirector = static_cast(t->decorationPaintRedirector()); - if (t->noBorder() || !redirector) { + GLTexture *textures[2]; + if (!getDecorationTextures(textures)) return; - } WindowQuadList quads[2]; // left-right, top-bottom @@ -1173,20 +1207,11 @@ void SceneOpenGL::Window::paintDecorations(const WindowPaintData &data, const QR } } - redirector->ensurePixmapsPainted(); - - GLTexture *textures[2]; - textures[0] = redirector->leftRightTexture(); - textures[1] = redirector->topBottomTexture(); - TextureType type[] = { DecorationLeftRight, DecorationTopBottom }; for (int i = 0; i < 2; i++) paintDecoration(textures[i], type[i], region, data, quads[i]); - - redirector->markAsRepainted(); } - void SceneOpenGL::Window::paintDecoration(GLTexture *texture, TextureType type, const QRegion ®ion, const WindowPaintData &data, const WindowQuadList &quads) diff --git a/scene_opengl.h b/scene_opengl.h index 48222551c2..a07cf944a9 100644 --- a/scene_opengl.h +++ b/scene_opengl.h @@ -287,7 +287,8 @@ protected: bool m_hardwareClipping; private: - template + OpenGLPaintRedirector *paintRedirector() const; + bool getDecorationTextures(GLTexture **textures) const; void paintDecorations(const WindowPaintData &data, const QRegion ®ion); Texture *texture; };