Safety checks in cube and coverswitch if shaders are not available
Do not try to load the shaders if using the OpenGL1 compositor - it might crash the driver. REVIEW: 110798
This commit is contained in:
parent
aa92d2dbd9
commit
2657476db0
2 changed files with 25 additions and 16 deletions
|
@ -67,16 +67,20 @@ CoverSwitchEffect::CoverSwitchEffect()
|
||||||
captionFont.setBold(true);
|
captionFont.setBold(true);
|
||||||
captionFont.setPointSize(captionFont.pointSize() * 2);
|
captionFont.setPointSize(captionFont.pointSize() * 2);
|
||||||
|
|
||||||
QString shadersDir = "kwin/shaders/1.10/";
|
if (effects->compositingType() == OpenGL2Compositing) {
|
||||||
|
QString shadersDir = "kwin/shaders/1.10/";
|
||||||
#ifdef KWIN_HAVE_OPENGLES
|
#ifdef KWIN_HAVE_OPENGLES
|
||||||
const qint64 coreVersionNumber = kVersionNumber(3, 0);
|
const qint64 coreVersionNumber = kVersionNumber(3, 0);
|
||||||
#else
|
#else
|
||||||
const qint64 coreVersionNumber = kVersionNumber(1, 40);
|
const qint64 coreVersionNumber = kVersionNumber(1, 40);
|
||||||
#endif
|
#endif
|
||||||
if (GLPlatform::instance()->glslVersion() >= coreVersionNumber)
|
if (GLPlatform::instance()->glslVersion() >= coreVersionNumber)
|
||||||
shadersDir = "kwin/shaders/1.40/";
|
shadersDir = "kwin/shaders/1.40/";
|
||||||
const QString fragmentshader = KGlobal::dirs()->findResource("data", shadersDir + "coverswitch-reflection.glsl");
|
const QString fragmentshader = KGlobal::dirs()->findResource("data", shadersDir + "coverswitch-reflection.glsl");
|
||||||
m_reflectionShader = ShaderManager::instance()->loadFragmentShader(ShaderManager::GenericShader, fragmentshader);
|
m_reflectionShader = ShaderManager::instance()->loadFragmentShader(ShaderManager::GenericShader, fragmentshader);
|
||||||
|
} else {
|
||||||
|
m_reflectionShader = NULL;
|
||||||
|
}
|
||||||
connect(effects, SIGNAL(windowClosed(KWin::EffectWindow*)), this, SLOT(slotWindowClosed(KWin::EffectWindow*)));
|
connect(effects, SIGNAL(windowClosed(KWin::EffectWindow*)), this, SLOT(slotWindowClosed(KWin::EffectWindow*)));
|
||||||
connect(effects, SIGNAL(tabBoxAdded(int)), this, SLOT(slotTabBoxAdded(int)));
|
connect(effects, SIGNAL(tabBoxAdded(int)), this, SLOT(slotTabBoxAdded(int)));
|
||||||
connect(effects, SIGNAL(tabBoxClosed()), this, SLOT(slotTabBoxClosed()));
|
connect(effects, SIGNAL(tabBoxClosed()), this, SLOT(slotTabBoxClosed()));
|
||||||
|
@ -309,7 +313,7 @@ void CoverSwitchEffect::paintScreen(int mask, QRegion region, ScreenPaintData& d
|
||||||
glScissor(area.x(), y, area.width(), area.height());
|
glScissor(area.x(), y, area.width(), area.height());
|
||||||
glEnable(GL_SCISSOR_TEST);
|
glEnable(GL_SCISSOR_TEST);
|
||||||
|
|
||||||
if (shaderManager->isValid() && m_reflectionShader->isValid()) {
|
if (shaderManager->isValid() && m_reflectionShader && m_reflectionShader->isValid()) {
|
||||||
shaderManager->pushShader(m_reflectionShader);
|
shaderManager->pushShader(m_reflectionShader);
|
||||||
QMatrix4x4 windowTransformation;
|
QMatrix4x4 windowTransformation;
|
||||||
windowTransformation.translate(area.x() + area.width() * 0.5f, 0.0, 0.0);
|
windowTransformation.translate(area.x() + area.width() * 0.5f, 0.0, 0.0);
|
||||||
|
|
|
@ -108,10 +108,15 @@ CubeEffect::CubeEffect()
|
||||||
if (GLPlatform::instance()->glslVersion() >= coreVersionNumber)
|
if (GLPlatform::instance()->glslVersion() >= coreVersionNumber)
|
||||||
m_shadersDir = "kwin/shaders/1.40/";
|
m_shadersDir = "kwin/shaders/1.40/";
|
||||||
|
|
||||||
const QString fragmentshader = KGlobal::dirs()->findResource("data", m_shadersDir + "cube-reflection.glsl");
|
if (effects->compositingType() == OpenGL2Compositing) {
|
||||||
m_reflectionShader = ShaderManager::instance()->loadFragmentShader(ShaderManager::GenericShader, fragmentshader);
|
const QString fragmentshader = KGlobal::dirs()->findResource("data", m_shadersDir + "cube-reflection.glsl");
|
||||||
const QString capshader = KGlobal::dirs()->findResource("data", m_shadersDir + "cube-cap.glsl");
|
m_reflectionShader = ShaderManager::instance()->loadFragmentShader(ShaderManager::GenericShader, fragmentshader);
|
||||||
m_capShader = ShaderManager::instance()->loadFragmentShader(ShaderManager::GenericShader, capshader);
|
const QString capshader = KGlobal::dirs()->findResource("data", m_shadersDir + "cube-cap.glsl");
|
||||||
|
m_capShader = ShaderManager::instance()->loadFragmentShader(ShaderManager::GenericShader, capshader);
|
||||||
|
} else {
|
||||||
|
m_reflectionShader = NULL;
|
||||||
|
m_capShader = NULL;
|
||||||
|
}
|
||||||
m_textureMirrorMatrix.scale(1.0, -1.0, 1.0);
|
m_textureMirrorMatrix.scale(1.0, -1.0, 1.0);
|
||||||
m_textureMirrorMatrix.translate(0.0, -1.0, 0.0);
|
m_textureMirrorMatrix.translate(0.0, -1.0, 0.0);
|
||||||
connect(effects, SIGNAL(tabBoxAdded(int)), this, SLOT(slotTabBoxAdded(int)));
|
connect(effects, SIGNAL(tabBoxAdded(int)), this, SLOT(slotTabBoxAdded(int)));
|
||||||
|
@ -219,7 +224,7 @@ void CubeEffect::reconfigure(ReconfigureFlags)
|
||||||
}
|
}
|
||||||
|
|
||||||
// set the cap color on the shader
|
// set the cap color on the shader
|
||||||
if (m_capShader->isValid()) {
|
if (m_capShader && m_capShader->isValid()) {
|
||||||
ShaderBinder binder(m_capShader);
|
ShaderBinder binder(m_capShader);
|
||||||
m_capShader->setUniform("u_capColor", capColor);
|
m_capShader->setUniform("u_capColor", capColor);
|
||||||
}
|
}
|
||||||
|
@ -485,7 +490,7 @@ void CubeEffect::paintScreen(int mask, QRegion region, ScreenPaintData& data)
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
ShaderManager *shaderManager = ShaderManager::instance();
|
ShaderManager *shaderManager = ShaderManager::instance();
|
||||||
if (shaderManager->isValid() && m_reflectionShader->isValid()) {
|
if (shaderManager->isValid() && m_reflectionShader && m_reflectionShader->isValid()) {
|
||||||
// ensure blending is enabled - no attribute stack
|
// ensure blending is enabled - no attribute stack
|
||||||
ShaderBinder binder(m_reflectionShader);
|
ShaderBinder binder(m_reflectionShader);
|
||||||
QMatrix4x4 windowTransformation;
|
QMatrix4x4 windowTransformation;
|
||||||
|
@ -771,7 +776,7 @@ void CubeEffect::paintCap(bool frontFirst, float zOffset)
|
||||||
}
|
}
|
||||||
|
|
||||||
bool capShader = false;
|
bool capShader = false;
|
||||||
if (effects->compositingType() == OpenGL2Compositing && m_capShader->isValid()) {
|
if (effects->compositingType() == OpenGL2Compositing && m_capShader && m_capShader->isValid()) {
|
||||||
capShader = true;
|
capShader = true;
|
||||||
ShaderManager::instance()->pushShader(m_capShader);
|
ShaderManager::instance()->pushShader(m_capShader);
|
||||||
float opacity = cubeOpacity;
|
float opacity = cubeOpacity;
|
||||||
|
@ -1544,7 +1549,7 @@ void CubeEffect::paintWindow(EffectWindow* w, int mask, QRegion region, WindowPa
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bool capShader = false;
|
bool capShader = false;
|
||||||
if (effects->compositingType() == OpenGL2Compositing && m_capShader->isValid()) {
|
if (effects->compositingType() == OpenGL2Compositing && m_capShader && m_capShader->isValid()) {
|
||||||
capShader = true;
|
capShader = true;
|
||||||
ShaderManager::instance()->pushShader(m_capShader);
|
ShaderManager::instance()->pushShader(m_capShader);
|
||||||
m_capShader->setUniform("u_mirror", 0);
|
m_capShader->setUniform("u_mirror", 0);
|
||||||
|
|
Loading…
Reference in a new issue