summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--vcl/Library_vclplug_gen.mk7
-rw-r--r--vcl/unx/generic/gdi/salbmp.cxx31
2 files changed, 38 insertions, 0 deletions
diff --git a/vcl/Library_vclplug_gen.mk b/vcl/Library_vclplug_gen.mk
index c9c9bbe6468f..31df6c2d95c5 100644
--- a/vcl/Library_vclplug_gen.mk
+++ b/vcl/Library_vclplug_gen.mk
@@ -132,6 +132,13 @@ $(eval $(call gb_Library_add_defs,vclplug_gen,\
endif
endif
+$(eval $(call gb_Library_add_defs,vclplug_gen,\
+ $(if $(VALGRIND_CFLAGS), \
+ $(VALGRIND_CFLAGS) \
+ -DHAVE_MEMCHECK_H=1 \
+ ) \
+))
+
## handle Xinerama
ifneq ($(USE_XINERAMA),NO)
ifneq ($(OS),SOLARIS)
diff --git a/vcl/unx/generic/gdi/salbmp.cxx b/vcl/unx/generic/gdi/salbmp.cxx
index b8b9f42f9302..d48cf985fcc5 100644
--- a/vcl/unx/generic/gdi/salbmp.cxx
+++ b/vcl/unx/generic/gdi/salbmp.cxx
@@ -53,6 +53,10 @@
#include <unx/salinst.h>
#include <unx/x11/xlimits.hxx>
+#if defined(HAVE_MEMCHECK_H)
+#include <memcheck.h>
+#endif
+
// -----------
// - Defines -
// -----------
@@ -113,6 +117,21 @@ void X11SalBitmap::ImplRemovedFromCache()
delete mpDDB, mpDDB = NULL;
}
+#if defined(HAVE_MEMCHECK_H)
+void blankExtraSpace(BitmapBuffer* pDIB)
+{
+ size_t nExtraSpaceInScanLine = pDIB->mnScanlineSize - pDIB->mnWidth * pDIB->mnBitCount / 8;
+ if (nExtraSpaceInScanLine)
+ {
+ for (long i = 0; i < pDIB->mnHeight; ++i)
+ {
+ sal_uInt8 *pRow = pDIB->mpBits + (i * pDIB->mnScanlineSize);
+ memset(pRow + (pDIB->mnScanlineSize - nExtraSpaceInScanLine), 0, nExtraSpaceInScanLine);
+ }
+ }
+}
+#endif
+
// -----------------------------------------------------------------------------
BitmapBuffer* X11SalBitmap::ImplCreateDIB(
@@ -186,6 +205,10 @@ BitmapBuffer* X11SalBitmap::ImplCreateDIB(
try
{
pDIB->mpBits = new sal_uInt8[ pDIB->mnScanlineSize * pDIB->mnHeight ];
+#if defined(HAVE_MEMCHECK_H)
+ if (RUNNING_ON_VALGRIND)
+ blankExtraSpace(pDIB);
+#endif
}
catch (const std::bad_alloc&)
{
@@ -530,6 +553,10 @@ XImage* X11SalBitmap::ImplCreateXImage(
if( pDstBuf && pDstBuf->mpBits )
{
+#if defined(HAVE_MEMCHECK_H)
+ if (RUNNING_ON_VALGRIND)
+ blankExtraSpace(pDstBuf);
+#endif
// set data in buffer as data member in pImage
pImage->data = (char*) pDstBuf->mpBits;
@@ -704,6 +731,10 @@ bool X11SalBitmap::Create( const SalBitmap& rSSalBmp )
try
{
mpDIB->mpBits = new sal_uInt8[ mpDIB->mnScanlineSize * mpDIB->mnHeight ];
+#if defined(HAVE_MEMCHECK_H)
+ if (RUNNING_ON_VALGRIND)
+ blankExtraSpace(mpDIB);
+#endif
}
catch (const std::bad_alloc&)
{