Commit d882ddee authored by Cyrille Berger's avatar Cyrille Berger

constify KoColorSpace

svn path=/trunk/koffice/; revision=590353
parent 99c4c769
......@@ -39,7 +39,7 @@ class KisRgbColorSpace : public KoLcmsColorSpace<RgbU8Traits>
{
public:
KisRgbColorSpace(KoColorSpaceRegistry * parent, KoColorProfile *p);
virtual bool willDegrade(ColorSpaceIndependence ) { return false; }
virtual bool willDegrade(ColorSpaceIndependence ) const { return false; }
};
class KisRgbColorSpaceFactory : public KoColorSpaceFactory
......
......@@ -46,7 +46,7 @@ KoCompositeOpList KoColorSpace::userVisiblecompositeOps() const
return m_compositeOps.values();
}
const KoCompositeOp * KoColorSpace::compositeOp(const QString & id)
const KoCompositeOp * KoColorSpace::compositeOp(const QString & id) const
{
if ( m_compositeOps.contains( id ) )
return m_compositeOps.value( id );
......@@ -64,9 +64,9 @@ void KoColorSpace::addCompositeOp(const KoCompositeOp * op)
bool KoColorSpace::convertPixelsTo(const quint8 * src,
quint8 * dst,
KoColorSpace * dstColorSpace,
const KoColorSpace * dstColorSpace,
quint32 numPixels,
qint32 renderingIntent)
qint32 renderingIntent) const
{
Q_UNUSED(renderingIntent);
// 4 channels: labA, 2 bytes per lab channel
......@@ -91,7 +91,7 @@ void KoColorSpace::bitBlt(quint8 *dst,
qint32 rows,
qint32 cols,
const QString & op,
const QBitArray & channelFlags)
const QBitArray & channelFlags) const
{
if ( m_compositeOps.contains( op ) ) {
bitBlt(dst, dststride, srcSpace, src, srcRowStride, srcAlphaMask, maskRowStride, opacity, rows, cols, m_compositeOps.value( op ), channelFlags);
......@@ -112,7 +112,7 @@ void KoColorSpace::bitBlt(quint8 *dst,
quint8 opacity,
qint32 rows,
qint32 cols,
const QString& op)
const QString& op) const
{
if ( m_compositeOps.contains( op ) ) {
bitBlt(dst, dststride, srcSpace, src, srcRowStride, srcAlphaMask, maskRowStride, opacity, rows, cols, m_compositeOps.value( op ));
......@@ -133,7 +133,7 @@ void KoColorSpace::bitBlt(quint8 *dst,
qint32 rows,
qint32 cols,
const KoCompositeOp * op,
const QBitArray & channelFlags)
const QBitArray & channelFlags) const
{
if (rows <= 0 || cols <= 0)
return;
......@@ -186,7 +186,7 @@ void KoColorSpace::bitBlt(quint8 *dst,
quint8 opacity,
qint32 rows,
qint32 cols,
const KoCompositeOp * op)
const KoCompositeOp * op) const
{
if (rows <= 0 || cols <= 0)
return;
......
This diff is collapsed.
......@@ -102,10 +102,6 @@ class KoColorSpaceAbstract : public KoColorSpace {
{
return m_channels;
}
virtual quint32 pixelSize()
{
return _CSTraits::channels_nb * sizeof(typename _CSTraits::channels_type);
}
virtual QString channelValueText(const quint8 *pixel, quint32 channelIndex) const
{
......@@ -121,16 +117,16 @@ class KoColorSpaceAbstract : public KoColorSpace {
return QString().setNum( 100. * ((double)c ) / KoColorSpaceMathsTraits<typename _CSTraits::channels_type>::max() );
}
virtual quint8 scaleToU8(const quint8 * srcPixel, qint32 channelIndex) {
virtual quint8 scaleToU8(const quint8 * srcPixel, qint32 channelIndex) const {
typename _CSTraits::channels_type c = nativeArray(srcPixel)[channelIndex];
return KoColorSpaceMaths<typename _CSTraits::channels_type, quint8>::scaleToA(c);
}
virtual quint16 scaleToU16(const quint8 * srcPixel, qint32 channelIndex) {
virtual quint16 scaleToU16(const quint8 * srcPixel, qint32 channelIndex) const {
typename _CSTraits::channels_type c = nativeArray(srcPixel)[channelIndex];
return KoColorSpaceMaths<typename _CSTraits::channels_type,quint16>::scaleToA(c);
}
virtual void getSingleChannelPixel(quint8 *dstPixel, const quint8 *srcPixel, quint32 channelIndex)
virtual void getSingleChannelPixel(quint8 *dstPixel, const quint8 *srcPixel, quint32 channelIndex) const
{
const typename _CSTraits::channels_type* src = nativeArray(srcPixel);
typename _CSTraits::channels_type* dst = nativeArray(dstPixel);
......@@ -159,7 +155,7 @@ class KoColorSpaceAbstract : public KoColorSpace {
nativeArray(pixels)[_CSTraits::alpha_pos] = valpha;
}
}
virtual void multiplyAlpha(quint8 * pixels, quint8 alpha, qint32 nPixels)
virtual void multiplyAlpha(quint8 * pixels, quint8 alpha, qint32 nPixels) const
{
if (_CSTraits::alpha_pos < 0) return;
......@@ -172,7 +168,7 @@ class KoColorSpaceAbstract : public KoColorSpace {
}
}
virtual void applyAlphaU8Mask(quint8 * pixels, quint8 * alpha, qint32 nPixels)
virtual void applyAlphaU8Mask(quint8 * pixels, quint8 * alpha, qint32 nPixels) const
{
if (_CSTraits::alpha_pos < 0) return;
qint32 psize = pixelSize();
......@@ -184,7 +180,7 @@ class KoColorSpaceAbstract : public KoColorSpace {
}
}
virtual void applyInverseAlphaU8Mask(quint8 * pixels, quint8 * alpha, qint32 nPixels)
virtual void applyInverseAlphaU8Mask(quint8 * pixels, quint8 * alpha, qint32 nPixels) const
{
if (_CSTraits::alpha_pos < 0) return;
qint32 psize = pixelSize();
......
......@@ -115,14 +115,14 @@ class KoLcmsColorSpace : public KoColorSpaceAbstract<_CSTraits> {
}
public:
void setColorSpaceType(quint32 type) { m_cmType = type; }
quint32 colorSpaceType() { return m_cmType; }
quint32 colorSpaceType() const { return m_cmType; }
virtual icColorSpaceSignature colorSpaceSignature() { return m_colorSpaceSignature; }
virtual icColorSpaceSignature colorSpaceSignature() const { return m_colorSpaceSignature; }
virtual bool hasHighDynamicRange() const { return false; }
virtual KoColorProfile * getProfile() { return m_profile; };
virtual KoColorProfile * getProfile() const { return m_profile; };
virtual void fromQColor(const QColor& color, quint8 *dst, KoColorProfile * profile=0)
virtual void fromQColor(const QColor& color, quint8 *dst, KoColorProfile * profile=0) const
{
m_qcolordata[2] = color.red();
m_qcolordata[1] = color.green();
......@@ -149,13 +149,13 @@ class KoLcmsColorSpace : public KoColorSpaceAbstract<_CSTraits> {
this->setAlpha(dst, OPACITY_OPAQUE, 1);
}
virtual void fromQColor(const QColor& color, quint8 opacity, quint8 *dst, KoColorProfile * profile=0)
virtual void fromQColor(const QColor& color, quint8 opacity, quint8 *dst, KoColorProfile * profile=0) const
{
this->fromQColor(color, dst, profile);
this->setAlpha(dst, opacity, 1);
}
virtual void toQColor(const quint8 *src, QColor *c, KoColorProfile * profile =0)
virtual void toQColor(const quint8 *src, QColor *c, KoColorProfile * profile =0) const
{
if (profile == 0) {
// Default sRGB transform
......@@ -174,14 +174,14 @@ class KoLcmsColorSpace : public KoColorSpaceAbstract<_CSTraits> {
c->setRgb(m_qcolordata[2], m_qcolordata[1], m_qcolordata[0]);
}
virtual void toQColor(const quint8 *src, QColor *c, quint8 *opacity, KoColorProfile * profile =0)
virtual void toQColor(const quint8 *src, QColor *c, quint8 *opacity, KoColorProfile * profile =0) const
{
this->toQColor(src, c, profile);
*opacity = this->getAlpha(src);
}
virtual QImage convertToQImage(const quint8 *data, qint32 width, qint32 height,
KoColorProfile *dstProfile,
qint32 renderingIntent, float /*exposure*/)
qint32 renderingIntent, float /*exposure*/) const
{
QImage img = QImage(width, height, QImage::Format_ARGB32);
......@@ -226,9 +226,9 @@ class KoLcmsColorSpace : public KoColorSpaceAbstract<_CSTraits> {
virtual bool convertPixelsTo(const quint8 * src,
quint8 * dst,
KoColorSpace * dstColorSpace,
const KoColorSpace * dstColorSpace,
quint32 numPixels,
qint32 renderingIntent)
qint32 renderingIntent) const
{
/* kdDebug() << "new conversion" << endl;
for(int i = 0; i < numPixels; i++)
......@@ -307,7 +307,7 @@ class KoLcmsColorSpace : public KoColorSpaceAbstract<_CSTraits> {
return KoColorSpace::convertPixelsTo(src, dst, dstColorSpace, numPixels, renderingIntent);
}
virtual KoColorAdjustment *createBrightnessContrastAdjustment(quint16 *transferValues)
virtual KoColorAdjustment *createBrightnessContrastAdjustment(quint16 *transferValues) const
{
if (!m_profile) return 0;
......@@ -331,7 +331,7 @@ class KoLcmsColorSpace : public KoColorSpaceAbstract<_CSTraits> {
}
virtual KoColorAdjustment *createDesaturateAdjustment()
virtual KoColorAdjustment *createDesaturateAdjustment() const
{
if (!m_profile) return 0;
......@@ -389,7 +389,7 @@ class KoLcmsColorSpace : public KoColorSpaceAbstract<_CSTraits> {
return adj;
}
virtual KoColorAdjustment *createPerChannelAdjustment(quint16 **transferValues)
virtual KoColorAdjustment *createPerChannelAdjustment(quint16 **transferValues) const
{
if (!m_profile) return 0;
......@@ -415,7 +415,7 @@ class KoLcmsColorSpace : public KoColorSpaceAbstract<_CSTraits> {
}
virtual void applyAdjustment(const quint8 *src, quint8 *dst, KoColorAdjustment *adjustment, qint32 nPixels)
virtual void applyAdjustment(const quint8 *src, quint8 *dst, KoColorAdjustment *adjustment, qint32 nPixels) const
{
KoColorAdjustmentImpl * adj = dynamic_cast<KoColorAdjustmentImpl*>(adjustment);
if (adj)
......@@ -423,7 +423,7 @@ class KoLcmsColorSpace : public KoColorSpaceAbstract<_CSTraits> {
}
virtual void invertColor(quint8 * src, qint32 nPixels)
virtual void invertColor(quint8 * src, qint32 nPixels) const
{
quint16 rgba[4];
quint32 psize = this->pixelSize();
......@@ -438,7 +438,7 @@ class KoLcmsColorSpace : public KoColorSpaceAbstract<_CSTraits> {
}
}
virtual quint8 difference(const quint8* src1, const quint8* src2)
virtual quint8 difference(const quint8* src1, const quint8* src2) const
{
if (m_defaultToLab) {
......@@ -531,7 +531,7 @@ class KoLcmsColorSpace : public KoColorSpaceAbstract<_CSTraits> {
} BCHSWADJUSTS, *LPBCHSWADJUSTS;
static int desaturateSampler(register WORD In[], register WORD Out[], register LPVOID /*Cargo*/)
static int desaturateSampler(register WORD In[], register WORD Out[], register LPVOID /*Cargo*/)
{
cmsCIELab LabIn, LabOut;
cmsCIELCh LChIn, LChOut;
......@@ -553,10 +553,10 @@ class KoLcmsColorSpace : public KoColorSpaceAbstract<_CSTraits> {
return true;
}
cmsHTRANSFORM createTransform(KoColorSpace * dstColorSpace,
cmsHTRANSFORM createTransform(const KoColorSpace * dstColorSpace,
KoColorProfile * srcProfile,
KoColorProfile * dstProfile,
qint32 renderingIntent)
qint32 renderingIntent) const
{
KConfig * cfg = KGlobal::config();
bool bpCompensation = cfg->readEntry("useBlackPointCompensation", false);
......@@ -586,23 +586,23 @@ class KoLcmsColorSpace : public KoColorSpaceAbstract<_CSTraits> {
cmsHTRANSFORM m_defaultToRGB16; // Default transform to 16 bit sRGB
cmsHTRANSFORM m_defaultFromRGB16; // Default transform from 16 bit sRGB
cmsHPROFILE m_lastRGBProfile; // Last used profile to transform to/from RGB
cmsHTRANSFORM m_lastToRGB; // Last used transform to transform to RGB
cmsHTRANSFORM m_lastFromRGB; // Last used transform to transform from RGB
mutable cmsHPROFILE m_lastRGBProfile; // Last used profile to transform to/from RGB
mutable cmsHTRANSFORM m_lastToRGB; // Last used transform to transform to RGB
mutable cmsHTRANSFORM m_lastFromRGB; // Last used transform to transform from RGB
cmsHTRANSFORM m_defaultToLab;
cmsHTRANSFORM m_defaultFromLab;
KoColorProfile * m_profile;
KoColorSpace *m_lastUsedDstColorSpace;
cmsHTRANSFORM m_lastUsedTransform;
mutable const KoColorSpace *m_lastUsedDstColorSpace;
mutable cmsHTRANSFORM m_lastUsedTransform;
DWORD m_cmType; // The colorspace type as defined by littlecms
icColorSpaceSignature m_colorSpaceSignature; // The colorspace signature as defined in icm/icc files
// cmsHTRANSFORM is a void *, so this should work.
typedef QMap<KoColorSpace *, cmsHTRANSFORM> TransformMap;
TransformMap m_transforms; // Cache for existing transforms
typedef QMap<const KoColorSpace *, cmsHTRANSFORM> TransformMap;
mutable TransformMap m_transforms; // Cache for existing transforms
};
......
......@@ -42,7 +42,7 @@ public:
virtual ~KoAlphaColorSpace();
public:
virtual bool willDegrade(ColorSpaceIndependence independence)
virtual bool willDegrade(ColorSpaceIndependence independence) const
{
Q_UNUSED(independence);
return false;
......
......@@ -38,7 +38,7 @@ KoLabColorSpace::KoLabColorSpace(KoColorSpaceRegistry * parent, KoColorProfile *
m_compositeOps.insert( COMPOSITE_ERASE, new KoCompositeOpErase<LabU16Traits>( this ) );
}
bool KoLabColorSpace::willDegrade(ColorSpaceIndependence independence)
bool KoLabColorSpace::willDegrade(ColorSpaceIndependence independence) const
{
if (independence == TO_RGBA8)
return true;
......
......@@ -32,7 +32,7 @@ class KoLabColorSpace : public KoLcmsColorSpace<LabU16Traits>
{
public:
KoLabColorSpace(KoColorSpaceRegistry * parent, KoColorProfile *p);
virtual bool willDegrade(ColorSpaceIndependence independence);
virtual bool willDegrade(ColorSpaceIndependence independence) const;
virtual QString normalisedChannelValueText(const quint8 *pixel, quint32 channelIndex) const;
private:
static const quint32 CHANNEL_L = 0;
......
......@@ -38,7 +38,7 @@ KoRgbU16ColorSpace::KoRgbU16ColorSpace(KoColorSpaceRegistry * parent, KoColorPro
m_compositeOps.insert( COMPOSITE_ERASE, new KoCompositeOpErase<RgbU16Traits>( this ) );
}
bool KoRgbU16ColorSpace::willDegrade(ColorSpaceIndependence independence)
bool KoRgbU16ColorSpace::willDegrade(ColorSpaceIndependence independence) const
{
if (independence == TO_RGBA8)
return true;
......
......@@ -32,7 +32,7 @@ class KoRgbU16ColorSpace : public KoLcmsColorSpace<RgbU16Traits>
{
public:
KoRgbU16ColorSpace(KoColorSpaceRegistry * parent, KoColorProfile *p);
virtual bool willDegrade(ColorSpaceIndependence independence);
virtual bool willDegrade(ColorSpaceIndependence independence) const;
};
class KoRgbU16ColorSpaceFactory : public KoColorSpaceFactory
......
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