Commit 1f733e28 authored by Wolthera van Hövell's avatar Wolthera van Hövell 🛍

Refactor the proofing transform system for better caching.

This now makes the transform separately from the actual transforming,
which means it's easier to cache and to update. Softproofing is now
gone from usable to user-friendly.

Still needs saving/loading and little setting-bugs fixed.

ref T2337
parent 8371c417
......@@ -68,11 +68,6 @@ KoColorSpace::KoColorSpace(const QString &id, const QString &name, KoMixColorsOp
d->colorants = QVector <qreal> (0);
d->lumaCoefficients = QVector <qreal> (0);
d->iccEngine = 0;
d->proofingSpace = "";
d->softProofing = false;
d->gamutCheck = false;
d->gamutWarning = 0;
d->proofingTransform = 0;
d->deletability = NotOwnedByRegistry;
}
......@@ -96,7 +91,6 @@ KoColorSpace::~KoColorSpace()
delete d->transfoFromRGBA16;
delete d->transfoToLABA16;
delete d->transfoFromLABA16;
delete d->proofingTransform;
delete d;
}
......@@ -442,39 +436,24 @@ bool KoColorSpace::convertPixelsTo(const quint8 * src,
}
return true;
}
bool KoColorSpace::proofPixelsTo(const quint8 *src,
quint8 *dst,
const KoColorSpace *dstColorSpace,
const KoColorSpace *proofingSpace,
quint32 numPixels,
KoColorConversionTransformation::Intent renderingIntent,
KoColorConversionTransformation::Intent proofingIntent,
KoColorConversionTransformation::ConversionFlags conversionFlags,
quint8 *gamutWarning) const
KoColorConversionTransformation * KoColorSpace::createProofingTransform(const KoColorSpace *dstColorSpace, const KoColorSpace *proofingSpace, KoColorConversionTransformation::Intent renderingIntent, KoColorConversionTransformation::Intent proofingIntent, KoColorConversionTransformation::ConversionFlags conversionFlags, quint8 *gamutWarning) const
{
/*if (*this == *dstColorSpace) {
if (src != dst) {
memcpy(dst, src, numPixels * sizeof(quint8) * pixelSize());
}
return true;
}*/
// Only the icc engine can do this kind of stuff
//Can we cache this, maybe???
if (!d->iccEngine) {
d->iccEngine = KoColorSpaceEngineRegistry::instance()->get("icc");
qDebug() << ">>>>>>>>>>>>>>>>>>>> we got a proofing engine";
}
if (!d->iccEngine) return false;
if (d->proofingSpace!=proofingSpace->profile()->name()+dstColorSpace->profile()->name() || d->softProofing!=conversionFlags.testFlag(KoColorConversionTransformation::SoftProofing) || d->gamutCheck!=conversionFlags.testFlag(KoColorConversionTransformation::GamutCheck)) {
d->proofingTransform = d->iccEngine->createColorProofingTransformation(this, dstColorSpace, proofingSpace, renderingIntent, proofingIntent, conversionFlags, gamutWarning);
d->proofingSpace = proofingSpace->profile()->name()+dstColorSpace->profile()->name();
d->gamutWarning = gamutWarning;
d->softProofing = conversionFlags.testFlag(KoColorConversionTransformation::SoftProofing);
d->gamutCheck = conversionFlags.testFlag(KoColorConversionTransformation::GamutCheck);
}
//Q_UNUSED(transform);
d->proofingTransform->transform(src, dst, numPixels);
return d->iccEngine->createColorProofingTransformation(this, dstColorSpace, proofingSpace, renderingIntent, proofingIntent, conversionFlags, gamutWarning);
}
bool KoColorSpace::proofPixelsTo(const quint8 *src,
quint8 *dst,
quint32 numPixels,
KoColorConversionTransformation *proofingTransform) const
{
proofingTransform->transform(src, dst, numPixels);
//the transform is deleted in the destructor.
return true;
......
......@@ -372,6 +372,12 @@ public:
KoColorConversionTransformation::Intent renderingIntent,
KoColorConversionTransformation::ConversionFlags conversionFlags) const;
virtual KoColorConversionTransformation *createProofingTransform(const KoColorSpace * dstColorSpace,
const KoColorSpace * proofingSpace,
KoColorConversionTransformation::Intent renderingIntent,
KoColorConversionTransformation::Intent proofingIntent,
KoColorConversionTransformation::ConversionFlags conversionFlags,
quint8 *gamutWarning) const;
/**
* @brief proofPixelsTo
* @param src
......@@ -386,13 +392,9 @@ public:
* @return
*/
virtual bool proofPixelsTo(const quint8 * src,
quint8 * dst, const KoColorSpace * dstColorSpace,
const KoColorSpace * proofingSpace,
quint32 numPixels,
KoColorConversionTransformation::Intent renderingIntent,
KoColorConversionTransformation::Intent proofingIntent,
KoColorConversionTransformation::ConversionFlags conversionFlags,
quint8 *gamutWarning) const;
quint8 * dst,
quint32 numPixels,
KoColorConversionTransformation *proofingTransform) const;
//============================== Manipulation functions ==========================//
......
......@@ -48,10 +48,6 @@ struct Q_DECL_HIDDEN KoColorSpace::Private {
QVector <qreal> lumaCoefficients;
KoColorSpaceEngine *iccEngine;
QString proofingSpace;
bool softProofing;
bool gamutCheck;
KoColorConversionTransformation *proofingTransform;
Deletability deletability;
};
......
......@@ -116,6 +116,7 @@ public:
KisProofingConfiguration *proofingConfig = 0;
bool softProofing = false;
bool gamutCheck = false;
bool proofingConfigUpdated = false;
KisPopupPalette *popupPalette = 0;
KisDisplayColorConverter displayColorConverter;
......@@ -574,6 +575,7 @@ void KisCanvas2::setProofingOptions(bool softProof, bool gamutCheck)
qDebug()<<"setting softproofing in canvas: "<<softProof <<", "<<gamutCheck;
qDebug()<<conversionFlags.testFlag(KoColorConversionTransformation::SoftProofing);
qDebug()<<conversionFlags.testFlag(KoColorConversionTransformation::GamutCheck);
m_d->proofingConfigUpdated = true;
startUpdateInPatches(this->image()->bounds());
}
......@@ -595,6 +597,16 @@ void KisCanvas2::slotChangeProofingConfig()
setProofingOptions(m_d->softProofing, m_d->gamutCheck);
}
void KisCanvas2::setProofingConfigUpdated(bool updated)
{
m_d->proofingConfigUpdated = updated;
}
bool KisCanvas2::proofingConfigUpdated()
{
return m_d->proofingConfigUpdated;
}
KisProofingConfiguration *KisCanvas2::proofingConfiguration() const
{
if (!m_d->proofingConfig) {
......
......@@ -166,8 +166,23 @@ public: // KisCanvas2 methods
KisDisplayColorConverter *displayColorConverter() const;
KisExposureGammaCorrectionInterface* exposureGammaCorrectionInterface() const;
/**
* @brief setProofingOptions
* set the options for softproofing, without affecting the proofing options as stored inside the image.
*/
void setProofingOptions(bool softProof, bool gamutCheck);
KisProofingConfiguration *proofingConfiguration() const;
/**
* @brief setProofingConfigUpdated This function is to set whether the proofing config is updated,
* this is needed for determining whether or not to generate a new proofing transform.
* @param updated whether it's updated. Just set it to false in normal usage.
*/
void setProofingConfigUpdated(bool updated);
/**
* @brief proofingConfigUpdated ask the canvas whether or not it updated the proofing config.
* @return whether or not the proofing config is updated, if so, a new proofing transform needs to be made
* in KisOpenGL canvas.
*/bool proofingConfigUpdated();
void setCursor(const QCursor &cursor);
KisAnimationFrameCacheSP frameCache() const;
......
......@@ -94,6 +94,7 @@ public:
KisDisplayFilter* displayFilter;
KisOpenGL::FilterMode filterMode;
bool proofingConfigIsUpdated=false;
GLsync glSyncObject{0};
......@@ -789,7 +790,10 @@ void KisOpenGLCanvas2::finishResizingImage(qint32 w, qint32 h)
KisUpdateInfoSP KisOpenGLCanvas2::startUpdateCanvasProjection(const QRect & rc, const QBitArray &channelFlags)
{
d->openGLImageTextures->setChannelFlags(channelFlags);
d->openGLImageTextures->setProofingConfig(canvas()->proofingConfiguration());
if (canvas()->proofingConfigUpdated()) {
d->openGLImageTextures->setProofingConfig(canvas()->proofingConfiguration());
canvas()->setProofingConfigUpdated(false);
}
return d->openGLImageTextures->updateCache(rc);
}
......
......@@ -59,6 +59,8 @@ KisOpenGLImageTextures::KisOpenGLImageTextures()
, m_useOcio(false)
, m_initialized(false)
, m_proofingConfig(0)
, m_proofingTransform(0)
, m_createNewProofingTransform(true)
{
KisConfig cfg;
m_renderingIntent = (KoColorConversionTransformation::Intent)cfg.monitorRenderIntent();
......@@ -324,14 +326,16 @@ KisOpenGLUpdateInfoSP KisOpenGLImageTextures::updateCacheImpl(const QRect& rect,
if (tileInfo->valid()) {
tileInfo->retrieveData(m_image, channelFlags, m_onlyOneChannelSelected, m_selectedChannelIndex);
//create transform
if (m_createNewProofingTransform) {
const KoColorSpace *proofingSpace = KoColorSpaceRegistry::instance()->colorSpace(m_proofingConfig->proofingModel,m_proofingConfig->proofingDepth,m_proofingConfig->proofingProfile);
m_proofingTransform = tileInfo->generateProofingTransform(dstCS, proofingSpace, m_renderingIntent, m_proofingConfig->intent, m_proofingConfig->conversionFlags, m_proofingConfig->warningColor);
m_createNewProofingTransform = false;
}
if (convertColorSpace) {
if (m_proofingConfig && m_proofingConfig->conversionFlags.testFlag(KoColorConversionTransformation::SoftProofing)) {
//qDebug()<<"model: "<<m_proofingConfig->proofingModel<<", depth: "<<m_proofingConfig->proofingDepth<<", profile: "<<m_proofingConfig->proofingProfile;
const KoColorSpace *proofingSpace = KoColorSpaceRegistry::instance()->colorSpace(m_proofingConfig->proofingModel,m_proofingConfig->proofingDepth,m_proofingConfig->proofingProfile);
if (!proofingSpace){
qDebug()<<"Proofing space is incorrect";
}
tileInfo->proofTo(dstCS, proofingSpace, m_renderingIntent, m_proofingConfig->intent, m_proofingConfig->conversionFlags, m_proofingConfig->warningColor);
if (m_proofingConfig && m_proofingTransform && m_proofingConfig->conversionFlags.testFlag(KoColorConversionTransformation::SoftProofing)) {
tileInfo->proofTo(dstCS, m_proofingConfig->conversionFlags, m_proofingTransform);
} else {
tileInfo->convertTo(dstCS, m_renderingIntent, m_conversionFlags);
}
......@@ -461,6 +465,8 @@ void KisOpenGLImageTextures::setChannelFlags(const QBitArray &channelFlags)
void KisOpenGLImageTextures::setProofingConfig(KisProofingConfiguration *proofingConfig)
{
m_proofingConfig = proofingConfig;
qDebug()<<"set";
m_createNewProofingTransform = true;
}
void KisOpenGLImageTextures::getTextureSize(KisGLTexturesInfo *texturesInfo)
......
......@@ -28,6 +28,7 @@
#include "canvas/kis_update_info.h"
#include "opengl/kis_texture_tile.h"
#include "KisProofingConfiguration.h"
#include <KoColorProofingConversionTransformation.h>
class KisOpenGLImageTextures;
class QOpenGLFunctions;
......@@ -161,7 +162,10 @@ private:
const KoColorProfile *m_monitorProfile;
KoColorConversionTransformation::Intent m_renderingIntent;
KoColorConversionTransformation::ConversionFlags m_conversionFlags;
KisProofingConfiguration *m_proofingConfig;
KoColorConversionTransformation *m_proofingTransform;
bool m_createNewProofingTransform;
/**
* If the destination color space coincides with the one of the image,
......
......@@ -209,11 +209,9 @@ public:
}
}
void proofTo(const KoColorSpace* dstCS, const KoColorSpace* proofingSpace,
KoColorConversionTransformation::Intent renderingIntent,
KoColorConversionTransformation::Intent proofingIntent,
void proofTo(const KoColorSpace* dstCS,
KoColorConversionTransformation::ConversionFlags conversionFlags,
KoColor gamutWarning)
KoColorConversionTransformation *proofingTransform)
{
if (dstCS == m_patchColorSpace && conversionFlags == KoColorConversionTransformation::Empty) return;
......@@ -222,7 +220,7 @@ public:
const quint32 conversionCacheLength = numPixels * dstCS->pixelSize();
m_conversionCache.ensureNotSmaller(conversionCacheLength);
m_patchColorSpace->proofPixelsTo(m_patchPixels.data(), m_conversionCache.data(), dstCS, proofingSpace, numPixels, renderingIntent,proofingIntent, conversionFlags, gamutWarning.data());
m_patchColorSpace->proofPixelsTo(m_patchPixels.data(), m_conversionCache.data(), numPixels, proofingTransform);
m_patchColorSpace = dstCS;
m_conversionCache.swap(m_patchPixels);
......@@ -230,6 +228,15 @@ public:
}
}
KoColorConversionTransformation *generateProofingTransform(const KoColorSpace* dstCS, const KoColorSpace* proofingSpace,
KoColorConversionTransformation::Intent renderingIntent,
KoColorConversionTransformation::Intent proofingIntent,
KoColorConversionTransformation::ConversionFlags conversionFlags,
KoColor gamutWarning)
{
return m_patchColorSpace->createProofingTransform(dstCS, proofingSpace, renderingIntent, proofingIntent, conversionFlags, gamutWarning.data());
}
inline quint8* data() const {
return m_patchPixels.data();
}
......
Markdown is supported
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