[Libreoffice-commits] core.git: 2 commits - external/harfbuzz include/vcl vcl/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Mon Jul 30 11:59:41 UTC 2018
external/harfbuzz/harfbuzz-rtti.patch | 12 +--
include/vcl/BitmapGaussianSeparableBlurFilter.hxx | 8 +-
vcl/source/bitmap/BitmapGaussianSeparableBlurFilter.cxx | 60 +++++++--------
vcl/source/bitmap/BitmapScaleConvolutionFilter.cxx | 62 ++++++++--------
4 files changed, 71 insertions(+), 71 deletions(-)
New commits:
commit e3c8f4978a797f2b999865b7d6ebd65aa1ef93f4
Author: Caolán McNamara <caolanm at redhat.com>
AuthorDate: Mon Jul 30 10:07:46 2018 +0100
Commit: Caolán McNamara <caolanm at redhat.com>
CommitDate: Mon Jul 30 13:59:29 2018 +0200
Related: rhbz#1602589 rework to avoid bogus cppcheck double free warning
Change-Id: Ie673de68f39b903536c2287b8989fe6afcc9fd66
Reviewed-on: https://gerrit.libreoffice.org/58307
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
Tested-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/include/vcl/BitmapGaussianSeparableBlurFilter.hxx b/include/vcl/BitmapGaussianSeparableBlurFilter.hxx
index 6e6a3a09e6f0..c1359dab4761 100644
--- a/include/vcl/BitmapGaussianSeparableBlurFilter.hxx
+++ b/include/vcl/BitmapGaussianSeparableBlurFilter.hxx
@@ -12,6 +12,7 @@
#define INCLUDED_VCL_BITMAPGAUSSIANSEPARABLEBLURFILTER_HXX
#include <vcl/BitmapFilter.hxx>
+#include <vector>
class BitmapEx;
@@ -39,10 +40,11 @@ private:
int aNumberOfContributions, const double* pWeights, int const* pPixels,
const int* pCount);
- static double* makeBlurKernel(const double radius, int& rows);
+ static std::vector<double> makeBlurKernel(const double radius, int& rows);
static void blurContributions(const int aSize, const int aNumberOfContributions,
- const double* pBlurVector, double*& pWeights, int*& pPixels,
- int*& pCount);
+ const std::vector<double>& rBlurVector,
+ std::vector<double>& rWeights, std::vector<int>& rPixels,
+ std::vector<int>& rCounts);
};
#endif
diff --git a/vcl/source/bitmap/BitmapGaussianSeparableBlurFilter.cxx b/vcl/source/bitmap/BitmapGaussianSeparableBlurFilter.cxx
index b28ce99e8d19..d65d82e238b3 100644
--- a/vcl/source/bitmap/BitmapGaussianSeparableBlurFilter.cxx
+++ b/vcl/source/bitmap/BitmapGaussianSeparableBlurFilter.cxx
@@ -26,14 +26,13 @@ BitmapEx BitmapGaussianSeparableBlurFilter::execute(BitmapEx const& rBitmapEx)
// Prepare Blur Vector
int aNumberOfContributions;
- double* pBlurVector = makeBlurKernel(mfRadius, aNumberOfContributions);
-
- double* pWeights;
- int* pPixels;
- int* pCount;
+ std::vector<double> aBlurVector(makeBlurKernel(mfRadius, aNumberOfContributions));
+ std::vector<double> aWeights;
+ std::vector<int> aPixels;
+ std::vector<int> aCounts;
// Do horizontal filtering
- blurContributions(nWidth, aNumberOfContributions, pBlurVector, pWeights, pPixels, pCount);
+ blurContributions(nWidth, aNumberOfContributions, aBlurVector, aWeights, aPixels, aCounts);
Bitmap::ScopedReadAccess pReadAcc(aBitmap);
@@ -41,17 +40,17 @@ BitmapEx BitmapGaussianSeparableBlurFilter::execute(BitmapEx const& rBitmapEx)
Bitmap aNewBitmap(Size(nHeight, nWidth), 24);
bool bResult = convolutionPass(aBitmap, aNewBitmap, pReadAcc.get(), aNumberOfContributions,
- pWeights, pPixels, pCount);
+ aWeights.data(), aPixels.data(), aCounts.data());
// Cleanup
pReadAcc.reset();
- delete[] pWeights;
- delete[] pPixels;
- delete[] pCount;
+ aWeights.clear();
+ aPixels.clear();
+ aCounts.clear();
if (!bResult)
{
- delete[] pBlurVector;
+ aBlurVector.clear();
}
else
{
@@ -59,19 +58,19 @@ BitmapEx BitmapGaussianSeparableBlurFilter::execute(BitmapEx const& rBitmapEx)
aBitmap.ReassignWithSize(aNewBitmap);
// Do vertical filtering
- blurContributions(nHeight, aNumberOfContributions, pBlurVector, pWeights, pPixels, pCount);
+ blurContributions(nHeight, aNumberOfContributions, aBlurVector, aWeights, aPixels, aCounts);
pReadAcc = Bitmap::ScopedReadAccess(aBitmap);
aNewBitmap = Bitmap(Size(nWidth, nHeight), 24);
bResult = convolutionPass(aBitmap, aNewBitmap, pReadAcc.get(), aNumberOfContributions,
- pWeights, pPixels, pCount);
+ aWeights.data(), aPixels.data(), aCounts.data());
// Cleanup
pReadAcc.reset();
- delete[] pWeights;
- delete[] pCount;
- delete[] pPixels;
- delete[] pBlurVector;
+ aWeights.clear();
+ aCounts.clear();
+ aPixels.clear();
+ aBlurVector.clear();
if (bResult)
aBitmap.ReassignWithSize(aNewBitmap); // swap current bitmap with new bitmap
@@ -138,11 +137,12 @@ bool BitmapGaussianSeparableBlurFilter::convolutionPass(Bitmap& rBitmap, Bitmap&
return true;
}
-double* BitmapGaussianSeparableBlurFilter::makeBlurKernel(const double radius, int& rows)
+std::vector<double> BitmapGaussianSeparableBlurFilter::makeBlurKernel(const double radius,
+ int& rows)
{
int intRadius = static_cast<int>(radius + 1.0);
rows = intRadius * 2 + 1;
- double* matrix = new double[rows];
+ std::vector<double> matrix(rows);
double sigma = radius / 3;
double radius2 = radius * radius;
@@ -163,15 +163,13 @@ double* BitmapGaussianSeparableBlurFilter::makeBlurKernel(const double radius, i
return matrix;
}
-void BitmapGaussianSeparableBlurFilter::blurContributions(const int aSize,
- const int aNumberOfContributions,
- const double* pBlurVector,
- double*& pWeights, int*& pPixels,
- int*& pCount)
+void BitmapGaussianSeparableBlurFilter::blurContributions(
+ const int aSize, const int aNumberOfContributions, const std::vector<double>& rBlurVector,
+ std::vector<double>& rWeights, std::vector<int>& rPixels, std::vector<int>& rCounts)
{
- pWeights = new double[aSize * aNumberOfContributions];
- pPixels = new int[aSize * aNumberOfContributions];
- pCount = new int[aSize];
+ rWeights.resize(aSize * aNumberOfContributions);
+ rPixels.resize(aSize * aNumberOfContributions);
+ rCounts.resize(aSize);
int aLeft, aRight, aCurrentCount, aPixelIndex;
double aWeight;
@@ -183,7 +181,7 @@ void BitmapGaussianSeparableBlurFilter::blurContributions(const int aSize,
aCurrentCount = 0;
for (int j = aLeft; j <= aRight; j++)
{
- aWeight = pBlurVector[aCurrentCount];
+ aWeight = rBlurVector[aCurrentCount];
// Mirror edges
if (j < 0)
@@ -205,12 +203,12 @@ void BitmapGaussianSeparableBlurFilter::blurContributions(const int aSize,
aWeight = 0.0;
}
- pWeights[i * aNumberOfContributions + aCurrentCount] = aWeight;
- pPixels[i * aNumberOfContributions + aCurrentCount] = aPixelIndex;
+ rWeights[i * aNumberOfContributions + aCurrentCount] = aWeight;
+ rPixels[i * aNumberOfContributions + aCurrentCount] = aPixelIndex;
aCurrentCount++;
}
- pCount[i] = aCurrentCount;
+ rCounts[i] = aCurrentCount;
}
}
diff --git a/vcl/source/bitmap/BitmapScaleConvolutionFilter.cxx b/vcl/source/bitmap/BitmapScaleConvolutionFilter.cxx
index e14f9930e47b..566abf22c78a 100644
--- a/vcl/source/bitmap/BitmapScaleConvolutionFilter.cxx
+++ b/vcl/source/bitmap/BitmapScaleConvolutionFilter.cxx
@@ -37,9 +37,9 @@ void ImplCalculateContributions(
const long aSourceSize,
const long aDestinationSize,
long& aNumberOfContributions,
- double*& pWeights,
- long*& pPixels,
- long*& pCount,
+ std::vector<double>& rWeights,
+ std::vector<long>& rPixels,
+ std::vector<long>& rCounts,
const Kernel& aKernel)
{
const double fSamplingRadius(aKernel.GetWidth());
@@ -49,9 +49,9 @@ void ImplCalculateContributions(
aNumberOfContributions = (long(fabs(ceil(fScaledRadius))) * 2) + 1;
const long nAllocSize(aDestinationSize * aNumberOfContributions);
- pWeights = new double[nAllocSize];
- pPixels = new long[nAllocSize];
- pCount = new long[aDestinationSize];
+ rWeights.resize(nAllocSize);
+ rPixels.resize(nAllocSize);
+ rCounts.resize(aDestinationSize);
for(long i(0); i < aDestinationSize; i++)
{
@@ -75,13 +75,13 @@ void ImplCalculateContributions(
const long aPixelIndex(MinMax(j, 0, aSourceSize - 1));
const long nIndex(aIndex + aCurrentCount);
- pWeights[nIndex] = aWeight;
- pPixels[nIndex] = aPixelIndex;
+ rWeights[nIndex] = aWeight;
+ rPixels[nIndex] = aPixelIndex;
aCurrentCount++;
}
- pCount[i] = aCurrentCount;
+ rCounts[i] = aCurrentCount;
}
}
@@ -101,13 +101,13 @@ bool ImplScaleConvolutionHor(Bitmap& rSource, Bitmap& rTarget, const double& rSc
if(pReadAcc)
{
- double* pWeights = nullptr;
- long* pPixels = nullptr;
- long* pCount = nullptr;
+ std::vector<double> aWeights;
+ std::vector<long> aPixels;
+ std::vector<long> aCounts;
long aNumberOfContributions(0);
const long nHeight(rSource.GetSizePixel().Height());
- ImplCalculateContributions(nWidth, nNewWidth, aNumberOfContributions, pWeights, pPixels, pCount, aKernel);
+ ImplCalculateContributions(nWidth, nNewWidth, aNumberOfContributions, aWeights, aPixels, aCounts, aKernel);
rTarget = Bitmap(Size(nNewWidth, nHeight), 24);
BitmapScopedWriteAccess pWriteAcc(rTarget);
bool bResult(pWriteAcc);
@@ -126,21 +126,21 @@ bool ImplScaleConvolutionHor(Bitmap& rSource, Bitmap& rTarget, const double& rSc
double aValueGreen(0.0);
double aValueBlue(0.0);
- for(long j(0); j < pCount[x]; j++)
+ for(long j(0); j < aCounts[x]; j++)
{
const long aIndex(aBaseIndex + j);
- const double aWeight(pWeights[aIndex]);
+ const double aWeight(aWeights[aIndex]);
BitmapColor aColor;
aSum += aWeight;
if(pReadAcc->HasPalette())
{
- aColor = pReadAcc->GetPaletteColor(pReadAcc->GetIndexFromData(pScanlineRead, pPixels[aIndex]));
+ aColor = pReadAcc->GetPaletteColor(pReadAcc->GetIndexFromData(pScanlineRead, aPixels[aIndex]));
}
else
{
- aColor = pReadAcc->GetPixelFromData(pScanlineRead, pPixels[aIndex]);
+ aColor = pReadAcc->GetPixelFromData(pScanlineRead, aPixels[aIndex]);
}
aValueRed += aWeight * aColor.GetRed();
@@ -160,9 +160,9 @@ bool ImplScaleConvolutionHor(Bitmap& rSource, Bitmap& rTarget, const double& rSc
pWriteAcc.reset();
}
- delete[] pWeights;
- delete[] pCount;
- delete[] pPixels;
+ aWeights.clear();
+ aCounts.clear();
+ aPixels.clear();
if(bResult)
{
@@ -189,13 +189,13 @@ bool ImplScaleConvolutionVer(Bitmap& rSource, Bitmap& rTarget, const double& rSc
if(pReadAcc)
{
- double* pWeights = nullptr;
- long* pPixels = nullptr;
- long* pCount = nullptr;
+ std::vector<double> aWeights;
+ std::vector<long> aPixels;
+ std::vector<long> aCounts;
long aNumberOfContributions(0);
const long nWidth(rSource.GetSizePixel().Width());
- ImplCalculateContributions(nHeight, nNewHeight, aNumberOfContributions, pWeights, pPixels, pCount, aKernel);
+ ImplCalculateContributions(nHeight, nNewHeight, aNumberOfContributions, aWeights, aPixels, aCounts, aKernel);
rTarget = Bitmap(Size(nWidth, nNewHeight), 24);
BitmapScopedWriteAccess pWriteAcc(rTarget);
bool bResult(pWriteAcc);
@@ -212,21 +212,21 @@ bool ImplScaleConvolutionVer(Bitmap& rSource, Bitmap& rTarget, const double& rSc
double aValueGreen(0.0);
double aValueBlue(0.0);
- for(long j(0); j < pCount[y]; j++)
+ for(long j(0); j < aCounts[y]; j++)
{
const long aIndex(aBaseIndex + j);
- const double aWeight(pWeights[aIndex]);
+ const double aWeight(aWeights[aIndex]);
BitmapColor aColor;
aSum += aWeight;
if(pReadAcc->HasPalette())
{
- aColor = pReadAcc->GetPaletteColor(pReadAcc->GetPixelIndex(pPixels[aIndex], x));
+ aColor = pReadAcc->GetPaletteColor(pReadAcc->GetPixelIndex(aPixels[aIndex], x));
}
else
{
- aColor = pReadAcc->GetPixel(pPixels[aIndex], x);
+ aColor = pReadAcc->GetPixel(aPixels[aIndex], x);
}
aValueRed += aWeight * aColor.GetRed();
@@ -251,9 +251,9 @@ bool ImplScaleConvolutionVer(Bitmap& rSource, Bitmap& rTarget, const double& rSc
}
}
- delete[] pWeights;
- delete[] pCount;
- delete[] pPixels;
+ aWeights.clear();
+ aCounts.clear();
+ aPixels.clear();
if(bResult)
{
commit d12b73008a29317e779920e02ac521fd7af70017
Author: Caolán McNamara <caolanm at redhat.com>
AuthorDate: Mon Jul 30 08:51:35 2018 +0100
Commit: Caolán McNamara <caolanm at redhat.com>
CommitDate: Mon Jul 30 13:59:18 2018 +0200
harfbuzz-rtti.patch doesn't apply
Change-Id: Ia634c008799793f3a54354a3f7fc13446f7db3c5
Reviewed-on: https://gerrit.libreoffice.org/58302
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
Tested-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/external/harfbuzz/harfbuzz-rtti.patch b/external/harfbuzz/harfbuzz-rtti.patch
index 83fd0f40b856..5d1cfb4959ae 100644
--- a/external/harfbuzz/harfbuzz-rtti.patch
+++ b/external/harfbuzz/harfbuzz-rtti.patch
@@ -1,11 +1,11 @@
--- configure
+++ configure
-@@ -18918,7 +18918,7 @@
- LDFLAGS="$LDFLAGS -Bsymbolic-functions"
-
- # Make sure we don't link to libstdc++
-- CXXFLAGS="$CXXFLAGS -fno-rtti -fno-exceptions"
-+ CXXFLAGS="$CXXFLAGS -fno-exceptions"
+@@ -19012,7 +19012,7 @@
+ # even in the cases where we DO link to libstdc++.
+ # Put -fno-rtti before $CXXFLAGS such that users can re-enable it
+ # by overriding CXXFLAGS.
+- CXXFLAGS="-fno-rtti $CXXFLAGS -fno-exceptions -fno-threadsafe-statics"
++ CXXFLAGS="$CXXFLAGS -fno-exceptions -fno-threadsafe-statics"
# Assorted warnings
CXXFLAGS="$CXXFLAGS -Wcast-align"
More information about the Libreoffice-commits
mailing list