~ubuntu-branches/ubuntu/wily/kwin/wily-proposed

« back to all changes in this revision

Viewing changes to libkwineffects/kwinglcolorcorrection.cpp

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2015-08-10 23:16:37 UTC
  • mfrom: (1.1.10)
  • Revision ID: package-import@ubuntu.com-20150810231637-5zb2tstjkez93hml
Tags: 4:5.3.95-0ubuntu1
new upstream beta release

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
 
24
24
#include "kwinglplatform.h"
25
25
#include "kwinglutils.h"
 
26
#include "logging_p.h"
26
27
 
27
28
#include <QByteArrayMatcher>
28
29
#include <QDBusConnection>
29
30
#include <QDBusError>
30
31
#include <QDBusPendingCall>
31
32
#include <QDBusPendingCallWatcher>
32
 
#include <QDebug>
33
33
#include <QPair>
34
34
#include <QVector3D>
35
35
 
101
101
uint ColorServerInterface::versionInfo() const
102
102
{
103
103
    if (!m_versionInfoUpdated)
104
 
        qWarning() << "Version info not updated";
 
104
        qCWarning(LIBKWINGLUTILS) << "Version info not updated";
105
105
    return m_versionInfo;
106
106
}
107
107
 
154
154
void ColorServerInterface::callFinishedSlot(QDBusPendingCallWatcher *watcher)
155
155
{
156
156
    if (watcher == m_versionInfoWatcher) {
157
 
        qDebug() << "Version info call finished";
 
157
        qCDebug(LIBKWINGLUTILS) << "Version info call finished";
158
158
        QDBusPendingReply< uint > reply = *watcher;
159
159
        if (reply.isError()) {
160
 
            qWarning() << reply.error();
 
160
            qCWarning(LIBKWINGLUTILS) << reply.error();
161
161
            if (!m_signaledFail)
162
162
                emit updateFailed();
163
163
            m_signaledFail = true;
169
169
    }
170
170
 
171
171
    if (watcher == m_outputClutsWatcher) {
172
 
        qDebug() << "Output cluts call finished";
 
172
        qCDebug(LIBKWINGLUTILS) << "Output cluts call finished";
173
173
        QDBusPendingReply< ClutList > reply = *watcher;
174
174
        if (reply.isError()) {
175
 
            qWarning() << reply.error();
 
175
            qCWarning(LIBKWINGLUTILS) << reply.error();
176
176
            if (!m_signaledFail)
177
177
                emit updateFailed();
178
178
            m_signaledFail = true;
184
184
    }
185
185
 
186
186
    if (watcher == m_regionClutsWatcher) {
187
 
        qDebug() << "Region cluts call finished";
 
187
        qCDebug(LIBKWINGLUTILS) << "Region cluts call finished";
188
188
        QDBusPendingReply< RegionalClutMap > reply = *watcher;
189
189
        if (reply.isError()) {
190
 
            qWarning() << reply.error();
 
190
            qCWarning(LIBKWINGLUTILS) << reply.error();
191
191
            if (!m_signaledFail)
192
192
                emit updateFailed();
193
193
            m_signaledFail = true;
201
201
    if (m_versionInfoUpdated &&
202
202
        m_outputClutsUpdated &&
203
203
        m_regionClutsUpdated) {
204
 
        qDebug() << "Update succeeded";
 
204
        qCDebug(LIBKWINGLUTILS) << "Update succeeded";
205
205
        emit updateSucceeded();
206
206
    }
207
207
}
284
284
        return true;
285
285
 
286
286
    if (enabled && d->m_hasError) {
287
 
        qCritical() << "cannot enable color correction because of a previous error";
 
287
        qCCritical(LIBKWINGLUTILS) << "cannot enable color correction because of a previous error";
288
288
        return false;
289
289
    }
290
290
 
291
291
#ifdef KWIN_HAVE_OPENGLES
292
292
    const GLPlatform *gl = GLPlatform::instance();
293
293
    if (enabled && gl->isGLES() && !d->m_haveTexture3D) {
294
 
        qCritical() << "color correction is not supported on OpenGL ES without OES_texture_3D";
 
294
        qCCritical(LIBKWINGLUTILS) << "color correction is not supported on OpenGL ES without OES_texture_3D";
295
295
        d->m_hasError = true;
296
296
        return false;
297
297
    }
300
300
    if (enabled) {
301
301
        // Update all profiles and regions
302
302
        d->m_csi->update();
303
 
        qDebug() << "color correction will be enabled after contacting KolorManager";
 
303
        qCDebug(LIBKWINGLUTILS) << "color correction will be enabled after contacting KolorManager";
304
304
        d->m_duringEnablingPhase = true;
305
305
        // d->m_enabled will be set to true in colorServerUpdateSucceededSlot()
306
306
    } else {
307
307
        d->deleteCCTextures();
308
308
        d->m_enabled = false;
309
309
        GLShader::sColorCorrect = false;
310
 
        qDebug() << "color correction has been disabled";
 
310
        qCDebug(LIBKWINGLUTILS) << "color correction has been disabled";
311
311
 
312
312
        // Reload all shaders
313
313
        ShaderManager::cleanup();
326
326
 
327
327
    GLShader *shader = ShaderManager::instance()->getBoundShader();
328
328
    if (!shader) {
329
 
        qCritical() << "no bound shader for color correction setup";
 
329
        qCCritical(LIBKWINGLUTILS) << "no bound shader for color correction setup";
330
330
        d->m_hasError = true;
331
331
        emit errorOccured();
332
332
        return;
339
339
    }
340
340
 
341
341
    if (!shader->setUniform(GLShader::ColorCorrectionLookupTextureUnit, d->m_ccTextureUnit)) {
342
 
        qCritical() << "unable to set uniform for the color correction lookup texture";
 
342
        qCCritical(LIBKWINGLUTILS) << "unable to set uniform for the color correction lookup texture";
343
343
        d->m_hasError = true;
344
344
        emit errorOccured();
345
345
        return;
346
346
    }
347
347
 
348
348
    if (!d->setupCCTextures()) {
349
 
        qCritical() << "unable to setup color correction textures";
 
349
        qCCritical(LIBKWINGLUTILS) << "unable to setup color correction textures";
350
350
        d->m_hasError = true;
351
351
        emit errorOccured();
352
352
        return;
556
556
bool ColorCorrectionPrivate::setupCCTextures()
557
557
{
558
558
    if (!m_enabled || m_hasError) {
559
 
        qWarning() << "Color correction not enabled or an error occurred, refusing to set up textures";
 
559
        qCWarning(LIBKWINGLUTILS) << "Color correction not enabled or an error occurred, refusing to set up textures";
560
560
        return false;
561
561
    }
562
562
 
564
564
    if (!m_dummyCCTexture) {
565
565
        glGenTextures(1, &m_dummyCCTexture);
566
566
        if (!setupCCTexture(m_dummyCCTexture, m_dummyClut)) {
567
 
            qCritical() << "unable to setup dummy color correction texture";
 
567
            qCCritical(LIBKWINGLUTILS) << "unable to setup dummy color correction texture";
568
568
            m_dummyCCTexture = 0;
569
569
            return false;
570
570
        }
574
574
 
575
575
    // Setup actual color correction textures
576
576
    if (m_outputCCTextures.isEmpty() && !m_outputCluts->isEmpty()) {
577
 
        qDebug() << "setting up output color correction textures";
 
577
        qCDebug(LIBKWINGLUTILS) << "setting up output color correction textures";
578
578
 
579
579
        const int outputCount = m_outputCluts->size();
580
580
        m_outputCCTextures.resize(outputCount);
582
582
 
583
583
        for (int i = 0; i < outputCount; ++i)
584
584
            if (!setupCCTexture(m_outputCCTextures[i], m_outputCluts->at(i))) {
585
 
                qCritical() << "unable to set up color correction texture for output" << i;
 
585
                qCCritical(LIBKWINGLUTILS) << "unable to set up color correction texture for output" << i;
586
586
                success = false;
587
587
            }
588
588
    }
608
608
bool ColorCorrectionPrivate::setupCCTexture(GLuint texture, const Clut& clut)
609
609
{
610
610
    if ((uint) clut.size() != CLUT_ELEMENT_COUNT) {
611
 
        qCritical() << "cannot setup CC texture: invalid color lookup table";
 
611
        qCCritical(LIBKWINGLUTILS) << "cannot setup CC texture: invalid color lookup table";
612
612
        return false;
613
613
    }
614
614
 
647
647
{
648
648
    Q_Q(ColorCorrection);
649
649
 
650
 
    qDebug() << "Update of color profiles succeeded";
 
650
    qCDebug(LIBKWINGLUTILS) << "Update of color profiles succeeded";
651
651
 
652
652
    // Force the color correction textures to be recreated
653
653
    deleteCCTextures();
657
657
        m_duringEnablingPhase = false;
658
658
        m_enabled = true;
659
659
        GLShader::sColorCorrect = true;
660
 
        qDebug() << "Color correction has been enabled";
 
660
        qCDebug(LIBKWINGLUTILS) << "Color correction has been enabled";
661
661
 
662
662
        // Reload all shaders
663
663
        ShaderManager::cleanup();
664
664
        if (!ShaderManager::instance()->isValid()) {
665
 
            qCritical() << "Shader reinitialization failed, possible compile problems with the shaders "
 
665
            qCCritical(LIBKWINGLUTILS) << "Shader reinitialization failed, possible compile problems with the shaders "
666
666
                "altered for color-correction";
667
667
            m_hasError = true;
668
 
            qDebug() << "Color correction has been disabled due to shader issues";
 
668
            qCDebug(LIBKWINGLUTILS) << "Color correction has been disabled due to shader issues";
669
669
            m_enabled = false;
670
670
            GLShader::sColorCorrect = false;
671
671
            ShaderManager::cleanup();
682
682
 
683
683
    m_duringEnablingPhase = false;
684
684
 
685
 
    qCritical() << "Update of color profiles failed";
 
685
    qCCritical(LIBKWINGLUTILS) << "Update of color profiles failed";
686
686
    m_hasError = true;
687
687
    emit q->errorOccured();
688
688
}