Commit d7971a94 authored by Boudewijn Rempt's avatar Boudewijn Rempt

Revert "Optimize Sharp brushes by 5% more"

This reverts commit e6545fdf.
parent e0cf4c2f
...@@ -60,17 +60,19 @@ void KisMaskGeneratorBenchmark::benchmarkCircle() ...@@ -60,17 +60,19 @@ void KisMaskGeneratorBenchmark::benchmarkCircle()
#include "krita_utils.h" #include "krita_utils.h"
void benchmarkSIMD(qreal fade) { void KisMaskGeneratorBenchmark::benchmarkSIMD()
{
#ifdef HAVE_VC
const KoColorSpace * cs = KoColorSpaceRegistry::instance()->rgb8(); const KoColorSpace * cs = KoColorSpaceRegistry::instance()->rgb8();
KisFixedPaintDeviceSP dev = new KisFixedPaintDevice(cs); KisFixedPaintDeviceSP dev = new KisFixedPaintDevice(cs);
dev->setRect(QRect(0, 0, 1000, 1000)); dev->setRect(QRect(0, 0, 100, 100));
dev->initialize(); dev->initialize();
MaskProcessingData data(dev, cs, MaskProcessingData data(dev, cs,
0.0, 1.0, 0.0, 1.0,
500, 500, 0); 50, 50, 0);
KisCircleMaskGenerator gen(1000, 1.0, fade, fade, 2, false); KisCircleMaskGenerator gen(100, 0.5, 0.5, 0.5, 2, false);
KisBrushMaskApplicatorBase *applicator = gen.applicator(); KisBrushMaskApplicatorBase *applicator = gen.applicator();
applicator->initializeData(&data); applicator->initializeData(&data);
...@@ -82,16 +84,7 @@ void benchmarkSIMD(qreal fade) { ...@@ -82,16 +84,7 @@ void benchmarkSIMD(qreal fade) {
applicator->process(rc); applicator->process(rc);
} }
} }
} #endif
void KisMaskGeneratorBenchmark::benchmarkSIMD_SharpBrush()
{
benchmarkSIMD(1.0);
}
void KisMaskGeneratorBenchmark::benchmarkSIMD_FadedBrush()
{
benchmarkSIMD(0.5);
} }
void KisMaskGeneratorBenchmark::benchmarkSquare() void KisMaskGeneratorBenchmark::benchmarkSquare()
......
...@@ -26,10 +26,9 @@ class KisMaskGeneratorBenchmark : public QObject ...@@ -26,10 +26,9 @@ class KisMaskGeneratorBenchmark : public QObject
Q_OBJECT Q_OBJECT
private Q_SLOTS: private Q_SLOTS:
void benchmarkCircle(); void benchmarkCircle();
void benchmarkSIMD_SharpBrush(); void benchmarkSIMD();
void benchmarkSIMD_FadedBrush();
void benchmarkSquare(); void benchmarkSquare();
}; };
#endif #endif
...@@ -61,7 +61,6 @@ FastRowProcessor::process<Vc::CurrentImplementation::current()>(float* buffer, i ...@@ -61,7 +61,6 @@ FastRowProcessor::process<Vc::CurrentImplementation::current()>(float* buffer, i
float centerX, float centerY) float centerX, float centerY)
{ {
const bool useSmoothing = d->copyOfAntialiasEdges; const bool useSmoothing = d->copyOfAntialiasEdges;
const bool noFading = d->noFading;
float y_ = y - centerY; float y_ = y - centerY;
float sinay_ = sina * y_; float sinay_ = sina * y_;
...@@ -85,7 +84,7 @@ FastRowProcessor::process<Vc::CurrentImplementation::current()>(float* buffer, i ...@@ -85,7 +84,7 @@ FastRowProcessor::process<Vc::CurrentImplementation::current()>(float* buffer, i
Vc::float_v vTransformedFadeX(d->transformedFadeX); Vc::float_v vTransformedFadeX(d->transformedFadeX);
Vc::float_v vTransformedFadeY(d->transformedFadeY); Vc::float_v vTransformedFadeY(d->transformedFadeY);
Vc::float_v vOne(Vc::One); Vc::float_v vOne(1.0f);
for (int i=0; i < width; i+= Vc::float_v::Size){ for (int i=0; i < width; i+= Vc::float_v::Size){
...@@ -99,30 +98,24 @@ FastRowProcessor::process<Vc::CurrentImplementation::current()>(float* buffer, i ...@@ -99,30 +98,24 @@ FastRowProcessor::process<Vc::CurrentImplementation::current()>(float* buffer, i
if (!outsideMask.isFull()) { if (!outsideMask.isFull()) {
if (noFading) { if (useSmoothing) {
Vc::float_v vFade(Vc::Zero); xr = Vc::abs(xr) + vOne;
vFade(outsideMask) = vOne; yr = Vc::abs(yr) + vOne;
vFade.store(bufferPointer, Vc::Aligned); }
} else {
if (useSmoothing) {
xr = Vc::abs(xr) + vOne;
yr = Vc::abs(yr) + vOne;
}
Vc::float_v vNormFade = pow2(xr * vTransformedFadeX) + pow2(yr * vTransformedFadeY); Vc::float_v vNormFade = pow2(xr * vTransformedFadeX) + pow2(yr * vTransformedFadeY);
//255 * n * (normeFade - 1) / (normeFade - n) //255 * n * (normeFade - 1) / (normeFade - n)
Vc::float_v vFade = n * (vNormFade - vOne) / (vNormFade - n); Vc::float_v vFade = n * (vNormFade - vOne) / (vNormFade - n);
// Mask in the inner circe of the mask // Mask in the inner circe of the mask
Vc::float_m mask = vNormFade < vOne; Vc::float_m mask = vNormFade < vOne;
vFade.setZero(mask); vFade.setZero(mask);
// Mask out the outer circe of the mask // Mask out the outer circe of the mask
vFade(outsideMask) = vOne; vFade(outsideMask) = vOne;
vFade.store(bufferPointer, Vc::Aligned); vFade.store(bufferPointer, Vc::Aligned);
}
} else { } else {
// Mask out everything outside the circle // Mask out everything outside the circle
vOne.store(bufferPointer, Vc::Aligned); vOne.store(bufferPointer, Vc::Aligned);
......
...@@ -70,10 +70,6 @@ void KisCircleMaskGenerator::setScale(qreal scaleX, qreal scaleY) ...@@ -70,10 +70,6 @@ void KisCircleMaskGenerator::setScale(qreal scaleX, qreal scaleY)
d->yfadecoef = (verticalFade() == 0) ? 1 : (2.0 / (verticalFade() * effectiveSrcHeight())); d->yfadecoef = (verticalFade() == 0) ? 1 : (2.0 / (verticalFade() * effectiveSrcHeight()));
d->transformedFadeX = KisMaskGenerator::softness() * d->xfadecoef; d->transformedFadeX = KisMaskGenerator::softness() * d->xfadecoef;
d->transformedFadeY = KisMaskGenerator::softness() * d->yfadecoef; d->transformedFadeY = KisMaskGenerator::softness() * d->yfadecoef;
d->noFading = !d->copyOfAntialiasEdges &&
qFuzzyCompare(d->xcoef, d->transformedFadeX) &&
qFuzzyCompare(d->ycoef, d->transformedFadeY);
} }
KisCircleMaskGenerator::~KisCircleMaskGenerator() KisCircleMaskGenerator::~KisCircleMaskGenerator()
......
...@@ -24,7 +24,6 @@ struct Q_DECL_HIDDEN KisCircleMaskGenerator::Private { ...@@ -24,7 +24,6 @@ struct Q_DECL_HIDDEN KisCircleMaskGenerator::Private {
double xfadecoef, yfadecoef; double xfadecoef, yfadecoef;
double transformedFadeX, transformedFadeY; double transformedFadeX, transformedFadeY;
bool copyOfAntialiasEdges; bool copyOfAntialiasEdges;
bool noFading;
KisBrushMaskApplicatorBase *applicator; KisBrushMaskApplicatorBase *applicator;
}; };
......
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