Commit 947b331b authored by Dmitry Kazakov's avatar Dmitry Kazakov

Fix fill painter to be able to fill a 8bit color on a 16-bit device

This patch changes the API of KisPaintDevice to not give any access
to raw bytes of the default colors. Not one is obliged to use KoColor
instead.
parent 13540e37
......@@ -92,7 +92,7 @@ void KisFillPainter::initFillPainter()
void KisFillPainter::fillSelection(const QRect &rc, const KoColor &color)
{
KisPaintDeviceSP fillDevice = new KisPaintDevice(device()->colorSpace());
fillDevice->setDefaultPixel(color.data());
fillDevice->setDefaultPixel(color);
bitBlt(rc.topLeft(), fillDevice, rc);
}
......
......@@ -224,7 +224,8 @@ public:
int pixelSize = m_src->pixelSize();
KoMixColorsOp *mixOp = m_src->colorSpace()->mixColorsOp();
const quint8 *defaultPixel = m_src->defaultPixel();
const KoColor defaultPixelObject = m_src->defaultPixel();
const quint8 *defaultPixel = defaultPixelObject.data();
const quint8 *borderPixel = defaultPixel;
quint8 *srcLineBuf = new quint8[pixelSize * (rightSrcBorder - leftSrcBorder)];
......
......@@ -190,14 +190,8 @@ void KisGroupLayer::resetCache(const KoColorSpace *colorSpace)
KisPaintDeviceSP dev = new KisPaintDevice(this, colorSpace, new KisDefaultBounds(image()));
dev->setX(this->x());
dev->setY(this->y());
quint8* defaultPixel = new quint8[colorSpace->pixelSize()];
m_d->paintDevice->colorSpace()->
convertPixelsTo(m_d->paintDevice->defaultPixel(), defaultPixel, colorSpace, 1,
KoColorConversionTransformation::internalRenderingIntent(),
KoColorConversionTransformation::internalConversionFlags());
dev->setDefaultPixel(defaultPixel);
delete[] defaultPixel;
dev->setDefaultPixel(m_d->paintDevice->defaultPixel());
m_d->paintDevice = dev;
m_d->paintDevice->setProjectionDevice(true);
} else {
......@@ -239,8 +233,7 @@ KisPaintDeviceSP KisGroupLayer::tryObligeChild() const
!child->layerStyle()) {
quint8 defaultOpacity =
m_d->paintDevice->colorSpace()->opacityU8(
m_d->paintDevice->defaultPixel());
m_d->paintDevice->defaultPixel().opacityU8();
if(defaultOpacity == OPACITY_TRANSPARENT_U8) {
return child->projection();
......@@ -276,8 +269,7 @@ bool KisGroupLayer::projectionIsValid() const
void KisGroupLayer::setDefaultProjectionColor(KoColor color)
{
color.convertTo(m_d->paintDevice->colorSpace());
m_d->paintDevice->setDefaultPixel(color.data());
m_d->paintDevice->setDefaultPixel(color);
}
KoColor KisGroupLayer::defaultProjectionColor() const
......
......@@ -1103,7 +1103,7 @@ void KisImage::setRootLayer(KisGroupLayerSP rootLayer)
m_d->rootLayer->disconnect();
KisPaintDeviceSP original = m_d->rootLayer->original();
defaultProjectionColor.setColor(original->defaultPixel(), original->colorSpace());
defaultProjectionColor = original->defaultPixel();
}
m_d->rootLayer = rootLayer;
......@@ -1111,8 +1111,7 @@ void KisImage::setRootLayer(KisGroupLayerSP rootLayer)
m_d->rootLayer->setGraphListener(this);
KisPaintDeviceSP newOriginal = m_d->rootLayer->original();
defaultProjectionColor.convertTo(newOriginal->colorSpace());
newOriginal->setDefaultPixel(defaultProjectionColor.data());
newOriginal->setDefaultPixel(defaultProjectionColor);
setRoot(m_d->rootLayer.data());
}
......
......@@ -27,6 +27,7 @@
#include <QScopedPointer>
#include <KoColor.h>
#include <KoColorSpace.h>
#include <KoCompositeOpRegistry.h>
......@@ -169,9 +170,7 @@ void KisMask::Private::initSelectionImpl(KisSelectionSP copyFrom, KisLayerSP par
} else {
selection = new KisSelection(new KisSelectionDefaultBounds(parentPaintDevice, parentLayer->image()));
quint8 newDefaultPixel = MAX_SELECTED;
selection->pixelSelection()->setDefaultPixel(&newDefaultPixel);
selection->pixelSelection()->setDefaultPixel(KoColor(Qt::white, selection->pixelSelection()->colorSpace()));
if (deferredSelectionOffset) {
selection->setX(deferredSelectionOffset->x());
......
......@@ -52,7 +52,7 @@ struct KisOnionSkinCompositor::Private
{
KisPaintDeviceSP tintDevice = new KisPaintDevice(colorSpace);
KoColor color = KoColor(tintColor, colorSpace);
tintDevice->setDefaultPixel(color.data());
tintDevice->setDefaultPixel(color);
return tintDevice;
}
......
......@@ -366,16 +366,19 @@ public:
return data->dataManager()->write(store);
}
void setFrameDefaultPixel(const quint8 *defPixel, int frameId)
void setFrameDefaultPixel(const KoColor &defPixel, int frameId)
{
DataSP data = m_frames[frameId];
data->dataManager()->setDefaultPixel(defPixel);
KoColor color(defPixel);
color.convertTo(data->colorSpace());
data->dataManager()->setDefaultPixel(color.data());
}
const quint8* frameDefaultPixel(int frameId) const
KoColor frameDefaultPixel(int frameId) const
{
DataSP data = m_frames[frameId];
return data->dataManager()->defaultPixel();
DataSP data = m_frames[frameId];
return KoColor(data->dataManager()->defaultPixel(),
data->colorSpace());
}
void fetchFrame(int frameId, KisPaintDeviceSP targetDevice);
......@@ -465,7 +468,7 @@ private:
{
currentData()->prepareClone(srcData);
q->setDefaultPixel(srcData->dataManager()->defaultPixel());
q->setDefaultPixel(KoColor(srcData->dataManager()->defaultPixel(), colorSpace()));
q->setDefaultBounds(src->defaultBounds());
}
......@@ -1266,7 +1269,7 @@ QRect KisPaintDevice::calculateExactBounds(bool nonDefaultOnly) const
QRect startRect = extent();
QRect endRect;
quint8 defaultOpacity = m_d->colorSpace()->opacityU8(defaultPixel());
quint8 defaultOpacity = defaultPixel().opacityU8();
if (defaultOpacity != OPACITY_TRANSPARENT_U8) {
if (!nonDefaultOnly) {
/**
......@@ -1283,7 +1286,8 @@ QRect KisPaintDevice::calculateExactBounds(bool nonDefaultOnly) const
}
if (nonDefaultOnly) {
Impl::CheckNonDefault compareOp(pixelSize(), defaultPixel());
const KoColor defaultPixel = this->defaultPixel();
Impl::CheckNonDefault compareOp(pixelSize(), defaultPixel.data());
endRect = Impl::calculateExactBoundsImpl(this, startRect, endRect, compareOp);
} else {
Impl::CheckFullyTransparent compareOp(m_d->colorSpace());
......@@ -1298,7 +1302,8 @@ QRegion KisPaintDevice::regionExact() const
QRegion resultRegion;
QVector<QRect> rects = region().rects();
Impl::CheckNonDefault compareOp(pixelSize(), defaultPixel());
const KoColor defaultPixel = this->defaultPixel();
Impl::CheckNonDefault compareOp(pixelSize(), defaultPixel.data());
Q_FOREACH (const QRect &rc1, rects) {
const int patchSize = 64;
......@@ -1333,15 +1338,18 @@ void KisPaintDevice::purgeDefaultPixels()
dm->purge(dm->extent());
}
void KisPaintDevice::setDefaultPixel(const quint8 *defPixel)
void KisPaintDevice::setDefaultPixel(const KoColor &defPixel)
{
m_d->dataManager()->setDefaultPixel(defPixel);
KoColor color(defPixel);
color.convertTo(colorSpace());
m_d->dataManager()->setDefaultPixel(color.data());
m_d->cache()->invalidate();
}
const quint8 *KisPaintDevice::defaultPixel() const
KoColor KisPaintDevice::defaultPixel() const
{
return m_d->dataManager()->defaultPixel();
return KoColor(m_d->dataManager()->defaultPixel(), colorSpace());
}
void KisPaintDevice::clear()
......@@ -1666,15 +1674,15 @@ void KisPaintDevice::clearSelection(KisSelectionSP selection)
KisHLineIteratorSP devIt = createHLineIteratorNG(r.x(), r.y(), r.width());
KisHLineConstIteratorSP selectionIt = selection->projection()->createHLineConstIteratorNG(r.x(), r.y(), r.width());
const quint8* defaultPixel_ = defaultPixel();
bool transparentDefault = (colorSpace->opacityU8(defaultPixel_) == OPACITY_TRANSPARENT_U8);
const KoColor defaultPixel = this->defaultPixel();
bool transparentDefault = (defaultPixel.opacityU8() == OPACITY_TRANSPARENT_U8);
for (qint32 y = 0; y < r.height(); y++) {
do {
// XXX: Optimize by using stretches
colorSpace->applyInverseAlphaU8Mask(devIt->rawData(), selectionIt->rawDataConst(), 1);
if (transparentDefault && colorSpace->opacityU8(devIt->rawData()) == OPACITY_TRANSPARENT_U8) {
memcpy(devIt->rawData(), defaultPixel_, colorSpace->pixelSize());
memcpy(devIt->rawData(), defaultPixel.data(), colorSpace->pixelSize());
}
} while (devIt->nextPixel() && selectionIt->nextPixel());
devIt->nextRow();
......@@ -1973,16 +1981,16 @@ QPoint KisPaintDeviceFramesInterface::frameOffset(int frameId) const
return q->m_d->frameOffset(frameId);
}
void KisPaintDeviceFramesInterface::setFrameDefaultPixel(const quint8 *defPixel, int frameId)
void KisPaintDeviceFramesInterface::setFrameDefaultPixel(const KoColor &defPixel, int frameId)
{
KIS_ASSERT_RECOVER_RETURN(frameId >= 0);
q->m_d->setFrameDefaultPixel(defPixel, frameId);
}
const quint8* KisPaintDeviceFramesInterface::frameDefaultPixel(int frameId) const
KoColor KisPaintDeviceFramesInterface::frameDefaultPixel(int frameId) const
{
KIS_ASSERT_RECOVER(frameId >= 0) {
return (quint8*)"deadbeef";
return KoColor(Qt::red, q->m_d->colorSpace());
}
return q->m_d->frameDefaultPixel(frameId);
}
......
......@@ -281,14 +281,14 @@ public:
* caller still owns the pointer and needs to delete it to avoid memory leaks.
* If frame ID is given, set default pixel for that frame. Otherwise use active frame.
*/
void setDefaultPixel(const quint8 *defPixel);
void setDefaultPixel(const KoColor &defPixel);
/**
* Get a pointer to the default pixel.
* If the frame parameter is given, get the default pixel of
* specified frame. Otherwise use currently active frame.
*/
const quint8 *defaultPixel() const;
KoColor defaultPixel() const;
/**
* Fill the given rectangle with the given pixel. The paint device will expand to
......
......@@ -86,12 +86,12 @@ public:
/**
* Sets default pixel for \p frameId
*/
void setFrameDefaultPixel(const quint8 *defPixel, int frameId);
void setFrameDefaultPixel(const KoColor &defPixel, int frameId);
/**
* @return default pixel for \p frameId
*/
const quint8* frameDefaultPixel(int frameId) const;
KoColor frameDefaultPixel(int frameId) const;
/**
* Write a \p frameId onto \p store
......
......@@ -52,8 +52,7 @@ public:
y += m_d->y();
extent = QRect(x, y, w, h);
quint8 defaultOpacity =
m_device->colorSpace()->opacityU8(m_device->defaultPixel());
quint8 defaultOpacity = m_device->defaultPixel().opacityU8();
if (defaultOpacity != OPACITY_TRANSPARENT_U8)
extent |= m_d->defaultBounds->bounds();
......
......@@ -257,7 +257,7 @@ void KisPixelSelection::intersectSelection(KisPixelSelectionSP selection)
void KisPixelSelection::clear(const QRect & r)
{
if (*defaultPixel() != MIN_SELECTED) {
if (*defaultPixel().data() != MIN_SELECTED) {
KisFillPainter painter(KisPaintDeviceSP(this));
const KoColorSpace * cs = KoColorSpaceRegistry::instance()->rgb8();
painter.fillRect(r, KoColor(Qt::white, cs), MIN_SELECTED);
......@@ -277,8 +277,7 @@ void KisPixelSelection::clear(const QRect & r)
void KisPixelSelection::clear()
{
quint8 defPixel = MIN_SELECTED;
setDefaultPixel(&defPixel);
setDefaultPixel(KoColor(Qt::transparent, colorSpace()));
KisPaintDevice::clear();
m_d->outlineCacheValid = true;
......@@ -301,8 +300,8 @@ void KisPixelSelection::invert()
*(it.rawData()) = MAX_SELECTED - *(it.rawData());
} while (it.nextPixel());
}
quint8 defPixel = MAX_SELECTED - *defaultPixel();
setDefaultPixel(&defPixel);
quint8 defPixel = MAX_SELECTED - *defaultPixel().data();
setDefaultPixel(KoColor(&defPixel, colorSpace()));
if (m_d->outlineCacheValid) {
QPainterPath path;
......@@ -339,7 +338,7 @@ void KisPixelSelection::move(const QPoint &pt)
bool KisPixelSelection::isTotallyUnselected(const QRect & r) const
{
if (*defaultPixel() != MIN_SELECTED)
if (*defaultPixel().data() != MIN_SELECTED)
return false;
QRect sr = selectedExactRect();
return ! r.intersects(sr);
......@@ -365,7 +364,7 @@ QVector<QPolygon> KisPixelSelection::outline() const
* value sane we should limit the calculated area by the bounds of
* the image.
*/
if (*defaultPixel() != MIN_SELECTED) {
if (*defaultPixel().data() != MIN_SELECTED) {
selectionExtent &= defaultBounds()->bounds();
}
......@@ -395,7 +394,7 @@ QVector<QPolygon> KisPixelSelection::outline() const
bool KisPixelSelection::isEmpty() const
{
return *defaultPixel() == MIN_SELECTED && selectedRect().isEmpty();
return *defaultPixel().data() == MIN_SELECTED && selectedRect().isEmpty();
}
QPainterPath KisPixelSelection::outlineCache() const
......
......@@ -85,8 +85,7 @@ KisSelectionBasedLayer::~KisSelectionBasedLayer()
void KisSelectionBasedLayer::initSelection()
{
m_d->selection = new KisSelection(new KisDefaultBounds(image()));
quint8 newDefaultPixel = MAX_SELECTED;
m_d->selection->pixelSelection()->setDefaultPixel(&newDefaultPixel);
m_d->selection->pixelSelection()->setDefaultPixel(KoColor(Qt::white, m_d->selection->pixelSelection()->colorSpace()));
m_d->selection->setParentNode(this);
m_d->selection->updateProjection();
}
......
......@@ -478,7 +478,8 @@ void mirror_impl(KisPaintDeviceSP dev, qreal axis, bool isHorizontal)
KisRandomAccessorSP leftIt = dev->createRandomAccessorNG(mirrorRect.x(), mirrorRect.y());
KisRandomAccessorSP rightIt = dev->createRandomAccessorNG(mirrorRect.x(), mirrorRect.y());
const quint8 *defaultPixel = dev->defaultPixel();
const KoColor defaultPixelObject = dev->defaultPixel();
const quint8 *defaultPixel = defaultPixelObject.data();
const int pixelSize = dev->pixelSize();
QByteArray buf(pixelSize, 0);
......
......@@ -80,7 +80,7 @@ void paintBevelSelection(KisPixelSelectionSP srcSelection,
quint8 selectedness = invert ?
qRound(qreal(size - i - 1) / size * 255.0) :
qRound(qreal(i + 1) / size * 255.0);
fillDevice->setDefaultPixel(&selectedness);
fillDevice->setDefaultPixel(KoColor(&selectedness, fillDevice->colorSpace()));
tmpSelection->makeCloneFromRough(srcSelection, srcSelection->selectedRect());
......@@ -421,7 +421,7 @@ void KisLsBevelEmbossFilter::applyBevelEmboss(KisPaintDeviceSP srcDevice,
const KoColor fillColor(config->shadowColor(), dstDevice->colorSpace());
const QRect &fillRect = d.shadowHighlightsFinalRect;
KisPaintDeviceSP fillDevice = new KisPaintDevice(dstDevice->colorSpace());
fillDevice->setDefaultPixel(fillColor.data());
fillDevice->setDefaultPixel(fillColor);
KisPainter gc(dstDevice);
gc.setSelection(baseSelection);
......@@ -444,7 +444,7 @@ void KisLsBevelEmbossFilter::applyBevelEmboss(KisPaintDeviceSP srcDevice,
const KoColor fillColor(config->highlightColor(), dstDevice->colorSpace());
const QRect &fillRect = d.shadowHighlightsFinalRect;
KisPaintDeviceSP fillDevice = new KisPaintDevice(dstDevice->colorSpace());
fillDevice->setDefaultPixel(fillColor.data());
fillDevice->setDefaultPixel(fillColor);
KisPainter gc(dstDevice);
gc.setSelection(baseSelection);
gc.setCompositeOp(COMPOSITE_OVER);
......
......@@ -419,7 +419,7 @@ namespace KisLsUtils
{
if (config->fillType() == psd_fill_solid_color) {
KoColor color(config->color(), fillDevice->colorSpace());
fillDevice->setDefaultPixel(color.data());
fillDevice->setDefaultPixel(color);
} else if (config->fillType() == psd_fill_pattern) {
fillPattern(fillDevice, applyRect, env,
......
......@@ -759,7 +759,7 @@ void KisPaintDeviceTest::testNonDefaultPixelArea()
QVERIFY(dev->nonDefaultPixelArea().isEmpty());
KoColor defPixel(Qt::red, cs);
dev->setDefaultPixel(defPixel.data());
dev->setDefaultPixel(defPixel);
QCOMPARE(dev->exactBounds(), KisDefaultBounds::infiniteRect);
QVERIFY(dev->nonDefaultPixelArea().isEmpty());
......@@ -796,7 +796,7 @@ void KisPaintDeviceTest::testExactBoundsNonTransparent()
QRect imageRect(0,0,1000,1000);
KoColor defPixel(Qt::red, cs);
dev->setDefaultPixel(defPixel.data());
dev->setDefaultPixel(defPixel);
QCOMPARE(dev->exactBounds(), imageRect);
QVERIFY(dev->nonDefaultPixelArea().isEmpty());
......
......@@ -269,7 +269,7 @@ void KisSelectionTest::testSelectionExactBounds()
KisSelectionSP selection = new KisSelection(new KisSelectionDefaultBounds(device, image));
quint8 defaultPixel = MAX_SELECTED;
selection->pixelSelection()->setDefaultPixel(&defaultPixel);
selection->pixelSelection()->setDefaultPixel(KoColor(&defaultPixel, selection->pixelSelection()->colorSpace()));
// the selection uses device's extent only for performance reasons
// \see bug 320213
......
......@@ -2319,7 +2319,7 @@ bool KisDocument::newImage(const QString& name,
image->setDefaultProjectionColor(KoColor(cs));
if (bgColor.opacityU8() == OPACITY_OPAQUE_U8) {
layer->paintDevice()->setDefaultPixel(bgColor.data());
layer->paintDevice()->setDefaultPixel(bgColor);
} else {
// Hack: with a semi-transparent background color, the projection isn't composited right if we just set the default pixel
KisFillPainter painter;
......
......@@ -390,7 +390,7 @@ struct SimpleDevicePolicy
return dev->read(stream);
}
void setDefaultPixel(KisPaintDeviceSP dev, const quint8 *defaultPixel) const {
void setDefaultPixel(KisPaintDeviceSP dev, const KoColor &defaultPixel) const {
return dev->setDefaultPixel(defaultPixel);
}
};
......@@ -404,7 +404,7 @@ struct FramedDevicePolicy
return dev->framesInterface()->readFrame(stream, m_frameId);
}
void setDefaultPixel(KisPaintDeviceSP dev, const quint8 *defaultPixel) const {
void setDefaultPixel(KisPaintDeviceSP dev, const KoColor &defaultPixel) const {
return dev->framesInterface()->setFrameDefaultPixel(defaultPixel, m_frameId);
}
......@@ -459,10 +459,9 @@ bool KisKraLoadVisitor::loadPaintDeviceFrame(KisPaintDeviceSP device, const QStr
if (m_store->open(location + ".defaultpixel")) {
int pixelSize = device->colorSpace()->pixelSize();
if (m_store->size() == pixelSize) {
quint8 *defPixel = new quint8[pixelSize];
m_store->read((char*)defPixel, pixelSize);
policy.setDefaultPixel(device, defPixel);
delete[] defPixel;
KoColor color(Qt::transparent, device->colorSpace());
m_store->read((char*)color.data(), pixelSize);
policy.setDefaultPixel(device, color);
}
m_store->close();
}
......
......@@ -307,7 +307,7 @@ struct SimpleDevicePolicy
return dev->write(store);
}
const quint8* defaultPixel(KisPaintDeviceSP dev) const {
KoColor defaultPixel(KisPaintDeviceSP dev) const {
return dev->defaultPixel();
}
};
......@@ -321,7 +321,7 @@ struct FramedDevicePolicy
return dev->framesInterface()->writeFrame(store, m_frameId);
}
const quint8* defaultPixel(KisPaintDeviceSP dev) const {
KoColor defaultPixel(KisPaintDeviceSP dev) const {
return dev->framesInterface()->frameDefaultPixel(m_frameId);
}
......@@ -377,7 +377,7 @@ bool KisKraSaveVisitor::savePaintDeviceFrame(KisPaintDeviceSP device, QString lo
m_store->close();
}
if (m_store->open(location + ".defaultpixel")) {
m_store->write((char*)policy.defaultPixel(device), device->colorSpace()->pixelSize());
m_store->write((char*)policy.defaultPixel(device).data(), device->colorSpace()->pixelSize());
m_store->close();
}
......
......@@ -149,7 +149,7 @@ void KisKraLoaderTest::testLoadAnimated()
QCOMPARE(dev->exactBounds(), QRect(506, 378, 198, 198));
QCOMPARE(dev->x(), -26);
QCOMPARE(dev->y(), -128);
QVERIFY(!memcmp(dev->defaultPixel(), transparent.data(), cs->pixelSize()));
QCOMPARE(dev->defaultPixel(), transparent);
image->animationInterface()->switchCurrentTimeAsync(20);
image->waitForDone();
......@@ -157,7 +157,7 @@ void KisKraLoaderTest::testLoadAnimated()
QCOMPARE(dev->nonDefaultPixelArea(), QRect(615, 416, 129, 129));
QCOMPARE(dev->x(), 502);
QCOMPARE(dev->y(), 224);
QVERIFY(!memcmp(dev->defaultPixel(), white.data(), cs->pixelSize()));
QCOMPARE(dev->defaultPixel(), white);
image->animationInterface()->switchCurrentTimeAsync(30);
image->waitForDone();
......@@ -165,7 +165,7 @@ void KisKraLoaderTest::testLoadAnimated()
QCOMPARE(dev->nonDefaultPixelArea(), QRect(729, 452, 45, 44));
QCOMPARE(dev->x(), 645);
QCOMPARE(dev->y(), -10);
QVERIFY(!memcmp(dev->defaultPixel(), red.data(), cs->pixelSize()));
QCOMPARE(dev->defaultPixel(), red);
}
......
......@@ -257,7 +257,7 @@ void KisKraSaverTest::testRoundTripAnimation()
image->addNode(layer1);
layer1->paintDevice()->fill(QRect(100, 100, 50, 50), KoColor(Qt::black, cs));
layer1->paintDevice()->setDefaultPixel(KoColor(Qt::red, cs).data());
layer1->paintDevice()->setDefaultPixel(KoColor(Qt::red, cs));
KUndo2Command parentCommand;
......@@ -268,14 +268,14 @@ void KisKraSaverTest::testRoundTripAnimation()
image->waitForDone();
layer1->paintDevice()->fill(QRect(200, 50, 10, 10), KoColor(Qt::black, cs));
layer1->paintDevice()->move(25, 15);
layer1->paintDevice()->setDefaultPixel(KoColor(Qt::green, cs).data());
layer1->paintDevice()->setDefaultPixel(KoColor(Qt::green, cs));
rasterChannel->addKeyframe(20, &parentCommand);
image->animationInterface()->switchCurrentTimeAsync(20);
image->waitForDone();
layer1->paintDevice()->fill(QRect(150, 200, 30, 30), KoColor(Qt::black, cs));
layer1->paintDevice()->move(100, 50);
layer1->paintDevice()->setDefaultPixel(KoColor(Qt::blue, cs).data());
layer1->paintDevice()->setDefaultPixel(KoColor(Qt::blue, cs));
QScopedPointer<KisDocument> doc(KisPart::instance()->createDocument());
doc->setCurrentImage(image);
......@@ -300,7 +300,7 @@ void KisKraSaverTest::testRoundTripAnimation()
QCOMPARE(layer2->paintDevice()->nonDefaultPixelArea(), QRect(64, 64, 128, 128));
QCOMPARE(layer2->paintDevice()->x(), 0);
QCOMPARE(layer2->paintDevice()->y(), 0);
QVERIFY(!memcmp(layer2->paintDevice()->defaultPixel(), KoColor(Qt::red, cs).data(), cs->pixelSize()));
QCOMPARE(layer2->paintDevice()->defaultPixel(), KoColor(Qt::red, cs));
image2->animationInterface()->switchCurrentTimeAsync(10);
image2->waitForDone();
......@@ -308,7 +308,7 @@ void KisKraSaverTest::testRoundTripAnimation()
QCOMPARE(layer2->paintDevice()->nonDefaultPixelArea(), QRect(217, 15, 64, 64));
QCOMPARE(layer2->paintDevice()->x(), 25);
QCOMPARE(layer2->paintDevice()->y(), 15);
QVERIFY(!memcmp(layer2->paintDevice()->defaultPixel(), KoColor(Qt::green, cs).data(), cs->pixelSize()));
QCOMPARE(layer2->paintDevice()->defaultPixel(), KoColor(Qt::green, cs));
image2->animationInterface()->switchCurrentTimeAsync(20);
image2->waitForDone();
......@@ -316,7 +316,7 @@ void KisKraSaverTest::testRoundTripAnimation()
QCOMPARE(layer2->paintDevice()->nonDefaultPixelArea(), QRect(228, 242, 64, 64));
QCOMPARE(layer2->paintDevice()->x(), 100);
QCOMPARE(layer2->paintDevice()->y(), 50);
QVERIFY(!memcmp(layer2->paintDevice()->defaultPixel(), KoColor(Qt::blue, cs).data(), cs->pixelSize()));
QCOMPARE(layer2->paintDevice()->defaultPixel(), KoColor(Qt::blue, cs));
}
......
......@@ -425,7 +425,7 @@ void KisScratchPad::fillDefault()
if(!m_paintLayer) return;
KisPaintDeviceSP paintDevice = m_paintLayer->paintDevice();
paintDevice->setDefaultPixel(m_defaultColor.data());
paintDevice->setDefaultPixel(m_defaultColor);
paintDevice->clear();
update();
}
......@@ -459,8 +459,7 @@ void KisScratchPad::fillBackground()
if(!m_paintLayer) return;
KisPaintDeviceSP paintDevice = m_paintLayer->paintDevice();
KoColor c(m_resourceProvider->bgColor(), paintDevice->colorSpace());
paintDevice->setDefaultPixel(c.data());
paintDevice->setDefaultPixel(m_resourceProvider->bgColor());
paintDevice->clear();
update();
}
......
......@@ -23,6 +23,8 @@
#include <QBuffer>
#include <QDataStream>
#include <QStringList>
#include <KoColor.h>
#include <kis_debug.h>
#include <kis_node.h>
......@@ -541,7 +543,7 @@ void PSDLayerRecord::write(QIODevice* io,
{
KIS_ASSERT_RECOVER_NOOP(m_onlyTransparencyMask->paintDevice()->pixelSize() == 1);
const quint8 defaultPixel = *m_onlyTransparencyMask->paintDevice()->defaultPixel();
const quint8 defaultPixel = *m_onlyTransparencyMask->paintDevice()->defaultPixel().data();
SAFE_WRITE_EX(io, defaultPixel);
}
......@@ -711,7 +713,7 @@ bool PSDLayerRecord::readMask(QIODevice *io, KisPaintDeviceSP dev, ChannelInfo *
// the device must be a pixel selection
KIS_ASSERT_RECOVER(dev->pixelSize() == 1) { return false; }
dev->setDefaultPixel(&layerMask.defaultColor);
dev->setDefaultPixel(KoColor(&layerMask.defaultColor, dev->colorSpace()));
int uncompressedLength = maskRect.width();
......
......@@ -315,8 +315,7 @@ void addBackgroundIfNeeded(KisNodeSP root, QList<FlattenedNode> &nodes)
i18nc("Automatically created layer name when saving into PSD", "Background"),
OPACITY_OPAQUE_U8);
projectionColor.convertTo(layer->paintDevice()->colorSpace());
layer->paintDevice()->setDefaultPixel(projectionColor.data());
layer->paintDevice()->setDefaultPixel(projectionColor);