vcl/source/bitmap/BitmapScaleConvolutionFilter.cxx | 29 ++++++++++----------- 1 file changed, 15 insertions(+), 14 deletions(-)
New commits: commit 36b26c1ee6aff5b5101f45067736bd619fb56171 Author: Noel Grandin <[email protected]> AuthorDate: Tue Jun 25 12:53:28 2019 +0200 Commit: Xisco Faulí <[email protected]> CommitDate: Wed Jun 26 10:33:05 2019 +0200 tdf#125892 improve time to export PDF, use int ops for scaling The time here is all in the nice rescaling we do these days. Speed it up by using int ops instead of float ops. This takes the time from 5m to 1m30 for me. Change-Id: Ic1dcd9e49eef1894f4a4fdb416015b69c6ef96da Reviewed-on: https://gerrit.libreoffice.org/74689 Tested-by: Jenkins Reviewed-by: Noel Grandin <[email protected]> (cherry picked from commit d1c075c6a7002521129bddb5860f20746f168a29) Reviewed-on: https://gerrit.libreoffice.org/74727 Reviewed-by: Xisco Faulí <[email protected]> diff --git a/vcl/source/bitmap/BitmapScaleConvolutionFilter.cxx b/vcl/source/bitmap/BitmapScaleConvolutionFilter.cxx index 389b2a3b11b3..25196d61cc66 100644 --- a/vcl/source/bitmap/BitmapScaleConvolutionFilter.cxx +++ b/vcl/source/bitmap/BitmapScaleConvolutionFilter.cxx @@ -38,7 +38,7 @@ void ImplCalculateContributions( const long aSourceSize, const long aDestinationSize, long& aNumberOfContributions, - std::vector<double>& rWeights, + std::vector<sal_Int16>& rWeights, std::vector<sal_Int32>& rPixels, std::vector<sal_Int32>& rCounts, const Kernel& aKernel) @@ -76,7 +76,8 @@ void ImplCalculateContributions( const long aPixelIndex(MinMax(j, 0, aSourceSize - 1)); const long nIndex(aIndex + aCurrentCount); - rWeights[nIndex] = aWeight; + // scale the weight by 255 since we're converting from float to int + rWeights[nIndex] = aWeight * 255; rPixels[nIndex] = aPixelIndex; aCurrentCount++; @@ -102,7 +103,7 @@ bool ImplScaleConvolutionHor(Bitmap& rSource, Bitmap& rTarget, const double& rSc if(pReadAcc) { - std::vector<double> aWeights; + std::vector<sal_Int16> aWeights; std::vector<sal_Int32> aPixels; std::vector<sal_Int32> aCounts; long aNumberOfContributions(0); @@ -122,15 +123,15 @@ bool ImplScaleConvolutionHor(Bitmap& rSource, Bitmap& rTarget, const double& rSc for(long x(0); x < nNewWidth; x++) { const long aBaseIndex(x * aNumberOfContributions); - double aSum(0.0); - double aValueRed(0.0); - double aValueGreen(0.0); - double aValueBlue(0.0); + sal_Int32 aSum(0); + sal_Int32 aValueRed(0); + sal_Int32 aValueGreen(0); + sal_Int32 aValueBlue(0); for(long j(0); j < aCounts[x]; j++) { const long aIndex(aBaseIndex + j); - const double aWeight(aWeights[aIndex]); + const sal_Int16 aWeight(aWeights[aIndex]); BitmapColor aColor; aSum += aWeight; @@ -190,7 +191,7 @@ bool ImplScaleConvolutionVer(Bitmap& rSource, Bitmap& rTarget, const double& rSc if(pReadAcc) { - std::vector<double> aWeights; + std::vector<sal_Int16> aWeights; std::vector<sal_Int32> aPixels; std::vector<sal_Int32> aCounts; long aNumberOfContributions(0); @@ -214,15 +215,15 @@ bool ImplScaleConvolutionVer(Bitmap& rSource, Bitmap& rTarget, const double& rSc for(long y(0); y < nNewHeight; y++) { const long aBaseIndex(y * aNumberOfContributions); - double aSum(0.0); - double aValueRed(0.0); - double aValueGreen(0.0); - double aValueBlue(0.0); + sal_Int32 aSum(0); + sal_Int32 aValueRed(0); + sal_Int32 aValueGreen(0); + sal_Int32 aValueBlue(0); for(long j(0); j < aCounts[y]; j++) { const long aIndex(aBaseIndex + j); - const double aWeight(aWeights[aIndex]); + const sal_Int16 aWeight(aWeights[aIndex]); aSum += aWeight; const BitmapColor & aColor = aScanline[aPixels[aIndex]]; aValueRed += aWeight * aColor.GetRed(); _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
