|
|
|
@ -24,13 +24,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
#include "kwinglplatform.h"
|
|
|
|
|
#include "kwinglutils.h"
|
|
|
|
|
|
|
|
|
|
#include <KDebug>
|
|
|
|
|
|
|
|
|
|
#include <QByteArrayMatcher>
|
|
|
|
|
#include <QDBusConnection>
|
|
|
|
|
#include <QDBusError>
|
|
|
|
|
#include <QDBusPendingCall>
|
|
|
|
|
#include <QDBusPendingCallWatcher>
|
|
|
|
|
#include <QDebug>
|
|
|
|
|
#include <QPair>
|
|
|
|
|
#include <QVector3D>
|
|
|
|
|
|
|
|
|
@ -102,7 +101,7 @@ ColorServerInterface::~ColorServerInterface()
|
|
|
|
|
uint ColorServerInterface::versionInfo() const
|
|
|
|
|
{
|
|
|
|
|
if (!m_versionInfoUpdated)
|
|
|
|
|
kWarning(1212) << "Version info not updated";
|
|
|
|
|
qWarning() << "Version info not updated";
|
|
|
|
|
return m_versionInfo;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -155,10 +154,10 @@ QDBusPendingReply< RegionalClutMap > ColorServerInterface::getRegionCluts()
|
|
|
|
|
void ColorServerInterface::callFinishedSlot(QDBusPendingCallWatcher *watcher)
|
|
|
|
|
{
|
|
|
|
|
if (watcher == m_versionInfoWatcher) {
|
|
|
|
|
kDebug(1212) << "Version info call finished";
|
|
|
|
|
qDebug() << "Version info call finished";
|
|
|
|
|
QDBusPendingReply< uint > reply = *watcher;
|
|
|
|
|
if (reply.isError()) {
|
|
|
|
|
kWarning(1212) << reply.error();
|
|
|
|
|
qWarning() << reply.error();
|
|
|
|
|
if (!m_signaledFail)
|
|
|
|
|
emit updateFailed();
|
|
|
|
|
m_signaledFail = true;
|
|
|
|
@ -170,10 +169,10 @@ void ColorServerInterface::callFinishedSlot(QDBusPendingCallWatcher *watcher)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (watcher == m_outputClutsWatcher) {
|
|
|
|
|
kDebug(1212) << "Output cluts call finished";
|
|
|
|
|
qDebug() << "Output cluts call finished";
|
|
|
|
|
QDBusPendingReply< ClutList > reply = *watcher;
|
|
|
|
|
if (reply.isError()) {
|
|
|
|
|
kWarning(1212) << reply.error();
|
|
|
|
|
qWarning() << reply.error();
|
|
|
|
|
if (!m_signaledFail)
|
|
|
|
|
emit updateFailed();
|
|
|
|
|
m_signaledFail = true;
|
|
|
|
@ -185,10 +184,10 @@ void ColorServerInterface::callFinishedSlot(QDBusPendingCallWatcher *watcher)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (watcher == m_regionClutsWatcher) {
|
|
|
|
|
kDebug(1212) << "Region cluts call finished";
|
|
|
|
|
qDebug() << "Region cluts call finished";
|
|
|
|
|
QDBusPendingReply< RegionalClutMap > reply = *watcher;
|
|
|
|
|
if (reply.isError()) {
|
|
|
|
|
kWarning(1212) << reply.error();
|
|
|
|
|
qWarning() << reply.error();
|
|
|
|
|
if (!m_signaledFail)
|
|
|
|
|
emit updateFailed();
|
|
|
|
|
m_signaledFail = true;
|
|
|
|
@ -202,7 +201,7 @@ void ColorServerInterface::callFinishedSlot(QDBusPendingCallWatcher *watcher)
|
|
|
|
|
if (m_versionInfoUpdated &&
|
|
|
|
|
m_outputClutsUpdated &&
|
|
|
|
|
m_regionClutsUpdated) {
|
|
|
|
|
kDebug(1212) << "Update succeeded";
|
|
|
|
|
qDebug() << "Update succeeded";
|
|
|
|
|
emit updateSucceeded();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -280,14 +279,14 @@ bool ColorCorrection::setEnabled(bool enabled)
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
if (enabled && d->m_hasError) {
|
|
|
|
|
kError(1212) << "cannot enable color correction because of a previous error";
|
|
|
|
|
qCritical() << "cannot enable color correction because of a previous error";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#ifdef KWIN_HAVE_OPENGLES
|
|
|
|
|
const GLPlatform *gl = GLPlatform::instance();
|
|
|
|
|
if (enabled && gl->isGLES() && glTexImage3D == 0) {
|
|
|
|
|
kError(1212) << "color correction is not supported on OpenGL ES without OES_texture_3D";
|
|
|
|
|
qCritical() << "color correction is not supported on OpenGL ES without OES_texture_3D";
|
|
|
|
|
d->m_hasError = true;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
@ -296,14 +295,14 @@ 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";
|
|
|
|
|
qDebug() << "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";
|
|
|
|
|
qDebug() << "color correction has been disabled";
|
|
|
|
|
|
|
|
|
|
// Reload all shaders
|
|
|
|
|
ShaderManager::cleanup();
|
|
|
|
@ -322,7 +321,7 @@ void ColorCorrection::setupForOutput(int screen)
|
|
|
|
|
|
|
|
|
|
GLShader *shader = ShaderManager::instance()->getBoundShader();
|
|
|
|
|
if (!shader) {
|
|
|
|
|
kError(1212) << "no bound shader for color correction setup";
|
|
|
|
|
qCritical() << "no bound shader for color correction setup";
|
|
|
|
|
d->m_hasError = true;
|
|
|
|
|
emit errorOccured();
|
|
|
|
|
return;
|
|
|
|
@ -335,14 +334,14 @@ void ColorCorrection::setupForOutput(int screen)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!shader->setUniform(GLShader::ColorCorrectionLookupTextureUnit, d->m_ccTextureUnit)) {
|
|
|
|
|
kError(1212) << "unable to set uniform for the color correction lookup texture";
|
|
|
|
|
qCritical() << "unable to set uniform for the color correction lookup texture";
|
|
|
|
|
d->m_hasError = true;
|
|
|
|
|
emit errorOccured();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!d->setupCCTextures()) {
|
|
|
|
|
kError(1212) << "unable to setup color correction textures";
|
|
|
|
|
qCritical() << "unable to setup color correction textures";
|
|
|
|
|
d->m_hasError = true;
|
|
|
|
|
emit errorOccured();
|
|
|
|
|
return;
|
|
|
|
@ -552,7 +551,7 @@ QByteArray ColorCorrection::prepareFragmentShader(const QByteArray &sourceCode)
|
|
|
|
|
bool ColorCorrectionPrivate::setupCCTextures()
|
|
|
|
|
{
|
|
|
|
|
if (!m_enabled || m_hasError) {
|
|
|
|
|
kWarning(1212) << "Color correction not enabled or an error occurred, refusing to set up textures";
|
|
|
|
|
qWarning() << "Color correction not enabled or an error occurred, refusing to set up textures";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -560,7 +559,7 @@ bool ColorCorrectionPrivate::setupCCTextures()
|
|
|
|
|
if (!m_dummyCCTexture) {
|
|
|
|
|
glGenTextures(1, &m_dummyCCTexture);
|
|
|
|
|
if (!setupCCTexture(m_dummyCCTexture, m_dummyClut)) {
|
|
|
|
|
kError(1212) << "unable to setup dummy color correction texture";
|
|
|
|
|
qCritical() << "unable to setup dummy color correction texture";
|
|
|
|
|
m_dummyCCTexture = 0;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
@ -570,7 +569,7 @@ bool ColorCorrectionPrivate::setupCCTextures()
|
|
|
|
|
|
|
|
|
|
// Setup actual color correction textures
|
|
|
|
|
if (m_outputCCTextures.isEmpty() && !m_outputCluts->isEmpty()) {
|
|
|
|
|
kDebug(1212) << "setting up output color correction textures";
|
|
|
|
|
qDebug() << "setting up output color correction textures";
|
|
|
|
|
|
|
|
|
|
const int outputCount = m_outputCluts->size();
|
|
|
|
|
m_outputCCTextures.resize(outputCount);
|
|
|
|
@ -578,7 +577,7 @@ bool ColorCorrectionPrivate::setupCCTextures()
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < outputCount; ++i)
|
|
|
|
|
if (!setupCCTexture(m_outputCCTextures[i], m_outputCluts->at(i))) {
|
|
|
|
|
kError(1212) << "unable to set up color correction texture for output" << i;
|
|
|
|
|
qCritical() << "unable to set up color correction texture for output" << i;
|
|
|
|
|
success = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -609,7 +608,7 @@ bool ColorCorrectionPrivate::deleteCCTextures()
|
|
|
|
|
bool ColorCorrectionPrivate::setupCCTexture(GLuint texture, const Clut& clut)
|
|
|
|
|
{
|
|
|
|
|
if ((uint) clut.size() != CLUT_ELEMENT_COUNT) {
|
|
|
|
|
kError(1212) << "cannot setup CC texture: invalid color lookup table";
|
|
|
|
|
qCritical() << "cannot setup CC texture: invalid color lookup table";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -648,7 +647,7 @@ void ColorCorrectionPrivate::colorServerUpdateSucceededSlot()
|
|
|
|
|
{
|
|
|
|
|
Q_Q(ColorCorrection);
|
|
|
|
|
|
|
|
|
|
kDebug(1212) << "Update of color profiles succeeded";
|
|
|
|
|
qDebug() << "Update of color profiles succeeded";
|
|
|
|
|
|
|
|
|
|
// Force the color correction textures to be recreated
|
|
|
|
|
deleteCCTextures();
|
|
|
|
@ -658,15 +657,15 @@ void ColorCorrectionPrivate::colorServerUpdateSucceededSlot()
|
|
|
|
|
m_duringEnablingPhase = false;
|
|
|
|
|
m_enabled = true;
|
|
|
|
|
GLShader::sColorCorrect = true;
|
|
|
|
|
kDebug(1212) << "Color correction has been enabled";
|
|
|
|
|
qDebug() << "Color correction has been enabled";
|
|
|
|
|
|
|
|
|
|
// Reload all shaders
|
|
|
|
|
ShaderManager::cleanup();
|
|
|
|
|
if (!ShaderManager::instance()->isValid()) {
|
|
|
|
|
kError(1212) << "Shader reinitialization failed, possible compile problems with the shaders "
|
|
|
|
|
qCritical() << "Shader reinitialization failed, possible compile problems with the shaders "
|
|
|
|
|
"altered for color-correction";
|
|
|
|
|
m_hasError = true;
|
|
|
|
|
kDebug(1212) << "Color correction has been disabled due to shader issues";
|
|
|
|
|
qDebug() << "Color correction has been disabled due to shader issues";
|
|
|
|
|
m_enabled = false;
|
|
|
|
|
GLShader::sColorCorrect = false;
|
|
|
|
|
ShaderManager::cleanup();
|
|
|
|
@ -683,7 +682,7 @@ void ColorCorrectionPrivate::colorServerUpdateFailedSlot()
|
|
|
|
|
|
|
|
|
|
m_duringEnablingPhase = false;
|
|
|
|
|
|
|
|
|
|
kError(1212) << "Update of color profiles failed";
|
|
|
|
|
qCritical() << "Update of color profiles failed";
|
|
|
|
|
m_hasError = true;
|
|
|
|
|
emit q->errorOccured();
|
|
|
|
|
}
|
|
|
|
|