Commit 06275f19 authored by Silvio Heinrich's avatar Silvio Heinrich

Reduced code duplication.

parent 4253ef35
......@@ -251,61 +251,40 @@ bool KoColorSpace::convertPixelsTo(const quint8 * src,
}
void KoColorSpace::bitBlt(quint8 *dst,
void KoColorSpace::bitBlt(quint8* dst,
qint32 dststride,
const KoColorSpace * srcSpace,
const quint8 *src,
const KoColorSpace* srcSpace,
const quint8* src,
qint32 srcRowStride,
const quint8 *srcAlphaMask,
const quint8* srcAlphaMask,
qint32 maskRowStride,
quint8 opacity,
quint8 flow,
qint32 rows,
qint32 cols,
const QString & op,
const QBitArray & channelFlags) const
const QString& op,
const QBitArray& channelFlags) const
{
if (d->compositeOps.contains(op)) {
bitBlt(dst, dststride, srcSpace, src, srcRowStride, srcAlphaMask, maskRowStride, opacity, flow, rows, cols, d->compositeOps.value(op), channelFlags);
} else {
bitBlt(dst, dststride, srcSpace, src, srcRowStride, srcAlphaMask, maskRowStride, opacity, flow, rows, cols, d->compositeOps.value(COMPOSITE_OVER), channelFlags);
}
}
void KoColorSpace::bitBlt(quint8 *dst,
qint32 dststride,
const KoColorSpace * srcSpace,
const quint8 *src,
qint32 srcRowStride,
const quint8 *srcAlphaMask,
qint32 maskRowStride,
quint8 opacity,
quint8 flow,
qint32 rows,
qint32 cols,
const QString& op) const
{
if (d->compositeOps.contains(op)) {
bitBlt(dst, dststride, srcSpace, src, srcRowStride, srcAlphaMask, maskRowStride, opacity, flow, rows, cols, d->compositeOps.value(op));
} else {
bitBlt(dst, dststride, srcSpace, src, srcRowStride, srcAlphaMask, maskRowStride, opacity, flow, rows, cols, d->compositeOps.value(COMPOSITE_OVER));
}
}
void KoColorSpace::bitBlt(quint8 *dst,
void KoColorSpace::bitBlt(quint8* dst,
qint32 dstRowStride,
const KoColorSpace * srcSpace,
const quint8 *src,
const KoColorSpace* srcSpace,
const quint8* src,
qint32 srcRowStride,
const quint8 *srcAlphaMask,
const quint8* srcAlphaMask,
qint32 maskRowStride,
quint8 opacity,
quint8 flow,
qint32 rows,
qint32 cols,
const KoCompositeOp * op,
const QBitArray & channelFlags) const
const KoCompositeOp* op,
const QBitArray& channelFlags) const
{
Q_ASSERT_X(*op->colorSpace() == *this, "KoColorSpace::bitBlt", QString("Composite op is for color space %1 (%2) while this is %3 (%4)").arg(op->colorSpace()->id()).arg(op->colorSpace()->profile()->name()).arg(id()).arg(profile()->name()).toLatin1());
......@@ -341,56 +320,6 @@ void KoColorSpace::bitBlt(quint8 *dst,
}
// XXX: I don't want this code duplication, but also don't want an
// extra function call in this critical section of code. What to
// do?
void KoColorSpace::bitBlt(quint8 *dst,
qint32 dstRowStride,
const KoColorSpace * srcSpace,
const quint8 *src,
qint32 srcRowStride,
const quint8 *srcAlphaMask,
qint32 maskRowStride,
quint8 opacity,
quint8 flow,
qint32 rows,
qint32 cols,
const KoCompositeOp * op) const
{
Q_ASSERT(*op->colorSpace() == *this);
if (rows <= 0 || cols <= 0)
return;
if (this != srcSpace) {
quint32 conversionBufferStride = cols * pixelSize();
QVector<quint8> * conversionCache =
threadLocalConversionCache(rows * conversionBufferStride);
quint8* conversionData = conversionCache->data();
for (qint32 row = 0; row < rows; row++) {
srcSpace->convertPixelsTo(src + row * srcRowStride,
conversionData + row * conversionBufferStride, this,
cols);
}
op->composite(dst, dstRowStride,
conversionData, conversionBufferStride,
srcAlphaMask, maskRowStride,
rows, cols,
opacity, flow);
} else {
op->composite(dst, dstRowStride,
src, srcRowStride,
srcAlphaMask, maskRowStride,
rows, cols,
opacity, flow);
}
}
QVector<quint8> * KoColorSpace::threadLocalConversionCache(quint32 size) const
{
QVector<quint8> * ba = 0;
......
......@@ -497,10 +497,10 @@ public:
* @param channelFlags a bit array reflecting which channels will be composited and which
* channels won't. The order is pixel order, not colorspace order.
*/
virtual void bitBlt(quint8 *dst,
virtual void bitBlt(quint8* dst,
qint32 dststride,
const KoColorSpace * srcSpace,
const quint8 *src,
const KoColorSpace* srcSpace,
const quint8* src,
qint32 srcRowStride,
const quint8 *srcAlphaMask,
qint32 maskRowStride,
......@@ -508,58 +508,24 @@ public:
quint8 flow,
qint32 rows,
qint32 cols,
const KoCompositeOp * op,
const QBitArray & channelFlags) const;
/**
* Convenience function for the above where all channels are turned on.
*/
virtual void bitBlt(quint8 *dst,
qint32 dststride,
const KoColorSpace * srcSpace,
const quint8 *src,
qint32 srcRowStride,
const quint8 *srcAlphaMask,
qint32 maskRowStride,
quint8 opacity,
quint8 flow,
qint32 rows,
qint32 cols,
const KoCompositeOp * op) const;
const KoCompositeOp* op,
const QBitArray& channelFlags=QBitArray()) const;
/**
* Convenience function for the above if you don't have the composite op object yet.
*/
virtual void bitBlt(quint8 *dst,
virtual void bitBlt(quint8* dst,
qint32 dststride,
const KoColorSpace * srcSpace,
const quint8 *src,
const KoColorSpace* srcSpace,
const quint8* src,
qint32 srcRowStride,
const quint8 *srcAlphaMask,
const quint8* srcAlphaMask,
qint32 maskRowStride,
quint8 opacity,
quint8 flow,
qint32 rows,
qint32 cols,
const QString & op,
const QBitArray & channelFlags) const;
/**
* Convenience function for the above, if you simply want all channels composited
*/
virtual void bitBlt(quint8 *dst,
qint32 dststride,
const KoColorSpace * srcSpace,
const quint8 *src,
qint32 srcRowStride,
const quint8 *srcAlphaMask,
qint32 maskRowStride,
quint8 opacity,
quint8 flow,
qint32 rows,
qint32 cols,
const QString& op) const;
const QString& op,
const QBitArray& channelFlags=QBitArray()) const;
/**
* Serialize this color following Create's swatch color specification available
......
......@@ -250,19 +250,6 @@ KoCompositeOp::KoCompositeOp(const KoColorSpace * cs, const QString& id, const
}
}
void KoCompositeOp::composite(quint8 *dstRowStart, qint32 dstRowStride,
const quint8 *srcRowStart, qint32 srcRowStride,
const quint8 *maskRowStart, qint32 maskRowStride,
qint32 rows, qint32 numColumns,
quint8 opacity, quint8 flow) const
{
composite(dstRowStart, dstRowStride,
srcRowStart, srcRowStride,
maskRowStart, maskRowStride,
rows, numColumns,
opacity, flow, d->defaultChannelFlags);
}
void KoCompositeOp::composite(quint8 *dstRowStart, qint32 dstRowStride,
const quint8 *srcRowStart, qint32 srcRowStride,
const quint8 *maskRowStart, qint32 maskRowStride,
......
......@@ -22,8 +22,8 @@
#include <klocale.h>
#include <QString>
#include <QList>
#include <QMap>
#include <QMultiMap>
#include <QBitArray>
#include "pigment_export.h"
......@@ -249,16 +249,7 @@ public:
const quint8 *maskRowStart, qint32 maskRowStride,
qint32 rows, qint32 numColumns,
quint8 opacity,
const QBitArray& channelFlags) const;
/**
* Same as previous, but without channelFlags parameter
*/
void composite(quint8 *dstRowStart, qint32 dstRowStride,
const quint8 *srcRowStart, qint32 srcRowStride,
const quint8 *maskRowStart, qint32 maskRowStride,
qint32 rows, qint32 numColumns,
quint8 opacity=255, quint8 flow=255) const;
const QBitArray& channelFlags=QBitArray()) const;
private:
KoCompositeOp();
......
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