Commit 8ee02989 authored by Sven Langkamp's avatar Sven Langkamp

fallback to old code if mask generator doesn't use vc

parent 8509fa17
......@@ -62,6 +62,11 @@ bool KisMaskGenerator::shouldSupersample() const
return false;
}
bool KisMaskGenerator::shouldVectorize() const
{
return false;
}
void KisMaskGenerator::toXML(QDomDocument& doc, QDomElement& e) const
{
Q_UNUSED(doc);
......
......@@ -68,11 +68,13 @@ public:
*/
virtual quint8 valueAt(qreal x, qreal y) const = 0;
virtual void processRowFast(float* buffer, int width, float y, float cosa, float sina,
float centerX, float centerY, float invScaleX, float invScaleY) {}
virtual void processRowFast(float* /*buffer*/, int /*width*/, float /*y*/, float /*cosa*/, float /*sina*/,
float /*centerX*/, float /*centerY*/, float /*invScaleX*/, float /*invScaleY*/) {}
virtual bool shouldSupersample() const;
virtual bool shouldVectorize() const;
virtual void toXML(QDomDocument& , QDomElement&) const;
/**
......
......@@ -58,6 +58,12 @@ bool KisCircleMaskGenerator::shouldSupersample() const
return width() < 10 || KisMaskGenerator::d->ratio * width() < 10;
}
bool KisCircleMaskGenerator::shouldVectorize() const
{
return !shouldSupersample();
}
quint8 KisCircleMaskGenerator::valueAt(qreal x, qreal y) const
{
if (KisMaskGenerator::d->empty) return 255;
......
......@@ -43,6 +43,8 @@ public:
virtual bool shouldSupersample() const;
virtual bool shouldVectorize() const;
virtual void toXML(QDomDocument& , QDomElement&) const;
virtual void setSoftness(qreal softness);
......
......@@ -77,6 +77,14 @@ struct MaskProcessor
}
void process(QRect& rect){
if (m_shape->shouldVectorize()) {
processParallel(rect);
} else {
processScalar(rect);
}
}
void processScalar(QRect& rect){
qreal random = 1.0;
quint8* dabPointer = m_device->data() + rect.y() * rect.width() * m_pixelSize;
quint8 alphaValue = OPACITY_TRANSPARENT_U8;
......@@ -122,47 +130,7 @@ struct MaskProcessor
}//endfor y
}
KisFixedPaintDeviceSP m_device;
const KoColorSpace* m_cs;
qreal m_randomness;
qreal m_density;
quint32 m_pixelSize;
double m_centerX;
double m_centerY;
double m_invScaleX;
double m_invScaleY;
double m_cosa;
double m_sina;
KisMaskGenerator* m_shape;
};
struct SIMDMaskProcessor
{
SIMDMaskProcessor(KisFixedPaintDeviceSP device, const KoColorSpace* cs, qreal randomness, qreal density,
double centerX, double centerY, double invScaleX, double invScaleY, double angle,
KisMaskGenerator* shape)
: m_device(device)
, m_cs(cs)
, m_randomness(randomness)
, m_density(density)
, m_pixelSize(cs->pixelSize())
, m_centerX(centerX)
, m_centerY(centerY)
, m_invScaleX(invScaleX)
, m_invScaleY(invScaleY)
, m_shape(shape)
{
m_cosa = cos(angle);
m_sina = sin(angle);
}
void operator()(QRect& rect)
{
process(rect);
}
void process(QRect& rect){
void processParallel(QRect& rect){
qreal random = 1.0;
quint8* dabPointer = m_device->data() + rect.y() * rect.width() * m_pixelSize;
quint8 alphaValue = OPACITY_TRANSPARENT_U8;
......@@ -340,7 +308,7 @@ void KisAutoBrush::generateMaskAndApplyMaskOrCreateDab(KisFixedPaintDeviceSP dst
}
}//endfor y
SIMDMaskProcessor s(dst, cs, d->randomness, d->density, centerX, centerY, invScaleX, invScaleY, angle, d->shape);
MaskProcessor s(dst, cs, d->randomness, d->density, centerX, centerY, invScaleX, invScaleY, angle, d->shape);
int jobs = d->idealThreadCountCached;
if(dstHeight > 100 && jobs >= 4) {
int splitter = dstHeight/jobs;
......
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