summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--vcl/Library_vcl.mk7
-rw-r--r--vcl/source/gdi/bitmap2.cxx20
-rw-r--r--vcl/unx/generic/gdi/salbmp.cxx15
3 files changed, 36 insertions, 6 deletions
diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk
index 0898286c7cae..92e35a2b3b98 100644
--- a/vcl/Library_vcl.mk
+++ b/vcl/Library_vcl.mk
@@ -429,6 +429,13 @@ vcl_headless_code=\
vcl/headless/svptext \
vcl/headless/svpvd
+$(eval $(call gb_Library_add_defs,vcl,\
+ $(if $(VALGRIND_CFLAGS), \
+ $(VALGRIND_CFLAGS) \
+ -DHAVE_MEMCHECK_H=1 \
+ ) \
+))
+
ifeq ($(GUIBASE),unx)
$(eval $(call gb_Library_add_defs,vcl,\
-DSAL_DLLPREFIX=\"$(gb_Library_SYSPRE)\" \
diff --git a/vcl/source/gdi/bitmap2.cxx b/vcl/source/gdi/bitmap2.cxx
index 90d407ee94e0..c559383ca756 100644
--- a/vcl/source/gdi/bitmap2.cxx
+++ b/vcl/source/gdi/bitmap2.cxx
@@ -36,6 +36,10 @@
#include <utility>
+#if defined(HAVE_MEMCHECK_H)
+#include <memcheck.h>
+#endif
+
// -----------
// - Defines -
@@ -903,6 +907,18 @@ sal_Bool Bitmap::ImplWriteDIBPalette( SvStream& rOStm, BitmapReadAccess& rAcc )
// ------------------------------------------------------------------
+#if defined(HAVE_MEMCHECK_H)
+namespace
+{
+ void blankExtraSpace(sal_uInt8 *pBits, long nWidth, long nScanlineSize, int nBitCount)
+ {
+ size_t nExtraSpaceInScanLine = nScanlineSize - nWidth * nBitCount / 8;
+ if (nExtraSpaceInScanLine)
+ memset(pBits + (nScanlineSize - nExtraSpaceInScanLine), 0, nExtraSpaceInScanLine);
+ }
+}
+#endif
+
sal_Bool Bitmap::ImplWriteDIBBits( SvStream& rOStm, BitmapReadAccess& rAcc,
sal_uLong nCompression, sal_uInt32& rImageSize )
{
@@ -975,6 +991,10 @@ sal_Bool Bitmap::ImplWriteDIBBits( SvStream& rOStm, BitmapReadAccess& rAcc,
const long nWidth = rAcc.Width();
const long nHeight = rAcc.Height();
sal_uInt8* pBuf = new sal_uInt8[ nAlignedWidth ];
+#if defined(HAVE_MEMCHECK_H)
+ if (RUNNING_ON_VALGRIND)
+ blankExtraSpace(pBuf, nWidth, nAlignedWidth, discretizeBitcount(nBitCount));
+#endif
sal_uInt8* pTmp;
sal_uInt8 cTmp;
diff --git a/vcl/unx/generic/gdi/salbmp.cxx b/vcl/unx/generic/gdi/salbmp.cxx
index d48cf985fcc5..e2f9e9743ffa 100644
--- a/vcl/unx/generic/gdi/salbmp.cxx
+++ b/vcl/unx/generic/gdi/salbmp.cxx
@@ -118,15 +118,18 @@ void X11SalBitmap::ImplRemovedFromCache()
}
#if defined(HAVE_MEMCHECK_H)
-void blankExtraSpace(BitmapBuffer* pDIB)
+namespace
{
- size_t nExtraSpaceInScanLine = pDIB->mnScanlineSize - pDIB->mnWidth * pDIB->mnBitCount / 8;
- if (nExtraSpaceInScanLine)
+ void blankExtraSpace(BitmapBuffer* pDIB)
{
- for (long i = 0; i < pDIB->mnHeight; ++i)
+ size_t nExtraSpaceInScanLine = pDIB->mnScanlineSize - pDIB->mnWidth * pDIB->mnBitCount / 8;
+ if (nExtraSpaceInScanLine)
{
- sal_uInt8 *pRow = pDIB->mpBits + (i * pDIB->mnScanlineSize);
- memset(pRow + (pDIB->mnScanlineSize - nExtraSpaceInScanLine), 0, nExtraSpaceInScanLine);
+ for (long i = 0; i < pDIB->mnHeight; ++i)
+ {
+ sal_uInt8 *pRow = pDIB->mpBits + (i * pDIB->mnScanlineSize);
+ memset(pRow + (pDIB->mnScanlineSize - nExtraSpaceInScanLine), 0, nExtraSpaceInScanLine);
+ }
}
}
}