diff --git a/effects/blur/blur.cpp b/effects/blur/blur.cpp index 2b32b3a49c..9e46818c5a 100644 --- a/effects/blur/blur.cpp +++ b/effects/blur/blur.cpp @@ -443,7 +443,7 @@ void BlurEffect::doBlur(const QRegion& shape, const QRect& screen, const float o // Set up the texture matrix to transform from screen coordinates // to texture coordinates. #ifndef KWIN_HAVE_OPENGLES - if (!ShaderManager::instance()->isValid()) { + if (effects->compositingType() == OpenGL1Compositing) { glMatrixMode(GL_TEXTURE); pushMatrix(); } @@ -485,7 +485,7 @@ void BlurEffect::doBlur(const QRegion& shape, const QRect& screen, const float o drawRegion(shape); #ifndef KWIN_HAVE_OPENGLES - if (!ShaderManager::instance()->isValid()) { + if (effects->compositingType() == OpenGL1Compositing) { popMatrix(); glMatrixMode(GL_MODELVIEW); } @@ -532,7 +532,7 @@ void BlurEffect::doCachedBlur(EffectWindow *w, const QRegion& region, const floa QMatrix4x4 textureMatrix; QMatrix4x4 modelViewProjectionMatrix; #ifndef KWIN_HAVE_OPENGLES - if (!ShaderManager::instance()->isValid()) { + if (effects->compositingType() == OpenGL1Compositing) { glMatrixMode(GL_MODELVIEW); pushMatrix(); glLoadIdentity(); @@ -604,7 +604,7 @@ void BlurEffect::doCachedBlur(EffectWindow *w, const QRegion& region, const floa textureMatrix.scale(1.0 / tex.width(), -1.0 / tex.height(), 1); textureMatrix.translate(-updateRect.x(), -updateRect.height() - updateRect.y(), 0); #ifndef KWIN_HAVE_OPENGLES - if (!ShaderManager::instance()->isValid()) { + if (effects->compositingType() == OpenGL1Compositing) { glMatrixMode(GL_TEXTURE); loadMatrix(textureMatrix); glMatrixMode(GL_PROJECTION); @@ -645,7 +645,7 @@ void BlurEffect::doCachedBlur(EffectWindow *w, const QRegion& region, const floa textureMatrix.scale(1.0 / targetTexture.width(), -1.0 / targetTexture.height(), 1); textureMatrix.translate(-r.x(), -targetTexture.height() - r.y(), 0); #ifndef KWIN_HAVE_OPENGLES - if (!ShaderManager::instance()->isValid()) { + if (effects->compositingType() == OpenGL1Compositing) { glMatrixMode(GL_TEXTURE); loadMatrix(textureMatrix); glMatrixMode(GL_PROJECTION); @@ -656,7 +656,7 @@ void BlurEffect::doCachedBlur(EffectWindow *w, const QRegion& region, const floa drawRegion(blurredRegion & region); #ifndef KWIN_HAVE_OPENGLES - if (!ShaderManager::instance()->isValid()) { + if (effects->compositingType() == OpenGL1Compositing) { popMatrix(); glMatrixMode(GL_TEXTURE); popMatrix(); diff --git a/effects/blur/blurshader.cpp b/effects/blur/blurshader.cpp index 1564c5a7f2..71d138cd47 100644 --- a/effects/blur/blurshader.cpp +++ b/effects/blur/blurshader.cpp @@ -129,7 +129,7 @@ bool GLSLBlurShader::supported() { if (!GLPlatform::instance()->supports(GLSL)) return false; - if (!ShaderManager::instance()->isValid()) + if (effects->compositingType() == OpenGL1Compositing) return false; (void) glGetError(); // Clear the error state diff --git a/effects/coverswitch/coverswitch.cpp b/effects/coverswitch/coverswitch.cpp index 496bda2763..3f6592687d 100644 --- a/effects/coverswitch/coverswitch.cpp +++ b/effects/coverswitch/coverswitch.cpp @@ -261,7 +261,7 @@ void CoverSwitchEffect::paintScreen(int mask, QRegion region, ScreenPaintData& d if (reflection) { // no reflections during start and stop animation // except when using a shader - if ((!start && !stop) || ShaderManager::instance()->isValid()) + if ((!start && !stop) || effects->compositingType() == OpenGL2Compositing) paintScene(frontWindow, leftWindows, rightWindows, true); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); @@ -736,7 +736,7 @@ void CoverSwitchEffect::paintWindowCover(EffectWindow* w, bool reflectedWindow, } if (reflectedWindow) { - if (ShaderManager::instance()->isValid()) { + if (effects->compositingType() == OpenGL2Compositing) { GLShader *shader = ShaderManager::instance()->pushShader(ShaderManager::GenericShader); QMatrix4x4 origMatrix = shader->getUniformMatrix4x4("screenTransformation"); QMatrix4x4 reflectionMatrix; diff --git a/effects/cube/cube.cpp b/effects/cube/cube.cpp index 392ae54f13..da594db957 100644 --- a/effects/cube/cube.cpp +++ b/effects/cube/cube.cpp @@ -213,7 +213,7 @@ void CubeEffect::loadConfig(QString config) } // set the cap color on the shader - if (ShaderManager::instance()->isValid() && m_capShader->isValid()) { + if (effects->compositingType() == OpenGL2Compositing && m_capShader->isValid()) { ShaderManager::instance()->pushShader(m_capShader); m_capShader->setUniform("u_capColor", capColor); ShaderManager::instance()->popShader(); @@ -404,13 +404,13 @@ void CubeEffect::paintScreen(int mask, QRegion region, ScreenPaintData& data) // wallpaper if (wallpaper) { - if (ShaderManager::instance()->isValid()) { + if (effects->compositingType() == OpenGL2Compositing) { ShaderManager::instance()->pushShader(ShaderManager::SimpleShader); } wallpaper->bind(); wallpaper->render(region, rect); wallpaper->unbind(); - if (ShaderManager::instance()->isValid()) { + if (effects->compositingType() == OpenGL2Compositing) { ShaderManager::instance()->popShader(); } } @@ -599,7 +599,7 @@ void CubeEffect::paintScreen(int mask, QRegion region, ScreenPaintData& data) } // restore the ScreenTransformation after all desktops are painted // if not done GenericShader keeps the rotation data and transforms windows incorrectly in other rendering calls - if (ShaderManager::instance()->isValid()) { + if (effects->compositingType() == OpenGL2Compositing) { GLShader *shader = ShaderManager::instance()->pushShader(KWin::ShaderManager::GenericShader); shader->setUniform(GLShader::ScreenTransformation, QMatrix4x4()); ShaderManager::instance()->popShader(); @@ -786,7 +786,7 @@ void CubeEffect::paintCap(bool frontFirst, float zOffset) } bool capShader = false; - if (ShaderManager::instance()->isValid() && m_capShader->isValid()) { + if (effects->compositingType() == OpenGL2Compositing && m_capShader->isValid()) { capShader = true; ShaderManager::instance()->pushShader(m_capShader); float opacity = cubeOpacity; @@ -1560,7 +1560,7 @@ void CubeEffect::paintWindow(EffectWindow* w, int mask, QRegion region, WindowPa } } bool capShader = false; - if (ShaderManager::instance()->isValid() && m_capShader->isValid()) { + if (effects->compositingType() == OpenGL2Compositing && m_capShader->isValid()) { capShader = true; ShaderManager::instance()->pushShader(m_capShader); m_capShader->setUniform("u_mirror", 0); diff --git a/effects/explosion/explosion.cpp b/effects/explosion/explosion.cpp index adf9bc3695..63be488fce 100644 --- a/effects/explosion/explosion.cpp +++ b/effects/explosion/explosion.cpp @@ -66,9 +66,6 @@ bool ExplosionEffect::supported() bool ExplosionEffect::loadData() { mInited = true; - if (!ShaderManager::instance()->isValid()) { - return false; - } QString shadername("explosion"); const QString fragmentshader = KGlobal::dirs()->findResource("data", "kwin/explosion.frag"); QString starttexture = KGlobal::dirs()->findResource("data", "kwin/explosion-start.png"); diff --git a/effects/invert/invert.cpp b/effects/invert/invert.cpp index 80fa1dea36..327d24e835 100644 --- a/effects/invert/invert.cpp +++ b/effects/invert/invert.cpp @@ -70,9 +70,6 @@ bool InvertEffect::supported() bool InvertEffect::loadData() { m_inited = true; - if (!ShaderManager::instance()->isValid()) { - return false; - } const QString fragmentshader = KGlobal::dirs()->findResource("data", "kwin/invert.frag"); diff --git a/effects/logout/logout.cpp b/effects/logout/logout.cpp index 450bab5fc2..2c068e251e 100644 --- a/effects/logout/logout.cpp +++ b/effects/logout/logout.cpp @@ -288,7 +288,7 @@ bool LogoutEffect::isLogoutDialog(EffectWindow* w) void LogoutEffect::renderVignetting() { - if (!ShaderManager::instance()->isValid()) { + if (effects->compositingType() == OpenGL1Compositing) { renderVignettingLegacy(); return; } @@ -369,7 +369,7 @@ void LogoutEffect::renderVignettingLegacy() void LogoutEffect::renderBlurTexture() { - if (!ShaderManager::instance()->isValid()) { + if (effects->compositingType() == OpenGL1Compositing) { renderBlurTextureLegacy(); return; } diff --git a/effects/magnifier/magnifier.cpp b/effects/magnifier/magnifier.cpp index 69f3dafdf9..50fdcc5d52 100644 --- a/effects/magnifier/magnifier.cpp +++ b/effects/magnifier/magnifier.cpp @@ -168,11 +168,11 @@ void MagnifierEffect::paintScreen(int mask, QRegion region, ScreenPaintData& dat verts << area.right() + FRAME_WIDTH << area.bottom() + FRAME_WIDTH; verts << area.right() + FRAME_WIDTH << area.bottom() + 1; vbo->setData(verts.size() / 2, 2, verts.constData(), NULL); - if (ShaderManager::instance()->isValid()) { + if (effects->compositingType() == OpenGL2Compositing) { ShaderManager::instance()->pushShader(ShaderManager::ColorShader); } vbo->render(GL_TRIANGLES); - if (ShaderManager::instance()->isValid()) { + if (effects->compositingType() == OpenGL2Compositing) { ShaderManager::instance()->popShader(); } } diff --git a/effects/mousemark/mousemark.cpp b/effects/mousemark/mousemark.cpp index 44d83e1585..5c032e83eb 100644 --- a/effects/mousemark/mousemark.cpp +++ b/effects/mousemark/mousemark.cpp @@ -116,7 +116,7 @@ void MouseMarkEffect::paintScreen(int mask, QRegion region, ScreenPaintData& dat vbo->reset(); vbo->setUseColor(true); vbo->setColor(color); - if (ShaderManager::instance()->isValid()) { + if (effects->compositingType() == OpenGL2Compositing) { ShaderManager::instance()->pushShader(ShaderManager::ColorShader); } QVector verts; @@ -138,7 +138,7 @@ void MouseMarkEffect::paintScreen(int mask, QRegion region, ScreenPaintData& dat vbo->setData(verts.size() / 2, 2, verts.data(), NULL); vbo->render(GL_LINE_STRIP); } - if (ShaderManager::instance()->isValid()) { + if (effects->compositingType() == OpenGL2Compositing) { ShaderManager::instance()->popShader(); } glLineWidth(1.0); diff --git a/effects/resize/resize.cpp b/effects/resize/resize.cpp index 625a9c40d9..5a4715f6f0 100644 --- a/effects/resize/resize.cpp +++ b/effects/resize/resize.cpp @@ -86,7 +86,7 @@ void ResizeEffect::paintWindow(EffectWindow* w, int mask, QRegion region, Window GLVertexBuffer *vbo = GLVertexBuffer::streamingBuffer(); vbo->reset(); vbo->setUseColor(true); - if (ShaderManager::instance()->isValid()) { + if (effects->compositingType() == OpenGL2Compositing) { ShaderManager::instance()->pushShader(ShaderManager::ColorShader); } glEnable(GL_BLEND); @@ -105,7 +105,7 @@ void ResizeEffect::paintWindow(EffectWindow* w, int mask, QRegion region, Window } vbo->setData(verts.count() / 2, 2, verts.data(), NULL); vbo->render(GL_TRIANGLES); - if (ShaderManager::instance()->isValid()) { + if (effects->compositingType() == OpenGL2Compositing) { ShaderManager::instance()->popShader(); } glDisable(GL_BLEND); diff --git a/effects/showfps/showfps.cpp b/effects/showfps/showfps.cpp index 56df8b2bf2..5914f3923f 100644 --- a/effects/showfps/showfps.cpp +++ b/effects/showfps/showfps.cpp @@ -176,7 +176,7 @@ void ShowFpsEffect::paintGL(int fps) glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // TODO painting first the background white and then the contents // means that the contents also blend with the background, I guess - if (ShaderManager::instance()->isValid()) { + if (effects->compositingType() == OpenGL2Compositing) { ShaderManager::instance()->pushShader(ShaderManager::ColorShader); } GLVertexBuffer *vbo = GLVertexBuffer::streamingBuffer(); @@ -228,7 +228,7 @@ void ShowFpsEffect::paintGL(int fps) // Paint amount of rendered pixels graph paintDrawSizeGraph(x, y); - if (ShaderManager::instance()->isValid()) { + if (effects->compositingType() == OpenGL2Compositing) { ShaderManager::instance()->popShader(); } @@ -449,12 +449,12 @@ void ShowFpsEffect::paintFPSText(int fps) delete fpsText; fpsText = new GLTexture(im); fpsText->bind(); - if (ShaderManager::instance()->isValid()) { + if (effects->compositingType() == OpenGL2Compositing) { GLShader *shader = ShaderManager::instance()->pushShader(ShaderManager::SimpleShader); shader->setUniform("offset", QVector2D(0, 0)); } fpsText->render(QRegion(fpsTextRect), fpsTextRect); - if (ShaderManager::instance()->isValid()) { + if (effects->compositingType() == OpenGL2Compositing) { ShaderManager::instance()->popShader(); } fpsText->unbind(); diff --git a/effects/showpaint/showpaint.cpp b/effects/showpaint/showpaint.cpp index 5e33fb67c2..ef475aaf3e 100644 --- a/effects/showpaint/showpaint.cpp +++ b/effects/showpaint/showpaint.cpp @@ -76,7 +76,7 @@ void ShowPaintEffect::paintGL() GLVertexBuffer *vbo = GLVertexBuffer::streamingBuffer(); vbo->reset(); vbo->setUseColor(true); - if (ShaderManager::instance()->isValid()) { + if (effects->compositingType() == OpenGL2Compositing) { ShaderManager::instance()->pushShader(ShaderManager::ColorShader); } glEnable(GL_BLEND); @@ -96,7 +96,7 @@ void ShowPaintEffect::paintGL() } vbo->setData(verts.count() / 2, 2, verts.data(), NULL); vbo->render(GL_TRIANGLES); - if (ShaderManager::instance()->isValid()) { + if (effects->compositingType() == OpenGL2Compositing) { ShaderManager::instance()->popShader(); } glDisable(GL_BLEND); diff --git a/effects/snaphelper/snaphelper.cpp b/effects/snaphelper/snaphelper.cpp index f59d4a38c4..924183aff7 100644 --- a/effects/snaphelper/snaphelper.cpp +++ b/effects/snaphelper/snaphelper.cpp @@ -81,7 +81,7 @@ void SnapHelperEffect::postPaintScreen() GLVertexBuffer *vbo = GLVertexBuffer::streamingBuffer(); vbo->reset(); vbo->setUseColor(true); - if (ShaderManager::instance()->isValid()) { + if (effects->compositingType() == OpenGL2Compositing) { ShaderManager::instance()->pushShader(ShaderManager::ColorShader); } glEnable(GL_BLEND); @@ -122,7 +122,7 @@ void SnapHelperEffect::postPaintScreen() } vbo->setData(verts.count() / 2, 2, verts.data(), NULL); vbo->render(GL_LINES); - if (ShaderManager::instance()->isValid()) { + if (effects->compositingType() == OpenGL2Compositing) { ShaderManager::instance()->popShader(); } diff --git a/effects/startupfeedback/startupfeedback.cpp b/effects/startupfeedback/startupfeedback.cpp index 3d743bccdd..ea753a6a62 100644 --- a/effects/startupfeedback/startupfeedback.cpp +++ b/effects/startupfeedback/startupfeedback.cpp @@ -129,7 +129,7 @@ void StartupFeedbackEffect::reconfigure(Effect::ReconfigureFlags flags) m_type = BouncingFeedback; else if (busyBlinking) { m_type = BlinkingFeedback; - if (ShaderManager::instance()->isValid()) { + if (effects->compositingType() == OpenGL2Compositing) { delete m_blinkingShader; m_blinkingShader = 0; const QString shader = KGlobal::dirs()->findResource("data", "kwin/blinking-startup-fragment.glsl"); @@ -216,7 +216,7 @@ void StartupFeedbackEffect::paintScreen(int mask, QRegion region, ScreenPaintDat glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, color); #endif } - } else if (ShaderManager::instance()->isValid()) { + } else if (effects->compositingType() == OpenGL2Compositing) { useShader = true; ShaderManager::instance()->pushShader(ShaderManager::SimpleShader); } diff --git a/effects/trackmouse/trackmouse.cpp b/effects/trackmouse/trackmouse.cpp index cfe735ef9d..350c217bd1 100644 --- a/effects/trackmouse/trackmouse.cpp +++ b/effects/trackmouse/trackmouse.cpp @@ -127,7 +127,7 @@ void TrackMouseEffect::paintScreen(int mask, QRegion region, ScreenPaintData& da if ( effects->isOpenGLCompositing() && m_texture[0] && m_texture[1]) { GLShader *shader(0); QMatrix4x4 modelview; - if (ShaderManager::instance()->isValid()) { + if (effects->compositingType() == OpenGL2Compositing) { ShaderManager::instance()->pushShader(ShaderManager::GenericShader); shader = ShaderManager::instance()->getBoundShader(); modelview = shader->getUniformMatrix4x4("modelview"); @@ -154,7 +154,7 @@ void TrackMouseEffect::paintScreen(int mask, QRegion region, ScreenPaintData& da popMatrix(); } glDisable(GL_BLEND); - if (ShaderManager::instance()->isValid()) { + if (effects->compositingType() == OpenGL2Compositing) { shader->setUniform(GLShader::ModelViewMatrix, modelview); ShaderManager::instance()->popShader(); } diff --git a/lanczosfilter.cpp b/lanczosfilter.cpp index eb1a1881db..07ff3a419a 100644 --- a/lanczosfilter.cpp +++ b/lanczosfilter.cpp @@ -203,7 +203,7 @@ void LanczosFilter::performPaint(EffectWindowImpl* w, int mask, QRegion region, if (hardwareClipping) { glEnable(GL_SCISSOR_TEST); } - if (ShaderManager::instance()->isValid()) { + if (effects->compositingType() == OpenGL2Compositing) { glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); @@ -340,7 +340,7 @@ void LanczosFilter::performPaint(EffectWindowImpl* w, int mask, QRegion region, if (hardwareClipping) { glEnable(GL_SCISSOR_TEST); } - if (ShaderManager::instance()->isValid()) { + if (effects->compositingType() == OpenGL2Compositing) { glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); @@ -616,7 +616,7 @@ bool LanczosShader::init() { GLPlatform *gl = GLPlatform::instance(); if (gl->supports(GLSL) && - ShaderManager::instance()->isValid() && + effects->compositingType() == OpenGL2Compositing && GLRenderTarget::supported() && !(gl->isRadeon() && gl->chipClass() < R600)) { m_shader = ShaderManager::instance()->loadFragmentShader(ShaderManager::SimpleShader, ":/resources/lanczos-fragment.glsl"); diff --git a/libkwineffects/kwinglutils.h b/libkwineffects/kwinglutils.h index 14fdd5ba9b..679443edba 100644 --- a/libkwineffects/kwinglutils.h +++ b/libkwineffects/kwinglutils.h @@ -283,6 +283,13 @@ public: **/ bool isShaderBound() const; /** + * Allows to query whether Shaders are supported by the compositor, that is + * whether the Shaders compiled successfully. + * + * With OpenGL 1 compositing this method will always return @c false. + * + * Do not use this method to check whether the compositor uses OpenGL 1 or 2, + * use @link EffectsHandler::compositingType instead. * @return @c true if the built-in shaders are valid, @c false otherwise **/ bool isValid() const; diff --git a/workspace.cpp b/workspace.cpp index de2d219269..e86e39e15a 100644 --- a/workspace.cpp +++ b/workspace.cpp @@ -2189,7 +2189,7 @@ QString Workspace::supportInformation() const support.append(" no\n"); } - if (ShaderManager::instance()->isValid()) { + if (effects->compositingType() == OpenGL2Compositing) { support.append("OpenGL 2 Shaders are used\n"); } else { support.append("OpenGL 2 Shaders are not used. Legacy OpenGL 1.x code path is used.\n");