Commit d315c710 authored by Boudewijn Rempt's avatar Boudewijn Rempt

Force use of const colorspace and profile pointers

This removes the usage of grabColorspace/releaseColorspace from Krita.

The option to get a non-const colorspace existed to get a non-const
profile, on which the current exposure could be set. That changed with
the move to lcms-based hdr colorspaces, so it's no longer necessary.
parent 3e4e08a9
......@@ -325,8 +325,8 @@ bool KisAsyncMerger::compositeWithProjection(KisLayerSP layer, const QRect &rect
// because the channel flags from the source layer doesn't match with the colorspace of the projection device
// this leads to the situation that the wrong channels will be enabled/disabled
if(!channelFlags.isEmpty() && m_currentProjection->colorSpace() != device->colorSpace()) {
KoColorSpace* src = device->colorSpace();
KoColorSpace* dst = m_currentProjection->colorSpace();
const KoColorSpace* src = device->colorSpace();
const KoColorSpace* dst = m_currentProjection->colorSpace();
bool alphaFlagIsSet = (src->channelFlags(false,true) & channelFlags) == src->channelFlags(false,true);
bool allColorFlagsAreSet = (src->channelFlags(true,false) & channelFlags) == src->channelFlags(true,false);
......
......@@ -168,7 +168,7 @@ public:
PaintDeviceCache cache;
qint32 x;
qint32 y;
KoColorSpace* colorSpace;
const KoColorSpace* colorSpace;
};
......@@ -209,7 +209,7 @@ void KisPaintDevice::init(KisDataManagerSP explicitDataManager,
defaultBounds = new KisDefaultBounds();
}
m_d->colorSpace = KoColorSpaceRegistry::instance()->grabColorSpace(colorSpace);
m_d->colorSpace = colorSpace;
Q_ASSERT(m_d->colorSpace);
if(explicitDataManager) {
......@@ -238,7 +238,7 @@ KisPaintDevice::KisPaintDevice(const KisPaintDevice& rhs)
, m_d(new Private(this))
{
if (this != &rhs) {
m_d->colorSpace = KoColorSpaceRegistry::instance()->grabColorSpace(rhs.m_d->colorSpace);
m_d->colorSpace = rhs.m_d->colorSpace;
Q_ASSERT(m_d->colorSpace);
m_d->x = rhs.m_d->x;
......@@ -256,7 +256,6 @@ KisPaintDevice::KisPaintDevice(const KisPaintDevice& rhs)
KisPaintDevice::~KisPaintDevice()
{
KoColorSpaceRegistry::instance()->releaseColorSpace(m_d->colorSpace);
delete m_d;
}
......@@ -276,8 +275,7 @@ void KisPaintDevice::prepareClone(KisPaintDeviceSP src)
setDefaultPixel(src->defaultPixel());
}
KoColorSpaceRegistry::instance()->releaseColorSpace(m_d->colorSpace);
m_d->colorSpace = KoColorSpaceRegistry::instance()->grabColorSpace(src->colorSpace());
m_d->colorSpace = src->colorSpace();
}
setDefaultBounds(src->defaultBounds());
setParentNode(0);
......@@ -607,7 +605,7 @@ KUndo2Command* KisPaintDevice::convertTo(const KoColorSpace * dstColorSpace, KoC
}
KisDataManagerSP oldData = m_datamanager;
KoColorSpace *oldColorSpace = m_d->colorSpace;
const KoColorSpace *oldColorSpace = m_d->colorSpace;
KisPaintDeviceConvertTypeCommand* cmd = new KisPaintDeviceConvertTypeCommand(this,
oldData,
......@@ -627,8 +625,7 @@ void KisPaintDevice::setProfile(const KoColorProfile * profile)
const KoColorSpace * dstSpace =
KoColorSpaceRegistry::instance()->colorSpace(colorSpace()->colorModelId().id(), colorSpace()->colorDepthId().id(), profile);
if (dstSpace) {
KoColorSpaceRegistry::instance()->releaseColorSpace(m_d->colorSpace);
m_d->colorSpace = KoColorSpaceRegistry::instance()->grabColorSpace(dstSpace);
m_d->colorSpace = dstSpace;
}
emit profileChanged(profile);
}
......@@ -639,8 +636,7 @@ void KisPaintDevice::setDataManager(KisDataManagerSP data, const KoColorSpace *
m_d->cache.setupCache();
if(colorSpace) {
KoColorSpaceRegistry::instance()->releaseColorSpace(m_d->colorSpace);
m_d->colorSpace = KoColorSpaceRegistry::instance()->grabColorSpace(colorSpace);
m_d->colorSpace = colorSpace;
emit colorSpaceChanged(colorSpace);
}
}
......@@ -1053,13 +1049,7 @@ quint32 KisPaintDevice::channelCount() const
return _channelCount;
}
KoColorSpace * KisPaintDevice::colorSpace()
{
Q_ASSERT(m_d->colorSpace != 0);
return m_d->colorSpace;
}
const KoColorSpace * KisPaintDevice::colorSpace() const
const KoColorSpace *KisPaintDevice::colorSpace() const
{
Q_ASSERT(m_d->colorSpace != 0);
return m_d->colorSpace;
......
......@@ -525,12 +525,7 @@ public:
/**
* @return the colorspace of the pixels in this paint device
*/
KoColorSpace * colorSpace();
/**
* @return the colorspace of the pixels in this paint device
*/
const KoColorSpace * colorSpace() const;
const KoColorSpace *colorSpace() const;
/**
* @return the internal datamanager that keeps the pixels.
......
......@@ -1823,9 +1823,9 @@ void KisPainter::drawThickLine(const QPointF & start, const QPointF & end, int s
selectionAccessor = d->selection->projection()->createRandomConstAccessorNG(start.x(), start.y());
}
int pixelSize = d->device->pixelSize();
quint8 pixelOpacity = quint8(d->paramInfo.opacity*255.0f);
KoColorSpace* cs = d->device->colorSpace();
int pixelSize = d->device->pixelSize();
quint8 pixelOpacity = quint8(d->paramInfo.opacity*255.0f);
const KoColorSpace *cs = d->device->colorSpace();
KoColor c1(d->paintColor);
KoColor c2(d->paintColor);
......
......@@ -91,7 +91,7 @@ QRect KisTransformWorker::rotateNone(KisPaintDeviceSP src, KisPaintDeviceSP dst,
{
qint32 pixelSize = src->pixelSize();
QRect r(boundRect);
KoColorSpace *cs = src->colorSpace();
const KoColorSpace *cs = src->colorSpace();
Q_UNUSED(cs);
KisHLineIteratorSP hit = src->createHLineIteratorNG(r.x(), r.top(), r.width());
......@@ -128,7 +128,7 @@ QRect rotateWithTf(int rotation, KisPaintDeviceSP src, KisPaintDeviceSP dst,
{
qint32 pixelSize = src->pixelSize();
QRect r(boundRect);
KoColorSpace *cs = src->colorSpace();
const KoColorSpace *cs = src->colorSpace();
Q_UNUSED(cs);
KisRandomAccessorSP srcAcc = src->createRandomAccessorNG(0, 0);
......@@ -296,7 +296,7 @@ void KisTransformWorker::transformPass(KisPaintDevice *src, KisPaintDevice *dst,
qint32 lineNum, srcStart, firstLine, srcLen, numLines;
qint32 center, begin, end; /* filter calculation variables */
quint8 pixelSize = src->pixelSize();
KoColorSpace * cs = src->colorSpace();
const KoColorSpace * cs = src->colorSpace();
KoMixColorsOp * mixOp = cs->mixColorsOp();
qint32 scale;
qint32 shearFracOffset;
......
......@@ -93,7 +93,7 @@ void KisUnsharpFilter::process(KisPaintDeviceSP device,
KisConvolutionKernelSP kernel = KisConvolutionKernel::fromMaskGenerator(kas);
KisPaintDeviceSP interm = new KisPaintDevice(*device);
KoColorSpace * cs = interm->colorSpace();
const KoColorSpace * cs = interm->colorSpace();
KoConvolutionOp * convolutionOp = cs->convolutionOp();
KisConvolutionPainter painter(interm); // TODO no need for a full copy and then a transaction
......
......@@ -193,9 +193,9 @@ qreal KisColorSmudgeOp::paintAt(const KisPaintInformation& info)
m_tempPainter->bitBlt(0, 0, painter()->device(), x, y, m_maskBounds.width(), m_maskBounds.height());
}
else {
KoColorSpace* cs = painter()->device()->colorSpace();
qint32 px = x + m_maskBounds.width() / 2;
qint32 py = y + m_maskBounds.height() / 2;
const KoColorSpace* cs = painter()->device()->colorSpace();
qint32 px = x + m_maskBounds.width() / 2;
qint32 py = y + m_maskBounds.height() / 2;
// get the pixel on the canvas that lies beneath the center
// of the dab and fill the temporary paint device with that color
m_smudgeAccessor->moveTo(px, py);
......
......@@ -433,7 +433,7 @@ double HairyBrush::computeMousePressure(double distance)
}
void HairyBrush::colorifyBristles(KisRandomConstAccessorSP acc, KoColorSpace * cs, QPointF point)
void HairyBrush::colorifyBristles(KisRandomConstAccessorSP acc, const KoColorSpace * cs, QPointF point)
{
KoColor color(cs);
int pixelSize = cs->pixelSize();
......
......@@ -93,7 +93,7 @@ private:
/// paint wu particle using composite operation
void paintParticle(QPointF pos, const KoColor& color);
/// similar to sample input color in spray
void colorifyBristles(KisRandomConstAccessorSP acc, KoColorSpace *cs, QPointF point);
void colorifyBristles(KisRandomConstAccessorSP acc, const KoColorSpace *cs, QPointF point);
void repositionBristles(double angle, double slope);
/// compute mouse pressure according distance
......
......@@ -67,6 +67,7 @@ public:
double thicknesssensorvalue;
void initializeTwin(KisHatchingPaintOpSettings* convenienttwin) const;
using KisPropertiesConfiguration::fromXML;
virtual void fromXML(const QDomElement&);
};
......
......@@ -48,7 +48,7 @@ void KisBidirectionalMixingOption::apply(KisPaintDeviceSP dab, KisPaintDeviceSP
{
if (!m_mixingEnabled) return;
KoColorSpace *cs = dab->colorSpace();
const KoColorSpace *cs = dab->colorSpace();
KisPaintDeviceSP canvas = new KisPaintDevice(cs);
KisPainter p(canvas);
p.setCompositeOp(COMPOSITE_COPY);
......
......@@ -114,7 +114,7 @@ void KisPlainColorSource::selectColor(double mix)
colors[0] = m_cachedBackGroundColor->data();
colors[1] = m_foreGroundColor.data();
int weight = (int)(mix * 255);
const qint16 weights[2] = { 255 - weight, weight };
const qint16 weights[2] = { (qint16)255 - weight, (qint16)weight };
m_color->colorSpace()->mixColorsOp()->mixColors(colors, weights, 2, m_color->data());
......
......@@ -51,7 +51,7 @@ void ParticleBrush::setInitialPosition(QPointF pos) {
}
void ParticleBrush::paintParticle(KisRandomAccessorSP accWrite,KoColorSpace * cs, QPointF pos, const KoColor& color,qreal weight, bool respectOpacity)
void ParticleBrush::paintParticle(KisRandomAccessorSP accWrite, const KoColorSpace * cs, QPointF pos, const KoColor& color,qreal weight, bool respectOpacity)
{
// opacity top left, right, bottom left, right
KoColor myColor(color);
......@@ -89,7 +89,7 @@ void ParticleBrush::paintParticle(KisRandomAccessorSP accWrite,KoColorSpace * cs
void ParticleBrush::draw(KisPaintDeviceSP dab,const KoColor& color,QPointF pos) {
KisRandomAccessorSP accessor = dab->createRandomAccessorNG( qRound(pos.x()), qRound(pos.y()) );
KoColorSpace * cs = dab->colorSpace();
const KoColorSpace * cs = dab->colorSpace();
for (int i = 0; i < m_properties->iterations; i++) {
for (int j = 0; j < m_properties->particleCount; j++) {
......@@ -119,7 +119,7 @@ void ParticleBrush::draw(KisPaintDeviceSP dab,const KoColor& color,QPointF pos)
m_particleNextPos[j] *= m_properties->gravity;
m_particlePos[j] = m_particlePos[j] + (m_particleNextPos[j] * TIME);
paintParticle(accessor, cs ,m_particlePos[j],color,m_properties->weight, true);
paintParticle(accessor, cs, m_particlePos[j], color, m_properties->weight, true);
}//for j
}//for i
......
......@@ -53,7 +53,7 @@ public:
private:
/// paints wu particle, similar to spray version but you can turn on respecting opacity of the tool and add weight to opacity
/// also the particle respects opacity in the destination pixel buffer
void paintParticle(KisRandomAccessorSP writeAccessor, KoColorSpace * cs, QPointF pos, const KoColor& color, qreal weight, bool respectOpacity);
void paintParticle(KisRandomAccessorSP writeAccessor, const KoColorSpace *cs, QPointF pos, const KoColor& color, qreal weight, bool respectOpacity);
QVector<QPointF> m_particlePos;
QVector<QPointF> m_particleNextPos;
......
......@@ -257,16 +257,13 @@ public:
virtual bool hasHighDynamicRange() const = 0;
//========== Display profiles =============================================//
//========== Display profiles =============================================//
/**
* Return the profile of this color space.
*/
virtual const KoColorProfile * profile() const = 0;
/**
* Return the profile of this color space.
*/
virtual KoColorProfile * profile() = 0;
//================= Conversion functions ==================================//
......
......@@ -95,10 +95,6 @@ public:
return m_profile;
}
virtual KoColorProfile* profile() {
return m_profile;
}
virtual QImage convertToQImage(const quint8 *data, qint32 width, qint32 height,
const KoColorProfile * dstProfile,
KoColorConversionTransformation::Intent renderingIntent,
......
......@@ -87,10 +87,6 @@ public:
return m_profile;
}
virtual KoColorProfile* profile() {
return m_profile;
}
virtual KoColorTransformation* createBrightnessContrastAdjustment(const quint16*) const {
warnPigment << i18n("Undefined operation in the %1 color space", m_name);
return 0;
......
......@@ -203,10 +203,6 @@ public:
return d->colorProfile;
}
virtual KoColorProfile * profile() {
return d->colorProfile;
}
virtual bool profileIsCompatible(const KoColorProfile* profile) const {
const IccColorProfile* p = dynamic_cast<const IccColorProfile*>(profile);
return (p && p->asLcms()->colorSpaceSignature() == colorSpaceSignature());
......
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