Commit 4a172a9d authored by Casian Andrei's avatar Casian Andrei
Browse files

Enable color correction only after successfuly contacting KolorManager

Prevents the possiblity of using shaders modified for color correction
without valid data from KolorManager. If that happened, everthing
blacked out.

Now the color correction shaders are enabled only after successfuly
contacting KolorManager.

The issue was highlighted after ab7e228d.

BUG: 321217
parent 5810f87d
......@@ -260,6 +260,7 @@ ColorCorrectionPrivate::ColorCorrectionPrivate(ColorCorrection *parent)
: QObject(parent)
, m_enabled(false)
, m_hasError(false)
, m_duringEnablingPhase(false)
, m_ccTextureUnit(-1)
, m_dummyCCTexture(0)
, m_lastOutput(-1)
......@@ -313,13 +314,20 @@ bool ColorCorrection::setEnabled(bool enabled)
if (enabled) {
// Update all profiles and regions
d->m_csi->update();
kDebug(1212) << "color correction will be enabled after contacting KolorManager";
d->m_duringEnablingPhase = true;
// d->m_enabled will be set to true in colorServerUpdateSucceededSlot()
} else {
d->deleteCCTextures();
d->m_enabled = false;
GLShader::sColorCorrect = false;
kDebug(1212) << "color correction has been disabled";
// Reload all shaders
ShaderManager::cleanup();
ShaderManager::instance();
}
d->m_enabled = enabled;
GLShader::sColorCorrect = enabled;
kDebug(1212) << enabled;
return true;
}
......@@ -665,6 +673,18 @@ void ColorCorrectionPrivate::colorServerUpdateSucceededSlot()
// Force the color correction textures to be recreated
deleteCCTextures();
// If this is reached after enabling color correction using ColorCorrection::setEnabled(true)
if (m_duringEnablingPhase) {
m_duringEnablingPhase = false;
m_enabled = true;
GLShader::sColorCorrect = true;
kDebug(1212) << "Color correction has been enabled";
// Reload all shaders
ShaderManager::cleanup();
ShaderManager::instance();
}
emit q->changed();
}
......@@ -672,9 +692,11 @@ void ColorCorrectionPrivate::colorServerUpdateFailedSlot()
{
Q_Q(ColorCorrection);
kError(1212) << "Update of color profiles failed";
m_duringEnablingPhase = false;
q->setEnabled(false);
kError(1212) << "Update of color profiles failed";
m_hasError = true;
emit q->errorOccured();
}
} // KWin namespace
......@@ -92,6 +92,7 @@ public slots:
public:
bool m_enabled;
bool m_hasError;
bool m_duringEnablingPhase;
int m_ccTextureUnit;
ColorServerInterface *m_csi;
......
......@@ -237,6 +237,7 @@ private:
static bool sColorCorrect;
friend class ColorCorrection;
friend class ColorCorrectionPrivate;
friend class ShaderManager;
};
......
......@@ -764,11 +764,7 @@ ColorCorrection *SceneOpenGL2::colorCorrection()
void SceneOpenGL2::slotColorCorrectedChanged()
{
if (m_colorCorrection->setEnabled(options->isColorCorrected())) {
// Reload all shaders
ShaderManager::cleanup();
ShaderManager::instance();
}
m_colorCorrection->setEnabled(options->isColorCorrected());
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment