Kaydet (Commit) beacd77a authored tarafından Noel Grandin's avatar Noel Grandin

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: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst 24503d5d
......@@ -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();
......
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