summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2019-04-27 09:43:28 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2019-04-29 08:30:07 +0200
commitbeacd77aa985ed90532cd5fdd7b56314c0a7b0eb (patch)
tree5ea23343cc56ee730d6daa5fdb55af1e03e802b4 /vcl
parent24503d5ddfc0a83ac88aa23d03b69ed47f989e8e (diff)
optimise ImplScaleConvolutionVer a little
cache the reading of the source scan line, and use sal_Int32 for pixels and counts (long is 64-bit on 64-bit linux) Change-Id: Iaa0abc3ed3316d3137184b0c051612874885ddf4 Reviewed-on: https://gerrit.libreoffice.org/71462 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/source/bitmap/BitmapScaleConvolutionFilter.cxx31
1 files changed, 13 insertions, 18 deletions
diff --git a/vcl/source/bitmap/BitmapScaleConvolutionFilter.cxx b/vcl/source/bitmap/BitmapScaleConvolutionFilter.cxx
index 7375d0260dfb..389b2a3b11b3 100644
--- a/vcl/source/bitmap/BitmapScaleConvolutionFilter.cxx
+++ b/vcl/source/bitmap/BitmapScaleConvolutionFilter.cxx
@@ -39,8 +39,8 @@ void ImplCalculateContributions(
const long aDestinationSize,
long& aNumberOfContributions,
std::vector<double>& rWeights,
- std::vector<long>& rPixels,
- std::vector<long>& rCounts,
+ std::vector<sal_Int32>& rPixels,
+ std::vector<sal_Int32>& rCounts,
const Kernel& aKernel)
{
const double fSamplingRadius(aKernel.GetWidth());
@@ -103,8 +103,8 @@ bool ImplScaleConvolutionHor(Bitmap& rSource, Bitmap& rTarget, const double& rSc
if(pReadAcc)
{
std::vector<double> aWeights;
- std::vector<long> aPixels;
- std::vector<long> aCounts;
+ std::vector<sal_Int32> aPixels;
+ std::vector<sal_Int32> aCounts;
long aNumberOfContributions(0);
const long nHeight(rSource.GetSizePixel().Height());
@@ -191,8 +191,8 @@ bool ImplScaleConvolutionVer(Bitmap& rSource, Bitmap& rTarget, const double& rSc
if(pReadAcc)
{
std::vector<double> aWeights;
- std::vector<long> aPixels;
- std::vector<long> aCounts;
+ std::vector<sal_Int32> aPixels;
+ std::vector<sal_Int32> aCounts;
long aNumberOfContributions(0);
const long nWidth(rSource.GetSizePixel().Width());
@@ -203,8 +203,14 @@ bool ImplScaleConvolutionVer(Bitmap& rSource, Bitmap& rTarget, const double& rSc
if(pWriteAcc)
{
+ std::vector<BitmapColor> aScanline(nHeight);
for(long x(0); x < nWidth; x++)
{
+ for(long y(0); y < nHeight; y++)
+ if(pReadAcc->HasPalette())
+ aScanline[y] = pReadAcc->GetPaletteColor(pReadAcc->GetPixelIndex(y, x));
+ else
+ aScanline[y] = pReadAcc->GetPixel(y, x);
for(long y(0); y < nNewHeight; y++)
{
const long aBaseIndex(y * aNumberOfContributions);
@@ -217,19 +223,8 @@ bool ImplScaleConvolutionVer(Bitmap& rSource, Bitmap& rTarget, const double& rSc
{
const long aIndex(aBaseIndex + j);
const double aWeight(aWeights[aIndex]);
- BitmapColor aColor;
-
aSum += aWeight;
-
- if(pReadAcc->HasPalette())
- {
- aColor = pReadAcc->GetPaletteColor(pReadAcc->GetPixelIndex(aPixels[aIndex], x));
- }
- else
- {
- aColor = pReadAcc->GetPixel(aPixels[aIndex], x);
- }
-
+ const BitmapColor & aColor = aScanline[aPixels[aIndex]];
aValueRed += aWeight * aColor.GetRed();
aValueGreen += aWeight * aColor.GetGreen();
aValueBlue += aWeight * aColor.GetBlue();