diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-06-25 12:53:28 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-06-25 15:36:01 +0200 |
commit | d1c075c6a7002521129bddb5860f20746f168a29 (patch) | |
tree | 41c4b8e6e76c1c7478b94508f7df5b9b4150c556 /vcl | |
parent | 4583911575edf98ccd5b15af8eafa6a3a7b64034 (diff) |
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 <noel.grandin@collabora.co.uk>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/source/bitmap/BitmapScaleConvolutionFilter.cxx | 29 |
1 files changed, 15 insertions, 14 deletions
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(); |